summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/common/gateway.lua
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-18 15:10:16 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-18 15:10:16 +0100
commitfa4ff4d2e603dae76ac033a16a524e5378d3d48f (patch)
treeca13e8c32ced662cec93c8ea6efa3d7197e3edc9 /misc/freeswitch/scripts/common/gateway.lua
parente7f51187fe563c559c5580e5091f01356a36b6c3 (diff)
parentc4c3ce49a9f1a229df30c88f0f8a24f06acc4d0f (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'misc/freeswitch/scripts/common/gateway.lua')
-rw-r--r--misc/freeswitch/scripts/common/gateway.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua
index 5c76aba..e50c763 100644
--- a/misc/freeswitch/scripts/common/gateway.lua
+++ b/misc/freeswitch/scripts/common/gateway.lua
@@ -52,6 +52,27 @@ function Gateway.find_by_id(self, id)
end
+function Gateway.find_by_name(self, name)
+ local gateway_name = name:gsub('([^%a%d%._%+])', '');
+
+ local sql_query = 'SELECT * FROM `gateways` WHERE `name`= "' .. gateway_name .. '" LIMIT 1';
+
+ local gateway = nil;
+ self.database:query(sql_query, function(entry)
+ gateway = Gateway:new(self);
+ gateway.record = entry;
+ gateway.id = tonumber(entry.id);
+ gateway.name = entry.name;
+ end)
+
+ if gateway then
+ gateway.settings = self:config_table_get('gateway_settings', gateway.id);
+ end
+
+ return gateway;
+end
+
+
function Gateway.authenticate(self, technology, caller)
local sql_query = 'SELECT `c`.`name`, `c`.`id`, `a`.`value` `auth_source`, `b`.`value` `auth_pattern` \
FROM `gateway_settings` `a` \