summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/common
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-11 05:57:32 -0400
committerPeter Kozak <spag@golwen.net>2013-03-11 05:57:32 -0400
commit576471586e781ad1f7535e5931b1e41e25fad71b (patch)
tree488ef28a7d1bb539986e005fc36a02b95ebe8a68 /misc/freeswitch/scripts/common
parent46c987b67be71aa77f484929c7c7323d8c25b0c2 (diff)
dial_string setting added
Diffstat (limited to 'misc/freeswitch/scripts/common')
-rw-r--r--misc/freeswitch/scripts/common/gateway.lua39
1 files changed, 25 insertions, 14 deletions
diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua
index 14c19fb..e32a790 100644
--- a/misc/freeswitch/scripts/common/gateway.lua
+++ b/misc/freeswitch/scripts/common/gateway.lua
@@ -34,7 +34,7 @@ end
function Gateway.find_by_id(self, id)
- local sql_query = 'SELECT `a`.*, `c`.`sip_host` `domain` \
+ local sql_query = 'SELECT `a`.*, `c`.`sip_host` AS `domain`, `c`.`contact` AS `contact_full`, `c`.`network_ip`, `c`.`network_port` \
FROM `gateways` `a` \
LEFT JOIN `gateway_settings` `b` ON `a`.`id` = `b`.`gateway_id` AND `b`.`name` = "inbound_username" \
LEFT JOIN `sip_registrations` `c` ON `b`.`value` = `c`.`sip_user` \
@@ -50,6 +50,9 @@ function Gateway.find_by_id(self, id)
gateway.technology = entry.technology;
gateway.outbound = common.str.to_b(entry.outbound);
gateway.inbound = common.str.to_b(entry.inbound);
+ gateway.domain = entry.domain;
+ gateway.network_ip = entry.network_ip;
+ gateway.network_port = tonumber(entry.network_port) or 5060;
end)
if gateway then
@@ -63,7 +66,7 @@ end
function Gateway.find_by_name(self, name)
local gateway_name = name:gsub('([^%a%d%._%+])', '');
- local sql_query = 'SELECT `a`.*, `c`.`sip_host` `domain` \
+ local sql_query = 'SELECT `a`.*, `c`.`sip_host` `domain`, `c`.`contact` AS `contact_full`, `c`.`network_ip`, `c`.`network_port`\
FROM `gateways` `a` \
LEFT JOIN `gateway_settings` `b` ON `a`.`id` = `b`.`gateway_id` AND `b`.`name` = "inbound_username" \
LEFT JOIN `sip_registrations` `c` ON `b`.`value` = `c`.`sip_user` \
@@ -79,6 +82,9 @@ function Gateway.find_by_name(self, name)
gateway.technology = entry.technology;
gateway.outbound = common.str.to_b(entry.outbound);
gateway.inbound = common.str.to_b(entry.inbound);
+ gateway.domain = entry.domain;
+ gateway.network_ip = entry.network_ip;
+ gateway.network_port = tonumber(entry.network_port) or 5060;
end)
if gateway then
@@ -123,19 +129,24 @@ end
function Gateway.call_url(self, destination_number)
require 'common.str';
- if self.technology == 'sip' then
- if self.settings.inbound_username and self.settings.inbound_password and not common.str.blank(self.record.domain) then
- return 'sofia/' .. (self.settings.profile or 'gemeinschaft') .. '/' .. self.settings.inbound_username .. '%' .. self.record.domain;
- else
- return 'sofia/gateway/' .. self.GATEWAY_PREFIX .. self.id .. '/' .. tostring(destination_number);
- end
-
- elseif self.technology == 'xmpp' then
- local destination_str = tostring(destination_number);
- if self.settings.destination_domain then
- destination_str = destination_str .. '@' .. self.settings.destination_domain;
+ if common.str.blank(self.settings.dial_string) then
+ if self.technology == 'sip' then
+ if self.settings.inbound_username and self.settings.inbound_password and not common.str.blank(self.record.domain) then
+ return 'sofia/' .. (self.settings.profile or 'gemeinschaft') .. '/' .. self.settings.inbound_username .. '%' .. self.record.domain;
+ else
+ return 'sofia/gateway/' .. self.GATEWAY_PREFIX .. self.id .. '/' .. tostring(destination_number);
+ end
+
+ elseif self.technology == 'xmpp' then
+ local destination_str = tostring(destination_number);
+ if self.settings.destination_domain then
+ destination_str = destination_str .. '@' .. self.settings.destination_domain;
+ end
+ return 'dingaling/' .. self.GATEWAY_PREFIX .. self.id .. '/' .. destination_str;
end
- return 'dingaling/' .. self.GATEWAY_PREFIX .. self.id .. '/' .. destination_str;
+ else
+ require 'common.array';
+ return tostring(common.array.expand_variables(self.settings.dial_string, self, { destination_number = destination_number }));
end
return '';