root/trunk/pdns/modules/pipebackend/backend.pl @ 1397

Revision 1397, 1.8 KB (checked in by ahu, 4 years ago)

add NS, SOA and TXT code to the example pipe backend

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to author date id revision
Line 
1#!/usr/bin/perl -w
2# sample PowerDNS Coprocess backend
3#
4
5use strict;
6
7
8$|=1;                                   # no buffering
9
10my $line=<>;
11chomp($line);
12
13unless($line eq "HELO\t1") {
14        print "FAIL\n";
15        print STDERR "Received '$line'\n";
16        <>;
17        exit;
18}
19print "OK       Sample backend firing up\n";    # print our banner
20
21while(<>)
22{
23        print STDERR "$$ Received: $_";
24        chomp();
25        my @arr=split(/\t/);
26        if(@arr<6) {
27                print "LOG      PowerDNS sent unparseable line\n";
28                print "FAIL\n";
29                next;
30        }
31
32        my ($type,$qname,$qclass,$qtype,$id,$ip)=split(/\t/);
33
34        if(($qtype eq "SOA" || $qtype eq "ANY") && $qname eq "example.com") {
35                print STDERR "$$ Sent SOA records\n";
36                print "DATA     $qname  $qclass SOA     3600    -1      ahu.example.com ns1.example.com 2008080300 1800 3600 604800 3600\n";
37        }
38        if(($qtype eq "NS" || $qtype eq "ANY") && $qname eq "example.com") {
39                print STDERR "$$ Sent NS records\n";
40                print "DATA     $qname  $qclass NS      3600    -1      ns1.example.com\n";
41                print "DATA     $qname  $qclass NS      3600    -1      ns2.example.com\n";
42        }
43        if(($qtype eq "TXT" || $qtype eq "ANY") && $qname eq "example.com") {
44                print STDERR "$$ Sent NS records\n";
45                print "DATA     $qname  $qclass TXT     3600    -1      \"hallo allemaal!\"\n";
46        }
47        if(($qtype eq "A" || $qtype eq "ANY") && $qname eq "webserver.example.com") {
48                print STDERR "$$ Sent A records\n";
49                print "DATA     $qname  $qclass A       3600    -1      1.2.3.4\n";
50                print "DATA     $qname  $qclass A       3600    -1      1.2.3.5\n";
51                print "DATA     $qname  $qclass A       3600    -1      1.2.3.6\n";
52        }
53        elsif(($qtype eq "CNAME" || $qtype eq "ANY") && $qname eq "www.example.com") {
54                print STDERR "$$ Sent CNAME records\n";
55                print "DATA     $qname  $qclass CNAME   3600    -1      webserver.example.com\n";
56        }
57        elsif($qtype eq "MBOXFW") {
58                print STDERR "$$ Sent MBOXFW records\n";
59                print "DATA     $qname  $qclass MBOXFW  3600    -1      powerdns\@example.com\n";
60        }
61
62
63        print STDERR "$$ End of data\n";
64        print "END\n";
65}
66
Note: See TracBrowser for help on using the browser.