From 8af64d9ad708b4c051142a0589096c66bd451ab5 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Tue, 10 Mar 2009 12:34:33 +1300 Subject: [PATCH] Allow using a YAML file to provide the list of resolvers to use. --- enum-agi.yml | 4 ++++ enum.agi | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 enum-agi.yml 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 100755 --- 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; -- 2.30.2