diff options
author | spag <spag@golwen.net> | 2013-01-14 17:16:38 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-01-14 17:16:38 +0100 |
commit | 9292aa909881b7f21192f9278b8ce5eb8fe442de (patch) | |
tree | 478b93c0f3cd1175ea10a12a9164daa095ea621f /misc/freeswitch/scripts | |
parent | e0064941bc73303e83f1fbd9374c3a731b1d3c0b (diff) |
allow header based authentication
Diffstat (limited to 'misc/freeswitch/scripts')
-rw-r--r-- | misc/freeswitch/scripts/dialplan/dialplan.lua | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 07b8f4f..aa6b8c8 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -127,17 +127,15 @@ function Dialplan.check_auth(self) self.log:info('AUTH_FIRST_STAGE - gateway autheticated by name/password: gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name); authenticated = true; else - local gateways = common.configuration_file.get('/opt/freeswitch/scripts/ini/gateways.ini', false); - if not gateways then - return false; - end - for gateway, gateway_parameters in pairs(gateways) do - if common.str.to_s(gateway_parameters.proxy) == self.caller.sip_contact_host then - self.caller.gateway_name = gateway; - self.caller.from_gateway = true; - self.log:info('AUTH_FIRST_STAGE - gateway autheticated by ip: gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name, ', ip: ', self.caller.sip_contact_host); - authenticated = true; - end + require 'common.gateway' + local gateway = common.gateway.Gateway:new{ log = self.log, database = self.database}:authenticate('sip', self.caller); + + if gateway then + self.caller.gateway_name = gateway.name; + self.caller.gateway_id = gateway.id; + self.caller.from_gateway = true; + self.log:info('AUTH_FIRST_STAGE - gateway autheticated by ip: gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name, ', ip: ', self.caller.sip_contact_host); + authenticated = true; end end @@ -876,6 +874,10 @@ function Dialplan.run(self, destination) end end + require 'dialplan.router' + local router = dialplan.router.Router:new{ log = self.log, database = self.database }; + router:table_load(); + self.routes = common.configuration_file.get('/opt/freeswitch/scripts/ini/routes.ini'); self.caller.domain_local = self.domain; self:retrieve_caller_data(); |