]> git.ipfire.org Git - thirdparty/pdns.git/blob - modules/pipebackend/backend-v3.pl
Check if -latomic is needed instead of hardcoding
[thirdparty/pdns.git] / modules / pipebackend / backend-v3.pl
1 #!/usr/bin/perl -w
2 # sample PowerDNS Coprocess backend with edns-client-subnet support
3 #
4
5 use strict;
6
7
8 $|=1; # no buffering
9
10 my $line=<>;
11 chomp($line);
12
13 unless($line eq "HELO\t3" ) {
14 print "FAIL\n";
15 print STDERR "Received unexpected '$line', wrong ABI version?\n";
16 <>;
17 exit;
18 }
19 print "OK Sample backend firing up\n"; # print our banner
20
21 while(<>)
22 {
23 print STDERR "$$ Received: $_";
24 chomp();
25 my @arr=split(/\t/);
26 if(@arr < 8) {
27 print "LOG PowerDNS sent unparseable line\n";
28 print "FAIL\n";
29 next;
30 }
31
32 my ($type,$qname,$qclass,$qtype,$id,$ip,$localip,$ednsip)=split(/\t/);
33 my $bits=21;
34 my $auth = 1;
35
36 if(($qtype eq "SOA" || $qtype eq "ANY") && $qname eq "example.com") {
37 print STDERR "$$ Sent SOA records\n";
38 print "DATA $bits $auth $qname $qclass SOA 3600 -1 ahu.example.com ns1.example.com 2008080300 1800 3600 604800 3600\n";
39 }
40 if(($qtype eq "NS" || $qtype eq "ANY") && $qname eq "example.com") {
41 print STDERR "$$ Sent NS records\n";
42 print "DATA $bits $auth $qname $qclass NS 3600 -1 ns1.example.com\n";
43 print "DATA $bits $auth $qname $qclass NS 3600 -1 ns2.example.com\n";
44 }
45 if(($qtype eq "TXT" || $qtype eq "ANY") && $qname eq "example.com") {
46 print STDERR "$$ Sent TXT records\n";
47 print "DATA $bits $auth $qname $qclass TXT 3600 -1 \"hallo allemaal!\"\n";
48 }
49 if(($qtype eq "A" || $qtype eq "ANY") && $qname eq "webserver.example.com") {
50 print STDERR "$$ Sent A records\n";
51 print "DATA $bits $auth $qname $qclass A 3600 -1 1.2.3.4\n";
52 print "DATA $bits $auth $qname $qclass A 3600 -1 1.2.3.5\n";
53 print "DATA $bits $auth $qname $qclass A 3600 -1 1.2.3.6\n";
54 }
55 if(($qtype eq "CNAME" || $qtype eq "ANY") && $qname eq "www.example.com") {
56 print STDERR "$$ Sent CNAME records\n";
57 print "DATA $bits $auth $qname $qclass CNAME 3600 -1 webserver.example.com\n";
58 }
59 if(($qtype eq "MX" || $qtype eq "ANY") && $qname eq "example.com") {
60 print STDERR "$$ Sent MX records\n";
61 print "DATA $bits $auth $qname $qclass MX 3600 -1 25 smtp.powerdns.com\n";
62 }
63
64
65 print STDERR "$$ End of data\n";
66 print "END\n";
67 }
68