From 59fddbdd5e07b7e9aa39d4504b0c1f02a3f6d031 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 4 Jul 2013 13:33:03 +0200 Subject: authenticate by previous_destination (transfer) --- misc/freeswitch/scripts/dialplan/dialplan.lua | 12 +++++++----- misc/freeswitch/scripts/dialplan_default.lua | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 913d7a5..7473a33 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -124,16 +124,18 @@ function Dialplan.auth_node(self) end -function Dialplan.auth_sip_account(self) +function Dialplan.auth_account(self) if not common.str.blank(self.caller.auth_account_type) then - self.log:info('AUTH_SIP_ACCOUNT - ', self.caller.auth_account_type, '=', self.caller.account_id, '/', self.caller.account_uuid); + self.log:info('AUTH auth_account - ', self.caller.auth_account_type, '=', self.caller.account_id, '/', self.caller.account_uuid); return true; + elseif not common.str.blank(self.caller.previous_destination_type) and not common.str.blank(self.caller.previous_destination_uuid) then + self.log:info('AUTH previous_destination - ', self.caller.previous_destination_type, '=', self.caller.previous_destination_id, '/', self.caller.previous_destination_uuid); end end function Dialplan.auth_gateway(self) - require 'common.gateway' + require 'common.gateway'; local gateway_class = common.gateway.Gateway:new{ log = self.log, database = self.database}; local gateway = false; @@ -143,14 +145,14 @@ function Dialplan.auth_gateway(self) name = self.caller:to_s('gs_gateway_name'), id = self.caller:to_i('gs_gateway_id'), } - log:info('AUTH_GATEWAY - authenticaded by password and username: ', self.caller:to_s('username'), ', gateway=', gateway.id, '|', gateway.name, ', ip: ', self.caller.sip_contact_host); + log:info('AUTH gateway - authenticaded by password and username: ', self.caller:to_s('username'), ', gateway=', gateway.id, '|', gateway.name, ', ip: ', self.caller.sip_contact_host); return gateway_class:find_by_id(gateway.id); else gateway = gateway_class:authenticate(self.caller); end if gateway then - log:info('AUTH_GATEWAY - ', gateway.auth_source, ' ~ ', gateway.auth_pattern, ', gateway=', gateway.id, '|', gateway.name, ', ip: ', self.caller.sip_contact_host); + log:info('AUTH gateway - ', gateway.auth_source, ' ~ ', gateway.auth_pattern, ', gateway=', gateway.id, '|', gateway.name, ', ip: ', self.caller.sip_contact_host); return gateway_class:find_by_id(gateway.id); end end diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index 32789cb..eeeb5c2 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -74,7 +74,7 @@ if start_caller.from_node and not start_dialplan:auth_node() then log:debug('DIALPLAN_DEFAULT - node unauthorized - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain); start_dialplan:hangup(401, start_dialplan.domain); else - if not start_dialplan:auth_sip_account() then + if not start_dialplan:auth_account() then local gateway = start_dialplan:auth_gateway() if gateway then -- cgit v1.2.3