Net::DNSBL::Utilities - functions for DNSBL daemons


Net-DNSBL-MultiDaemon documentation  | view source Contained in the Net-DNSBL-MultiDaemon distribution.

Index


NAME

Top

Net::DNSBL::Utilities - functions for DNSBL daemons

SYNOPSIS

Top

  use Net::DNSBL::Utilities qw(
        s_response 
        not_found  
        write_stats
	bystat
        statinit
        cntinit
	list2hash
        open_udpNB
        DO
	doINCLUDE
	list2NetAddr
	matchNetAddr
	list_countries
	setAUTH
	setRA
        A1271
        A1272
        A1273
        A1274
        A1275
	A1276
	A1277
  );

  s_response($mp,$resp,$id,$qdcount,$ancount,$nscount,$arcount);
  not_found($put,$name,$type,$id,$mp,$srp);
  write_stats($sfile,$cp,$sinit);
  $rv = bystat($cp);
  $timestamp = statinit($Sfile,$cp);
  cntinit($DNSBL,$cp);
  list2hash(\@list,$cp,$val);
  $sock = open_udpNB();
  $rv = DO($file,$nowarnings)
  $rv = doINCLUDE($file,$nowarnings);
  $rv=list2NetAddr(\@inlist,\@NAobject);
  $rv = matchNetAddr($ip,\@NAobject);
  ($countries,$code3s,$names) = list_countries;
  setAUTH(true/false);
  setRA(true/false);
  $netaddr = A1271;
  $netaddr = A1272;
  $netaddr = A1273;
  $netaddr = A1274;
  $netaddr = A1275;
  $netaddr = A1276;
  $netaddr = A1277;

DESCRIPTION

Top

Net::DNSBL::Utilities contains functions used to build DNSBL emulator daemons.

* s_response($mp,$resp,$id,$qdcount,$ancount,$nscount,$arcount);

Put a short response into the message buffer pointed to by $mp by sticking a new header on the EXISTING received query.

  input:	msg pointer,
 		id of question,
 		qd, an, ns, ar counts
  returns: 	nada

* not_found($put,$name,$type,$id,$mp,$srp);

Put a new 'not found' response in the buffer pointed to by $mp.

  input:	put,
		name,
		type,
		id,
		message buffer pointer,
		SOA record pointer
  returns:	nothing

* write_stats($sfile,$cp,$sinit);

Write out the contents of the accumulated statistics buffer to the STATs file.

  input:	statistics file path,
		pointer to count hash,
		initial timestamp line text
  returns:	nothing

* $rv = bystat($cp);

Return sort value +-1 or 0 for stat sort

  input:	$a,$b sort values
		pointer to count hash
  returns:	sort decision value

* $timestamp = statinit($Sfile,$cp);

Initialize the contents of the statistics hash with the file contents of $Sfile, if $Sfile exists and there are corresponding entries in the statistics hash. i.e. the statistics hash keys must first be initialized with the DNSBL (or LABEL) names.

  input:	statistics file path,
		pointer to count hash
  returns:	timestamp line for file
		or undef on failure

* cntinit($DNSBL,$cp);

Initialize the statistics count hash with DNSBL keys and set the counts to zero.

For compatibility with other applications, LABEL names other than the DNSBL's must NOT contain '.' Only the keys in the DNSBL hash that contain '.'s are added to the count hash.

The count hash is first emptied if it is not null to begin with.

  input:	pointer to DNSBL hash,
		pointer to counts hash
  returns:	nothing

* list2hash(\@list,$cp,$val);

Add a list of names as keys to the statistics count hash and set the hash value to $val or zero if $val is not present.

For compatibility with other applications, the labels in "list" must not contain the character '.'

  input:	pointer to list of labels,
		pointer to counts hash,
		value [optional]
  returns:	nothing

* $rv = DO($file,$nowarnings);

This is a fancy 'do file'. It first checks that the file exists and is readable, then does a 'do file' to pull the variables and subroutines into the current name space.

See the documentation File::SafeDO

  input:	file/path/name
  returns:	last value in file
	    or	undef on error
	    prints warning

* $rv = DO($file,$nowarnings);

This is a fancy 'do file'. It first checks that the file exists and is readable, then does a 'do file' to pull the variables and subroutines into the current name space.

See the documentation File::SafeDO

  input:	file/path/name
  returns:	last value in file
	    or	undef on error
	    prints warning

* $sock = open_udpNB();

Open and return a non-blocking UDP socket object

  input:	none
  returns:	pointer to socket object
		or undef on failure

* $rv=list2NetAddr(\@inlist,\@NAobject);

Build of NetAddr object structure from a list of IPv4 addresses or address ranges. This object is passed to matchNetAddr to check if a given IP address is contained in the list.

  input:	array reference pointer
		to a list of addresses

  i.e.		11.22.33.44
		11.22.33.0/24
		11.22.33.0/255.255.255.0
		11.22.33.20-11.22.33.46
		11.22.33.20 - 11.22.33.46

  output:	Number of objects created
		or undef on error

The NAobject array is filled with NetAddr::IP::Lite object references.

* $rv = matchNetAddr($ip,\@NAobject);

Check if an IP address appears in a list of NetAddr objects.

  input:	dot quad IP address,
		reference to NetAddr objects
  output:	true if match else false

* ($countries,$code3s,$names) = list_countries;

The function returns the list of 2 character, 3 character and country code names from the Geo::IP::PurePerl module if it is installed.

  input:	none
  returns:	\@countries,\@code3s,\@names
		blessed into callers namespace

NOTE: this process is very inefficient and should not be called in a repetitive fashion.

If Geo::IP::PurePerl is not installed, the function returns and empty array and sets $@;

* setAUTH(true/false);

Set the Authoratitive Answer bit true or false for all replys

  input:	true/false
  returns:	nothing

* setRA(true/false);

Set the Recursion Allowed bit true or false for all replys

  input:	true/false
  returns:	nothing

* $netaddr = A127x

Functions A1271, A1272, A1273, etc..., return the packed network address for 127.0.0.1, 127.0.0.2, etc.... respectively

DEPENDENCIES

Top

	Net::DNS::Codes
	Net::DNS::ToolKit

EXPORT_OK

Top

	s_response 
	not_found  
	write_stats
	bystat
	statinit
	cntinit
	list2hash
	open_udpNB
	DO
	list2NetAddr
	matchNetAddr
	list_countries
	setAUTH
	setRA
	A1271
	A1272
	A1273
	A1274
	A1275
	A1276
	A1277

AUTHOR

Top

Michael Robinton, michael@bizsystems.com

COPYRIGHT

Top

SEE ALSO

Top

Net::DNS::Codes, Net::DNS::ToolKit, Mail::SpamCannibal


Net-DNSBL-MultiDaemon documentation  | view source Contained in the Net-DNSBL-MultiDaemon distribution.