From: Andrew Ruthven Date: Mon, 9 Mar 2009 23:34:33 +0000 (+1300) Subject: Allow using a YAML file to provide the list of resolvers to use. X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=asterisk-agi-enum.git Allow using a YAML file to provide the list of resolvers to use. --- diff --git a/enum-agi.yml b/enum-agi.yml new file mode 100644 index 0000000..57fde02 --- /dev/null +++ b/enum-agi.yml @@ -0,0 +1,4 @@ +# A list of ENUM domains to search in. +resolvers: + - e164.org + - e164.arpa diff --git a/enum.agi b/enum.agi index 38e8cce..ac28bcf 100644 --- 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;