Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/PersistentAddrList.pm |
Statements | Executed 17 statements in 917µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 60µs | 72µs | BEGIN@49 | Mail::SpamAssassin::PersistentAddrList::
1 | 1 | 1 | 33µs | 37µs | BEGIN@51 | Mail::SpamAssassin::PersistentAddrList::
1 | 1 | 1 | 29µs | 52µs | BEGIN@50 | Mail::SpamAssassin::PersistentAddrList::
1 | 1 | 1 | 28µs | 88µs | BEGIN@52 | Mail::SpamAssassin::PersistentAddrList::
1 | 1 | 1 | 26µs | 107µs | BEGIN@54 | Mail::SpamAssassin::PersistentAddrList::
1 | 1 | 1 | 23µs | 23µs | new | Mail::SpamAssassin::PersistentAddrList::
0 | 0 | 0 | 0s | 0s | add_score | Mail::SpamAssassin::PersistentAddrList::
0 | 0 | 0 | 0s | 0s | finish | Mail::SpamAssassin::PersistentAddrList::
0 | 0 | 0 | 0s | 0s | get_addr_entry | Mail::SpamAssassin::PersistentAddrList::
0 | 0 | 0 | 0s | 0s | new_checker | Mail::SpamAssassin::PersistentAddrList::
0 | 0 | 0 | 0s | 0s | remove_entry | Mail::SpamAssassin::PersistentAddrList::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # <@LICENSE> | ||||
2 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||||
3 | # contributor license agreements. See the NOTICE file distributed with | ||||
4 | # this work for additional information regarding copyright ownership. | ||||
5 | # The ASF licenses this file to you under the Apache License, Version 2.0 | ||||
6 | # (the "License"); you may not use this file except in compliance with | ||||
7 | # the License. You may obtain a copy of the License at: | ||||
8 | # | ||||
9 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||
10 | # | ||||
11 | # Unless required by applicable law or agreed to in writing, software | ||||
12 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
14 | # See the License for the specific language governing permissions and | ||||
15 | # limitations under the License. | ||||
16 | # </@LICENSE> | ||||
17 | |||||
18 | =head1 NAME | ||||
19 | |||||
20 | Mail::SpamAssassin::PersistentAddrList - persistent address list base class | ||||
21 | |||||
22 | =head1 SYNOPSIS | ||||
23 | |||||
24 | my $factory = PersistentAddrListSubclass->new(); | ||||
25 | $spamtest->set_persistent_addr_list_factory ($factory); | ||||
26 | ... call into SpamAssassin classes... | ||||
27 | |||||
28 | SpamAssassin will call: | ||||
29 | |||||
30 | my $addrlist = $factory->new_checker($spamtest); | ||||
31 | $entry = $addrlist->get_addr_entry ($addr); | ||||
32 | ... | ||||
33 | |||||
34 | =head1 DESCRIPTION | ||||
35 | |||||
36 | All persistent address list implementations, used by the auto-whitelist | ||||
37 | code to track known-good email addresses, use this as a base class. | ||||
38 | |||||
39 | See C<Mail::SpamAssassin::DBBasedAddrList> for an example. | ||||
40 | |||||
41 | =head1 METHODS | ||||
42 | |||||
43 | =over 4 | ||||
44 | |||||
45 | =cut | ||||
46 | |||||
47 | package Mail::SpamAssassin::PersistentAddrList; | ||||
48 | |||||
49 | 2 | 77µs | 2 | 85µs | # spent 72µs (60+13) within Mail::SpamAssassin::PersistentAddrList::BEGIN@49 which was called:
# once (60µs+13µs) by Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 at line 49 # spent 72µs making 1 call to Mail::SpamAssassin::PersistentAddrList::BEGIN@49
# spent 13µs making 1 call to strict::import |
50 | 2 | 72µs | 2 | 74µs | # spent 52µs (29+23) within Mail::SpamAssassin::PersistentAddrList::BEGIN@50 which was called:
# once (29µs+23µs) by Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 at line 50 # spent 52µs making 1 call to Mail::SpamAssassin::PersistentAddrList::BEGIN@50
# spent 23µs making 1 call to warnings::import |
51 | 2 | 70µs | 2 | 42µs | # spent 37µs (33+5) within Mail::SpamAssassin::PersistentAddrList::BEGIN@51 which was called:
# once (33µs+5µs) by Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 at line 51 # spent 37µs making 1 call to Mail::SpamAssassin::PersistentAddrList::BEGIN@51
# spent 5µs making 1 call to bytes::import |
52 | 2 | 100µs | 2 | 148µs | # spent 88µs (28+60) within Mail::SpamAssassin::PersistentAddrList::BEGIN@52 which was called:
# once (28µs+60µs) by Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 at line 52 # spent 88µs making 1 call to Mail::SpamAssassin::PersistentAddrList::BEGIN@52
# spent 60µs making 1 call to re::import |
53 | |||||
54 | 1 | 3µs | # spent 107µs (26+81) within Mail::SpamAssassin::PersistentAddrList::BEGIN@54 which was called:
# once (26µs+81µs) by Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 at line 56 | ||
55 | @ISA | ||||
56 | 1 | 533µs | 2 | 188µs | }; # spent 107µs making 1 call to Mail::SpamAssassin::PersistentAddrList::BEGIN@54
# spent 81µs making 1 call to vars::import |
57 | |||||
58 | 1 | 12µs | @ISA = qw(); | ||
59 | |||||
60 | ########################################################################### | ||||
61 | |||||
62 | =item $factory = PersistentAddrListSubclass->new(); | ||||
63 | |||||
64 | This creates a factory object, which SpamAssassin will call to create | ||||
65 | a new checker object for the persistent address list. | ||||
66 | |||||
67 | =cut | ||||
68 | |||||
69 | # spent 23µs within Mail::SpamAssassin::PersistentAddrList::new which was called:
# once (23µs+0s) by Mail::SpamAssassin::DBBasedAddrList::new at line 37 of Mail/SpamAssassin/DBBasedAddrList.pm | ||||
70 | 1 | 2µs | my $class = shift; | ||
71 | 1 | 2µs | $class = ref($class) || $class; | ||
72 | 1 | 12µs | my $self = { }; | ||
73 | 1 | 3µs | bless ($self, $class); | ||
74 | 1 | 23µs | $self; | ||
75 | } | ||||
76 | |||||
77 | ########################################################################### | ||||
78 | |||||
79 | =item my $addrlist = $factory->new_checker(); | ||||
80 | |||||
81 | Create a new address-list checker object from the factory. Called by the | ||||
82 | SpamAssassin classes. | ||||
83 | |||||
84 | =cut | ||||
85 | |||||
86 | sub new_checker { | ||||
87 | my ($factory, $main) = @_; | ||||
88 | die "auto-whitelist: unimplemented base method"; # override this | ||||
89 | } | ||||
90 | |||||
91 | ########################################################################### | ||||
92 | |||||
93 | =item $entry = $addrlist->get_addr_entry ($addr); | ||||
94 | |||||
95 | Given an email address C<$addr>, return an entry object with the details of | ||||
96 | that address. | ||||
97 | |||||
98 | The entry object is a reference to a hash, which must contain at least | ||||
99 | two keys: C<count>, which is the count of times that address has been | ||||
100 | encountered before; and C<totscore>, which is the total of all scores for | ||||
101 | messages associated with that address. From these two fields, an average | ||||
102 | score will be calculated, and the score for the current message will be | ||||
103 | regressed towards that mean message score. | ||||
104 | |||||
105 | The hash can contain whatever other data your back-end needs to store, | ||||
106 | under other keys. | ||||
107 | |||||
108 | The method should never return C<undef>, or a hash that does not contain | ||||
109 | a C<count> key and a C<totscore> key. | ||||
110 | |||||
111 | =cut | ||||
112 | |||||
113 | sub get_addr_entry { | ||||
114 | my ($self, $addr, $signedby) = @_; | ||||
115 | my $entry = { }; | ||||
116 | die "auto-whitelist: unimplemented base method"; # override this | ||||
117 | return $entry; | ||||
118 | } | ||||
119 | |||||
120 | ########################################################################### | ||||
121 | |||||
122 | =item $entry = $addrlist->add_score($entry, $score); | ||||
123 | |||||
124 | This method should add the given score to the whitelist database for the | ||||
125 | given entry, and then return the new entry. | ||||
126 | |||||
127 | =cut | ||||
128 | |||||
129 | sub add_score { | ||||
130 | my ($self, $entry, $score) = @_; | ||||
131 | die "auto-whitelist: unimplemented base method"; # override this | ||||
132 | } | ||||
133 | |||||
134 | ########################################################################### | ||||
135 | |||||
136 | =item $entry = $addrlist->remove_entry ($entry); | ||||
137 | |||||
138 | This method should remove the given entry from the whitelist database. | ||||
139 | |||||
140 | =cut | ||||
141 | |||||
142 | sub remove_entry { | ||||
143 | my ($self, $entry) = @_; | ||||
144 | die "auto-whitelist: unimplemented base method"; # override this | ||||
145 | } | ||||
146 | |||||
147 | ########################################################################### | ||||
148 | |||||
149 | =item $entry = $addrlist->finish (); | ||||
150 | |||||
151 | Clean up, if necessary. Called by SpamAssassin when it has finished | ||||
152 | checking, or adding to, the auto-whitelist database. | ||||
153 | |||||
154 | =cut | ||||
155 | |||||
156 | sub finish { | ||||
157 | my ($self) = @_; | ||||
158 | } | ||||
159 | |||||
160 | ########################################################################### | ||||
161 | |||||
162 | 1 | 9µs | 1; | ||
163 | |||||
164 | =back | ||||
165 | |||||
166 | =cut |