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

Revision 546, 1.1 KB (checked in by ahu, 8 years ago)

Pipebackend did not properly propagate pipebackend-abi-version. This closes #45 by 'kickdaddy@…'

  • 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 "A" || $qtype eq "ANY") && $qname eq "webserver.example.com") {
35                print STDERR "$$ Sent A records\n";
36                print "DATA     $qname  $qclass A       3600    -1      1.2.3.4\n";
37                print "DATA     $qname  $qclass A       3600    -1      1.2.3.5\n";
38                print "DATA     $qname  $qclass A       3600    -1      1.2.3.6\n";
39        }
40        elsif(($qtype eq "CNAME" || $qtype eq "ANY") && $qname eq "www.example.com") {
41                print STDERR "$$ Sent CNAME records\n";
42                print "DATA     $qname  $qclass CNAME   3600    -1      webserver.example.com\n";
43        }
44        elsif($qtype eq "MBOXFW") {
45                print STDERR "$$ Sent MBOXFW records\n";
46                print "DATA     $qname  $qclass MBOXFW  3600    -1      powerdns\@example.com\n";
47        }
48
49
50        print STDERR "$$ End of data\n";
51        print "END\n";
52}
53
Note: See TracBrowser for help on using the browser.