| 1 | package Mail::Decency::Policy::CBL; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | extends 'Mail::Decency::Policy::Core::CWLCBL'; | ||
| 5 | |||
| 6 | use version 0.74; our $VERSION = qv( "v0.1.4" ); | ||
| 7 | |||
| 8 | use mro 'c3'; | ||
| 9 | |||
| 10 | use Data::Dumper; | ||
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | Mail::Decency::Policy::CWL | ||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | =head1 DESCRIPTION | ||
| 19 | |||
| 20 | Implementation of a custom whitelist based on sending server (ip/hostname), sending domain or (domain.tld) sending address (email@domain.tld). | ||
| 21 | |||
| 22 | =head2 CONFIG | ||
| 23 | |||
| 24 | --- | ||
| 25 | |||
| 26 | disable: 0 | ||
| 27 | |||
| 28 | # enable negative cache (non-hits) | ||
| 29 | use_negative_cache: 1 | ||
| 30 | |||
| 31 | # enable all tables | ||
| 32 | tables: | ||
| 33 | - ips | ||
| 34 | - domains | ||
| 35 | - addresses | ||
| 36 | |||
| 37 | |||
| 38 | =head1 DATABASE | ||
| 39 | |||
| 40 | CREATE TABLE cbl_ips ( | ||
| 41 | id INTEGER PRIMARY KEY, | ||
| 42 | recipient_domain varchar( 255 ), | ||
| 43 | client_address varchar( 39 ) | ||
| 44 | ); | ||
| 45 | CREATE UNIQUE INDEX cbl_ips_uk ON cbl_ips( recipient_domain, client_address ); | ||
| 46 | |||
| 47 | CREATE TABLE cbl_domains ( | ||
| 48 | id INTEGER PRIMARY KEY, | ||
| 49 | recipient_domain varchar( 255 ), | ||
| 50 | sender_domain varchar( 255 ) | ||
| 51 | ); | ||
| 52 | CREATE UNIQUE INDEX cbl_domains_uk ON cbl_domains( recipient_domain, sender_domain ); | ||
| 53 | |||
| 54 | CREATE TABLE cbl_addresses ( | ||
| 55 | id INTEGER PRIMARY KEY, | ||
| 56 | recipient_domain varchar( 255 ), | ||
| 57 | sender_address varchar( 255 ) | ||
| 58 | ); | ||
| 59 | CREATE UNIQUE INDEX cbl_addresses_uk ON cbl_addresses( recipient_domain, sender_address ); | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | =head1 CLASS ATTRIBUTES | ||
| 64 | |||
| 65 | =cut | ||
| 66 | |||
| 67 | has schema_definition => ( is => 'ro', isa => 'HashRef[HashRef]', default => sub { | ||
| 68 | { | ||
| 69 | cbl => { | ||
| 70 | ips => { | ||
| 71 | recipient_domain => [ varchar => 255 ], | ||
| 72 | client_address => [ varchar => 39 ], | ||
| 73 | -unique => [ 'recipient_domain', 'client_address' ] | ||
| 74 | }, | ||
| 75 | domains => { | ||
| 76 | recipient_domain => [ varchar => 255 ], | ||
| 77 | sender_domain => [ varchar => 255 ], | ||
| 78 | -unique => [ 'recipient_domain', 'sender_domain' ] | ||
| 79 | }, | ||
| 80 | addresses => { | ||
| 81 | recipient_domain => [ varchar => 255 ], | ||
| 82 | sender_address => [ varchar => 255 ], | ||
| 83 | -unique => [ 'recipient_domain', 'sender_address' ] | ||
| 84 | }, | ||
| 85 | } | ||
| 86 | }; | ||
| 87 | } ); | ||
| 88 | |||
| 89 | |||
| 90 | =head1 METHODS | ||
| 91 | |||
| 92 | |||
| 93 | =head2 init | ||
| 94 | |||
| 95 | =cut | ||
| 96 | |||
| 97 | sub init { | ||
| 98 | my ( $self ) = @_; | ||
| 99 | |||
| 100 | $self->next::method(); | ||
| 101 | $self->{ _handle_on_hit } = 'REJECT'; | ||
| 102 | $self->{ _table_prefix } = 'cbl'; | ||
| 103 | $self->{ _use_weight } = 1; | ||
| 104 | $self->{ _description } = 'Custom Black List'; | ||
| 105 | } | ||
| 106 | |||
| 107 | =head1 AUTHOR | ||
| 108 | |||
| 109 | Ulrich Kautz <uk@fortrabbit.de> | ||
| 110 | |||
| 111 | =head1 COPYRIGHT | ||
| 112 | |||
| 113 | Copyright (c) 2010 the L</AUTHOR> as listed above | ||
| 114 | |||
| 115 | =head1 LICENCSE | ||
| 116 | |||
| 117 | This library is free software and may be distributed under the same terms as perl itself. | ||
| 118 | |||
| 119 | =cut | ||
| 120 | |||
| 121 | |||
| 122 | |||
| 123 | 1; |