summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/dialplan_default.lua
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-01-15 12:30:29 +0100
committerspag <spag@golwen.net>2013-01-15 12:30:29 +0100
commitb713c19f0a7727a14b5ea4d72f8ddaaf01736027 (patch)
tree3c5278d17fdff5ad2d9ebd50ed87e48ba463d524 /misc/freeswitch/scripts/dialplan_default.lua
parent4ce6146b0883fd9f7557d6ccf118a4dac7adbbe9 (diff)
tweaking authentication
Diffstat (limited to 'misc/freeswitch/scripts/dialplan_default.lua')
-rw-r--r--misc/freeswitch/scripts/dialplan_default.lua29
1 files changed, 23 insertions, 6 deletions
diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua
index 1c0a52e..42271b9 100644
--- a/misc/freeswitch/scripts/dialplan_default.lua
+++ b/misc/freeswitch/scripts/dialplan_default.lua
@@ -34,20 +34,37 @@ end
-- dialplan object
require 'dialplan.dialplan'
-start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller, database = database };
+local start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller, database = database };
start_dialplan:configuration_read();
start_caller.local_node_id = start_dialplan.node_id;
start_caller:init_channel_variables();
-- session:execute('info','notice');
-if not start_dialplan:check_auth() then
- log:debug('AUTHENTICATION_REQUIRED - host: ' , start_caller.sip_contact_host, ', domain: ', start_dialplan.domain);
- start_dialplan:hangup(407, start_dialplan.domain);
- return false;
+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
+ local gateway = start_dialplan:auth_gateway()
+
+ if gateway then
+ start_caller.gateway_name = gateway.name;
+ start_caller.gateway_id = gateway.id;
+ start_caller.from_gateway = true;
+ start_caller.gateway = gateway;
+ else
+ log:debug('AUTHENTICATION_REQUIRED_SIP_ACCOUNT - contact host: ' , start_caller.sip_contact_host, ', ip: ', start_caller.sip_network_ip, ', domain: ', start_dialplan.domain);
+ start_dialplan:hangup(407, start_dialplan.domain);
+ if database then
+ database:release();
+ end
+ return;
+ end
+ end
end
-if start_caller.from_node and not start_dialplan:check_auth_node() then
+if start_caller.from_node then
log:debug('AUTHENTICATION_REQUIRED_NODE - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain);
start_dialplan:hangup(407, start_dialplan.domain);
else