The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::DNS::Method::Regexp - Build answers based on regular expressions

SYNOPSIS

  use Net::DNS::Method::Regexp;

  my $ans = new Net::DNS::Method::Regexp {
      /^www.test.com\.? IN A$/ => {
          answer => [ Net::DNS::RR->new("www.test.com. 10 IN A 192.168.0.1"),
                      Net::DNS::RR->new("www.test.com. 10 IN A 192.168.0.2") ],
          authority => [],
          additional => [],
          question => [],
          code => 'NOERROR',
          ra => 1,
          rd => 1,
          aa => 1,
          tc => 1,
          return => NS_OK | NS_STOP
      }
  }

DESCRIPTION

This module provides a simple but powerful DNS answer generator based in the idea of matching a DNS question with a regular expression and building the answer using the supplied rules.

Its ->new() method receives as its only parameter, a reference to a hash whose keys are regular expressions that must match the question section of a DNS packet. The value associated with these keys is a hash with the following possible pair - value entries:

answer, authority, additional and question

The value stored on these keys is a reference to a list of Net::DNS::RR objects that will be safe_push()ed into the corresponding sections of the answer. This requires a fairly recent version of Net::DNS.

ra, rd, aa, tc

Specify a value for the corresponding call in the answer packet, setting the corresponding bit to the specified value. For instance, an authoritative answer should specify aa = 1>.

code

Sets the answer's return code to the specified value. If left unspecified, the fault value of 'NOERROR' will be used.

return

Specifies the return value at the Net::DNS::Method level. This can be used to allow further classes to attempt a match on the packet, abort the search, skip the answer altogether, etc.

If this is omitted, the default value of NS_OK | NS_STOP will be returning, causing the answer to be returned immediately.

Note that the regular expression match will always be attempted with extended syntax (ie, spaces are meaningless) and case sensitivity turned off. Also, matches are attempted from the longest regular expression to the shortest, allowing for a trivial "priority" mechanism to be used. You can simply add whitespace to your regular expression to have it execute before a shorter regular expression.

HISTORY

1.00

Original version; created by h2xs 1.20 with options

  -ACOXfn
        Net::DNS::Method::Regexp
        -v
        1.00
2.00

Repackaged for public distribution.

AUTHOR

Luis E. Munoz <luismunoz@cpan.org>

SEE ALSO

perl(1), Net::DNS::Method(3), Net::DNS(3), Net::DNS::RR(3).

1 POD Error

The following errors were encountered while parsing the POD:

Around line 197:

You forgot a '=back' before '=head1'