forked from PowerDNS/pdns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add testbench script for remotebackend development, thanks Aki. Closes …
…PowerDNS#742 git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3171 d19b8d6e-7fed-0310-83ef-9ca221ded41b
- Loading branch information
Peter van Dijk
committed
Apr 22, 2013
1 parent
a8e2afd
commit 62b38b0
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/perl | ||
### This script is intended for testing/developing remotebackend scripts | ||
### To use, please install libjson-any-perl (JSON::Any) and libjson-xs-perl (JSON::XS) | ||
### (c) Aki Tuomi 2013 - Distributed under same license as PowerDNS Authoritative Server | ||
use strict; | ||
use warnings; | ||
use 5.005; | ||
use IPC::Open2; | ||
use JSON::Any; | ||
|
||
### CONFIGURATION SECTION | ||
|
||
## Full path to your remotebackend script | ||
my $script = "/home/cmouse/projects/pdns-v6-autorev/rev.pl"; | ||
|
||
## These are used to send initialize method before your actual code | ||
my $initparams = { value => "foo", value2 => "bar" }; | ||
|
||
## END CONFIGURATION | ||
|
||
$|=1; | ||
my $in; | ||
my $out; | ||
my $pid = open2($in,$out,$script); | ||
|
||
my $j = JSON::Any->new; | ||
|
||
sub rpc { | ||
my $meth = shift; | ||
my %p = @_; | ||
|
||
print $j->encode({method => $meth, parameters => \%p}),"\r\n"; | ||
print $out $j->encode({method => $meth, parameters => \%p}),"\r\n"; | ||
my $res = <$in>; | ||
if ($res) { | ||
chomp $res; | ||
print $res,"\n"; | ||
} | ||
} | ||
|
||
rpc 'initialize', %$initparams; | ||
|
||
if (@ARGV>1) { | ||
|
||
## this lets you call whatever method with simple parameters | ||
## like this: | ||
|
||
# perl remotebackend-pipe-test.pl lookup qtype SOA qname powerdns.com | ||
|
||
## this will execute | ||
## {"parameters":{"qname":"powerdns.com","qtype":"SOA"},"method":"lookup"} | ||
## on your remotebackend | ||
|
||
my $meth = shift; | ||
rpc $meth, @ARGV; | ||
|
||
|
||
} else { | ||
|
||
## Put whatever you want to run here. Or leave it empty if you | ||
## only want to use the command line | ||
|
||
#rpc 'lookup', qname => 'powerdns.com', qtype => 'SOA'; | ||
|
||
} |