diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-18 15:10:16 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-18 15:10:16 +0100 |
commit | fa4ff4d2e603dae76ac033a16a524e5378d3d48f (patch) | |
tree | ca13e8c32ced662cec93c8ea6efa3d7197e3edc9 /misc/freeswitch/scripts/common/gateway.lua | |
parent | e7f51187fe563c559c5580e5091f01356a36b6c3 (diff) | |
parent | c4c3ce49a9f1a229df30c88f0f8a24f06acc4d0f (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.lua | 21 |
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` \ |