]>
Commit | Line | Data |
---|---|---|
f4fe6fc4 DM |
1 | package PMG::RuleDB::IPAddress; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
f4fe6fc4 DM |
5 | use DBI; |
6 | ||
7 | use PMG::Utils; | |
8 | use PMG::RuleDB::WhoRegex; | |
9 | ||
10 | use base qw(PMG::RuleDB::WhoRegex); | |
11 | ||
12 | sub otype { | |
13 | return 1003; | |
14 | } | |
15 | ||
16 | sub otype_text { | |
17 | return 'IP Address'; | |
18 | } | |
19 | ||
f4fe6fc4 DM |
20 | sub new { |
21 | my ($type, $address, $ogroup) = @_; | |
22 | ||
23 | my $class = ref($type) || $type; | |
24 | ||
25 | $address //= '127.0.0.1'; | |
26 | ||
27 | my $self = $class->SUPER::new($address, $ogroup); | |
28 | ||
29 | return $self; | |
30 | } | |
31 | ||
32 | sub who_match { | |
33 | my ($self, $addr, $ip) = @_; | |
34 | ||
f4fe6fc4 DM |
35 | return 0 if !$ip; |
36 | ||
37 | return $self->{address} eq $ip; | |
38 | } | |
39 | ||
1ad24a43 DM |
40 | sub properties { |
41 | my ($class) = @_; | |
42 | ||
43 | return { | |
44 | ip => { | |
45 | description => "IP address", | |
46 | type => 'string', format => 'ip', | |
47 | }, | |
48 | }; | |
49 | } | |
50 | ||
718d48a7 DM |
51 | sub get { |
52 | my ($self) = @_; | |
53 | ||
54 | return { ip => $self->{address} }; | |
55 | } | |
56 | ||
1ad24a43 DM |
57 | sub update { |
58 | my ($self, $param) = @_; | |
59 | ||
60 | $self->{address} = $param->{ip}; | |
f4fe6fc4 DM |
61 | } |
62 | ||
63 | 1; | |
64 | ||
65 | __END__ | |
66 | ||
67 | =head1 PMG::RuleDB::IPAddress | |
68 | ||
69 | A WHO object to check sender IP addresses. | |
70 | ||
71 | =head2 Attribues | |
72 | ||
73 | =head3 address | |
74 | ||
75 | An IP address. | |
76 | ||
77 | =head2 Examples | |
78 | ||
79 | $obj = PMG::RuleDB::IPAddress->new('192.168.2.1'); | |
80 |