API-DirectAdmin

 view release on metacpan or  search on metacpan

lib/API/DirectAdmin/DNS.pm  view on Meta::CPAN

			   nsrecs0 
			   cnamerecs0 
			   srvrecs0 
			   ptrrecs0',
    );
}

# Special parser for zone dump
# Cropped code from Parse::DNS::Zone
sub _parse_zone {
    my ($zonetext, $origin) = @_;
    
    my $mrow;
    my $prev;
    my %zone;

    my $zentry = qr/^
	    (\S+)\s+ # name
	    (
		    (?: (?: IN | CH | HS ) \s+ \d+ \s+ ) |
		    (?: \d+ \s+ (?: IN | CH | HS ) \s+ ) |

lib/API/DirectAdmin/DNS.pm  view on Meta::CPAN

	    (.*) # rdata
    $/ix;

    foreach ( split /\n+/, $zonetext ) {

	    chomp;
	    s/;.*$//;
	    next if /^\s*$/;
	    s/\s+/ /g;
	    
	    s/^\@ /$origin /g;
	    s/ \@ / $origin /g;
	    s/ \@$/ $origin/g;

	    # handles mutlirow entries, with ()
	    if($mrow) {
		    $mrow.=$_;
		    
		    next if(! /\)/); 

		    # End of multirow 
		    $mrow=~s/[\(\)]//g;
		    $mrow=~s/\n//mg;

lib/API/DirectAdmin/DNS.pm  view on Meta::CPAN

	    } elsif(/^.*\([^\)]*$/) {
		    # Start of multirow
		    $mrow.=$_;
		    next;
	    }

	    if(/^ /) {
		    s/^/$prev/;
	    }

	    $origin = $1, next if(/^\$ORIGIN ([\w\-\.]+)\s*$/i);

	    my($name,$ttlclass,$type,$rdata) = /$zentry/;

	    my($ttl, $class);
	    if(defined $ttlclass) {
		    ($ttl) = $ttlclass=~/(\d+)/o;
		    ($class) = $ttlclass=~/(CH|IN|HS)/io;

		    $ttlclass=~s/\d+//;
		    $ttlclass=~s/(?:CH|IN|HS)//;

lib/API/DirectAdmin/DNS.pm  view on Meta::CPAN

		    if($ttlclass) {
			    next;
		    }
	    }

	    $ttl = defined $ttl ? $ttl : 14400;

	    next if (!$name || !$type || !$rdata);

	    $prev=$name;
	    $name.=".$origin" if $name ne $origin && $name !~ /\.$/;

	    if($type =~ /^(?:cname|afsdb|mx|ns)$/i and 
	       $rdata ne $origin and $rdata !~ /\.$/) {
		    $rdata.=".$origin";
	    }

	    push(@{$zone{lc $name}{lc $type}{rdata}}, $rdata);
	    push(@{$zone{lc $name}{lc $type}{ttl}}, $ttl);
	    push(@{$zone{lc $name}{lc $type}{class}}, $class);
    }

    return \%zone;
}



( run in 0.329 second using v1.01-cache-2.11-cpan-f985c23238c )