/[pxelator]/lib/PXElator/dnsd.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/dnsd.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 210 by dpavlin, Wed Aug 12 22:56:45 2009 UTC revision 211 by dpavlin, Thu Aug 13 12:00:51 2009 UTC
# Line 46  sub reply_handler { Line 46  sub reply_handler {
46    
47          my $ttl = 3600;          my $ttl = 3600;
48    
49            my $audit = { source => 'unknown' };
50    
51          if ( $local ) {          if ( $local ) {
52                  warn "local[$local] $qname $qtype";                  warn "local[$local] $qname $qtype";
53                  $rcode = "NOERROR";                  $rcode = "NOERROR";
54                  my $rdata;                  my $rdata;
55                  if ( $qtype eq "A" && $local eq "server" ) {                  if ( $qtype eq "A" && $local eq "server" ) {
56                          $rdata = name_ip( $local, $server::ip );                          $rdata = name_ip( $local, $server::ip );
57                          CouchDB::audit('local', $rdata);                          $audit->{source} = 'local';
58                  } else {                  } else {
59                          $rcode = "NXDOMAIN";                          $rcode = "NXDOMAIN";
60                  }                  }
# Line 63  sub reply_handler { Line 65  sub reply_handler {
65                          if ( my $rdata = $ptr_cache->{$1} ) {                          if ( my $rdata = $ptr_cache->{$1} ) {
66                                  $rdata .= '.' . $server::domain_name;                                  $rdata .= '.' . $server::domain_name;
67                                  push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");                                  push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
68                                  CouchDB::audit('ptr', $rdata );                                  $audit->{source} = 'PTR';
69                          } else {                          } else {
70  warn "## ",dump( $ptr_cache );  warn "## ",dump( $ptr_cache );
71                                  $rcode = "NXDOMAIN";                                  $rcode = "NXDOMAIN";
72                          }                          }
73          } elsif ( my $packet = $res->query( $qname, $qtype ) ) {          } elsif ( my $packet = $res->query( $qname, $qtype ) ) {
74    
75                  CouchDB::audit( 'upstream', $packet );                  $audit->{source} = 'upstream';
76                  $packet->print;                  $packet->print;
77                  push @ans, $_ foreach $packet->answer;                  push @ans, $_ foreach $packet->answer;
78                  $rcode = "NOERROR";                  $rcode = "NOERROR";
# Line 82  warn "## ",dump( $ptr_cache ); Line 84  warn "## ",dump( $ptr_cache );
84    
85          warn "rcode: $rcode ",dump( @ans );          warn "rcode: $rcode ",dump( @ans );
86    
87          CouchDB::audit('response', { rcode => $rcode, ans => [ @ans ], auth => [ @auth ], add => [ @add ] });          $audit->{rcode} = $rcode;
88            $audit->{ans} = [ @ans ];
89    
90            CouchDB::audit( 'response', $audit );
91    
92          # mark the answer as authoritive (by setting the 'aa' flag          # mark the answer as authoritive (by setting the 'aa' flag
93          return ($rcode, \@ans, \@auth, \@add, { aa => 1 });          return ($rcode, \@ans, \@auth, \@add, { aa => 1 });

Legend:
Removed from v.210  
changed lines
  Added in v.211

  ViewVC Help
Powered by ViewVC 1.1.26