]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7726 puppet xml curl handler
authorBrian West <brian@freeswitch.org>
Tue, 30 Jun 2015 23:27:19 +0000 (18:27 -0500)
committerBrian West <brian@freeswitch.org>
Tue, 30 Jun 2015 23:27:19 +0000 (18:27 -0500)
scripts/perl/puppet.cgi [new file with mode: 0755]

diff --git a/scripts/perl/puppet.cgi b/scripts/perl/puppet.cgi
new file mode 100755 (executable)
index 0000000..cba8cf3
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+#
+# Used for testing, This will allow you to configure a
+# dialplan on a remote system for testing via X headers
+# in a SIP invite.  DO NOT RUN IN PRODUCTION LIKE THIS.
+#
+# YOU'VE BEEN WARNED!
+#
+
+use CGI;
+use XML::Writer;
+use IO::File;
+use Data::Dumper;
+
+my $q = CGI->new;
+my $output = IO::File->new(*STDOUT);
+my $writer = XML::Writer->new(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT => 2);
+
+my $params = $q->Vars;
+print $q->header('text/xml');
+$writer->xmlDecl("UTF-8");
+
+$writer->startTag("document", "type" => "freeswitch/xml");
+
+if($params->{'Hunt-Destination-Number'} eq 'puppet') {
+    $writer->startTag("section",  "name" => "dialplan");
+    $writer->startTag("context",  "name" => "$params->{'Hunt-Context'}");
+    $writer->startTag("extension", "name" => "puppet");
+    $writer->startTag("condition");
+    my $count = 1;
+    while (exists $params->{"variable_sip_h_X-DP-$count"}) {
+       my ($app, $arg) = split(/:/, $params->{"variable_sip_h_X-DP-$count"});
+       if($arg) {
+           $writer->emptyTag("action", "application"  => "$app", "data" => "$arg");
+       } else {
+           $writer->emptyTag("action", "application"  => "$app");
+       }
+       $count++;
+    }
+    $writer->endTag("condition");
+    $writer->endTag("extension");
+    $writer->endTag("context");
+} else {
+    $writer->startTag("section",  "name" => "result");
+    $writer->emptyTag("result", "status"  => "not found");
+}
+$writer->endTag("section");
+$writer->endTag("document");
+$writer->end();