1NAME
2 POE::Component::Client::DNSBL - A component that provides non-blocking
3 DNSBL lookups
4
5VERSION
6 version 1.08
7
8SYNOPSIS
9 use strict;
10 use POE qw(Component::Client::DNSBL);
11
12 die "Please provide at least one IP address to lookup\n" unless scalar @ARGV;
13
14 my $dnsbl = POE::Component::Client::DNSBL->spawn();
15
16 POE::Session->create(
17 package_states => [
18 'main' => [ qw(_start _stop _response) ],
19 ],
20 heap => {
21 addresses => [ @ARGV ],
22 dnsbl => $dnsbl
23 },
24 );
25
26 $poe_kernel->run();
27 exit 0;
28
29 sub _start {
30 my ($kernel,$heap) = @_[KERNEL,HEAP];
31 $heap->{dnsbl}->lookup(
32 event => '_response',
33 address => $_,
34 ) for @{ $heap->{addresses} };
35 return;
36 }
37
38 sub _stop {
39 my ($kernel,$heap) = @_[KERNEL,HEAP];
40 $kernel->call( $heap->{dnsbl}->session_id(), 'shutdown' );
41 return;
42 }
43
44 sub _response {
45 my ($kernel,$heap,$record) = @_[KERNEL,HEAP,ARG0];
46 if ( $record->{error} ) {
47 print "An error occurred, ", $record->{error}, "\n";
48 return;
49 }
50 if ( $record->{response} eq 'NXDOMAIN' ) {
51 print $record->{address}, " is okay\n";
52 return;
53 }
54 print join( " ", $record->{address}, $record->{response}, $record->{reason} ), "\n";
55 return;
56 }
57
58DESCRIPTION
59 POE::Component::Client::DNSBL is a POE component that provides
60 non-blocking DNS blacklist lookups to other components and POE sessions.
61 It uses POE::Component::Client::DNS to perform the requested queries.
62
63 Only IPv4 lookups and URI/RHS lookups are supported and unless a DNSBL
64 zone is specified the component will use zen.spamhaus.org.
65
66CONSTRUCTOR
67 "spawn"
68 Takes a number of parameters:
69
70 'alias', set an alias that you can use to address the component later;
71 'options', a hashref of POE session options;
72 'dnsbl', the DNSBL zone to send queries to, default zen.spamhaus.org;
73 'resolver', optionally provide a POE::Component::Client::DNS to use;
74
75 Returns an object.
76
77METHODS
78 "session_id"
79 Takes no arguments. Returns the ID of the component's session.
80
81 "shutdown"
82 Terminates the component.
83
84 "lookup"
85 Performs a DNSBL lookup. Takes a number of parameters:
86
87 'event', the name of the event to send the reply to. ( Mandatory );
88 'address', the IPv4 address or domain to lookup ( Mandatory );
89 'session', send the resultant event to an alternative session, ( default is the sender );
90
91 You may also pass arbitary key/values. Arbitary keys should have an
92 underscore prefix '_'.
93
94 "event" may also be a POE::Session postback.
95
96INPUT EVENTS
97 "shutdown"
98 Terminates the component.
99
100 "lookup"
101 Performs a DNSBL lookup. Takes a number of parameters:
102
103 'event', the name of the event to send the reply to. ( Mandatory );
104 'address', the IPv4 address or domain to lookup ( Mandatory );
105 'session', send the resultant event to an alternative session, ( default is the sender );
106 'dnsbl', optionally override the configured DNSBL for this particular lookup;
107
108 You may also pass arbitary key/values. Arbitary keys should have an
109 underscore prefix '_'.
110
111 "event" may also be a POE::Session postback.
112
113OUTPUT EVENTS
114 The component will send an event in response to "lookup" requests.
115 "ARG0" will be a hashref containing the key/values of the original
116 request ( including any arbitary key/values passed ).
117
118 If a POE::Session postback was specified, then the hashref will be the
119 first parameter of the arrayref given as "ARG1"
120
121 'response', the status returned by the DNSBL, it will be NXDOMAIN if the address given was okay;
122 'reason', if an address is blacklisted, this may contain the reason;
123 'error', if something goes wrong with the DNS lookup the error string will be contained here;
124 'dnsbl', the DNSBL that was used for this request;
125
126AUTHOR
127 Chris "BinGOs" Williams <chris@bingosnet.co.uk>
128
129LICENSE
130 Copyright � Chris Williamss.
131
132 This module may be used, modified, and distributed under the same terms
133 as Perl itself. Please see the license that came with your Perl
134 distribution for details.
135
136SEE ALSO
137 <http://en.wikipedia.org/wiki/DNSBL>
138
139 <http://www.spamhaus.org/zen/>
140
141 <http://www.spamhaus.org/dbl/>
142
143 POE
144
145 POE::Session
146
147 POE::Component::Client::DNS
148
149AUTHOR
150 Chris Williams <chris@bingosnet.co.uk>
151
152COPYRIGHT AND LICENSE
153 This software is copyright (c) 2011 by Chris Williams.
154
155 This is free software; you can redistribute it and/or modify it under
156 the same terms as the Perl 5 programming language system itself.
157
158