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 38e8cce..ac28bcf 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;