GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
POE::Component::Client::DNSBL(3) User Contributed Perl Documentation POE::Component::Client::DNSBL(3)

POE::Component::Client::DNSBL - A component that provides non-blocking DNSBL lookups

version 1.08

  use strict;
  use POE qw(Component::Client::DNSBL);

  die "Please provide at least one IP address to lookup\n" unless scalar @ARGV;

  my $dnsbl = POE::Component::Client::DNSBL->spawn();

  POE::Session->create(
        package_states => [
            'main' => [ qw(_start _stop _response) ],
        ],
        heap => {
                  addresses => [ @ARGV ],
                  dnsbl => $dnsbl
        },
  );

  $poe_kernel->run();
  exit 0;

  sub _start {
     my ($kernel,$heap) = @_[KERNEL,HEAP];
     $heap->{dnsbl}->lookup(
        event => '_response',
        address => $_,
     ) for @{ $heap->{addresses} };
     return;
  }

  sub _stop {
     my ($kernel,$heap) = @_[KERNEL,HEAP];
     $kernel->call( $heap->{dnsbl}->session_id(), 'shutdown' );
     return;
  }

  sub _response {
     my ($kernel,$heap,$record) = @_[KERNEL,HEAP,ARG0];
     if ( $record->{error} ) {
        print "An error occurred, ", $record->{error}, "\n";
        return;
     }
     if ( $record->{response} eq 'NXDOMAIN' ) {
        print $record->{address}, " is okay\n";
        return;
     }
     print join( " ", $record->{address}, $record->{response}, $record->{reason} ), "\n";
     return;
  }

POE::Component::Client::DNSBL is a POE component that provides non-blocking DNS blacklist lookups to other components and POE sessions. It uses POE::Component::Client::DNS to perform the requested queries.

Only IPv4 lookups and URI/RHS lookups are supported and unless a DNSBL zone is specified the component will use zen.spamhaus.org.

"spawn"
Takes a number of parameters:

  'alias', set an alias that you can use to address the component later;
  'options', a hashref of POE session options;
  'dnsbl', the DNSBL zone to send queries to, default zen.spamhaus.org;
  'resolver', optionally provide a POE::Component::Client::DNS to use;
    

Returns an object.

"session_id"
Takes no arguments. Returns the ID of the component's session.
"shutdown"
Terminates the component.
"lookup"
Performs a DNSBL lookup. Takes a number of parameters:

  'event', the name of the event to send the reply to. ( Mandatory );
  'address', the IPv4 address or domain to lookup ( Mandatory );
  'session', send the resultant event to an alternative session, ( default is the sender );
    

You may also pass arbitary key/values. Arbitary keys should have an underscore prefix '_'.

"event" may also be a POE::Session postback.

"shutdown"
Terminates the component.
"lookup"
Performs a DNSBL lookup. Takes a number of parameters:

  'event', the name of the event to send the reply to. ( Mandatory );
  'address', the IPv4 address or domain to lookup ( Mandatory );
  'session', send the resultant event to an alternative session, ( default is the sender );
  'dnsbl', optionally override the configured DNSBL for this particular lookup;
    

You may also pass arbitary key/values. Arbitary keys should have an underscore prefix '_'.

"event" may also be a POE::Session postback.

The component will send an event in response to "lookup" requests. "ARG0" will be a hashref containing the key/values of the original request ( including any arbitary key/values passed ).

If a POE::Session postback was specified, then the hashref will be the first parameter of the arrayref given as "ARG1"

  'response', the status returned by the DNSBL, it will be NXDOMAIN if the address given was okay;
  'reason', if an address is blacklisted, this may contain the reason;
  'error', if something goes wrong with the DNS lookup the error string will be contained here;
  'dnsbl', the DNSBL that was used for this request;

Chris "BinGOs" Williams <chris@bingosnet.co.uk>

Copyright © Chris Williamss.

This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details.

<http://en.wikipedia.org/wiki/DNSBL>

<http://www.spamhaus.org/zen/>

<http://www.spamhaus.org/dbl/>

POE

POE::Session

POE::Component::Client::DNS

Chris Williams <chris@bingosnet.co.uk>

This software is copyright (c) 2011 by Chris Williams.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2011-11-17 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.