]> git.etc.gen.nz Git - asterisk-agi-enum.git/commitdiff
Allow using a YAML file to provide the list of resolvers to use. master
authorAndrew Ruthven <andrew@etc.gen.nz>
Mon, 9 Mar 2009 23:34:33 +0000 (12:34 +1300)
committerAndrew Ruthven <andrew@cerberus.etc.gen.nz>
Mon, 9 Mar 2009 23:38:45 +0000 (12:38 +1300)
enum-agi.yml [new file with mode: 0644]
enum.agi

diff --git a/enum-agi.yml b/enum-agi.yml
new file mode 100644 (file)
index 0000000..57fde02
--- /dev/null
@@ -0,0 +1,4 @@
+# A list of ENUM domains to search in.
+resolvers:
+ - e164.org
+ - e164.arpa
index 38e8cced4ae6e4d0b59533da2bc6c176b87de99f..ac28bcf9764ca623a532d1a3a3e4542c1cb1058e 100644 (file)
--- a/enum.agi
+++ b/enum.agi
@@ -16,12 +16,26 @@ use warnings;
 
 use Net::DNS;
 use Asterisk::AGI;
+use YAML::Syck qw/LoadFile/;
 
 my ( @resolvers, $A, %AGI, $num, $resources );
 
-# in order of preference
+# in order of preference - default.  Can be over ridden using
+# /etc/asterisk/enum-agi.yml .
 @resolvers = qw/ e164.org e164.arpa /;
 
+my $config_file = "/etc/asterisk/enum-agi.yml";
+if (-f $config_file) {
+  my $config = eval { LoadFile $config_file };
+  if ($@) {
+    die "Failed to load config file: $config_file, error: $@";
+  }
+
+  if (defined $config->{'resolvers'} && scalar(@{ $config->{'resolvers'} })) {
+    @resolvers = @{ $config->{'resolvers'} };
+  }
+}
+
 # setup AGI environment
 $A   = Asterisk::AGI->new();
 %AGI = $A->ReadParse;