summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/dialplan
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-11 02:34:11 -0400
committerPeter Kozak <spag@golwen.net>2013-03-11 02:34:11 -0400
commitdd5afe31149f7100c4a7fbce100b292b33e2c348 (patch)
tree09ed91a1d3809c3e008fbee08576962fb2fc0fa1 /misc/freeswitch/scripts/dialplan
parentf6a547f78186e109c6e12652d812604ebe094c2d (diff)
gateway authentication by username/password
Diffstat (limited to 'misc/freeswitch/scripts/dialplan')
-rw-r--r--misc/freeswitch/scripts/dialplan/dialplan.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua
index 4cc2245..6d75d8d 100644
--- a/misc/freeswitch/scripts/dialplan/dialplan.lua
+++ b/misc/freeswitch/scripts/dialplan/dialplan.lua
@@ -135,10 +135,22 @@ end
function Dialplan.auth_gateway(self)
require 'common.gateway'
local gateway_class = common.gateway.Gateway:new{ log = self.log, database = self.database};
- local gateway = gateway_class:authenticate(self.caller);
+
+ local gateway = false;
+
+ if self.caller:to_b('gs_from_gateway') then
+ gateway = {
+ 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);
+ 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, ', name: ', 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