summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'misc/freeswitch/scripts')
-rw-r--r--misc/freeswitch/scripts/common/gateway.lua102
-rw-r--r--misc/freeswitch/scripts/common/str.lua4
-rw-r--r--misc/freeswitch/scripts/configuration.lua69
-rw-r--r--misc/freeswitch/scripts/dialplan/dialplan.lua3
-rw-r--r--misc/freeswitch/scripts/dialplan/fax.lua7
-rw-r--r--misc/freeswitch/scripts/dialplan/router.lua26
-rw-r--r--misc/freeswitch/scripts/dialplan/sip_call.lua47
-rw-r--r--misc/freeswitch/scripts/dialplan/voicemail.lua12
-rw-r--r--misc/freeswitch/scripts/event_manager.lua2
-rw-r--r--misc/freeswitch/scripts/fax_daemon.lua2
-rw-r--r--misc/freeswitch/scripts/http_request.lua31
-rw-r--r--misc/freeswitch/scripts/phones/phone.lua9
-rw-r--r--misc/freeswitch/scripts/phones/snom.lua11
-rw-r--r--misc/freeswitch/scripts/send_fax.lua2
14 files changed, 244 insertions, 83 deletions
diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua
index e50c763..c1b50a7 100644
--- a/misc/freeswitch/scripts/common/gateway.lua
+++ b/misc/freeswitch/scripts/common/gateway.lua
@@ -38,10 +38,14 @@ function Gateway.find_by_id(self, id)
local gateway = nil;
self.database:query(sql_query, function(entry)
+ require 'common.str';
gateway = Gateway:new(self);
gateway.record = entry;
gateway.id = tonumber(entry.id);
gateway.name = entry.name;
+ gateway.technology = entry.technology;
+ gateway.outbound = common.str.to_b(entry.outbound);
+ gateway.inbound = common.str.to_b(entry.inbound);
end)
if gateway then
@@ -59,10 +63,14 @@ function Gateway.find_by_name(self, name)
local gateway = nil;
self.database:query(sql_query, function(entry)
+ require 'common.str';
gateway = Gateway:new(self);
gateway.record = entry;
gateway.id = tonumber(entry.id);
gateway.name = entry.name;
+ gateway.technology = entry.technology;
+ gateway.outbound = common.str.to_b(entry.outbound);
+ gateway.inbound = common.str.to_b(entry.inbound);
end)
if gateway then
@@ -73,14 +81,33 @@ function Gateway.find_by_name(self, name)
end
-function Gateway.authenticate(self, technology, caller)
+function Gateway.call_url(self, destination_number)
+ if self.technology == 'sip' then
+ return 'sofia/gateway/' .. self.GATEWAY_PREFIX .. self.id .. '/' .. tostring(destination_number);
+ 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 '';
+end
+
+
+function Gateway.authenticate(self, caller, technology)
local sql_query = 'SELECT `c`.`name`, `c`.`id`, `a`.`value` `auth_source`, `b`.`value` `auth_pattern` \
FROM `gateway_settings` `a` \
INNER JOIN `gateway_settings` `b` \
ON (`a`.`gateway_id` = `b`.`gateway_id` AND `a`.`name` = "auth_source" AND `b`.`name` = "auth_pattern" ) \
LEFT JOIN `gateways` `c` \
ON (`a`.`gateway_id` = `c`.`id`) \
- WHERE `c`.`inbound` IS TRUE AND `c`.`technology` = "' .. tostring(technology) .. '"';
+ WHERE `c`.`inbound` IS TRUE';
+
+ if technology then
+ sql_query = sql_query .. ' AND `c`.`technology` = "' .. tostring(technology) .. '"';
+ end
local gateway = false;
@@ -125,39 +152,58 @@ function Gateway.config_table_get(self, config_table, gateway_id)
end
-function Gateway.parameters_build(self, gateway_id)
+function Gateway.parameters_build(self, gateway_id, technology)
local settings = self:config_table_get('gateway_settings', gateway_id);
- local parameters = {
- realm = settings.domain,
- extension = 'auto_to_user',
- };
require 'common.str'
+ local parameters = {};
+
+ if technology == 'sip' then
+ parameters.realm = settings.domain;
+ parameters.extension = 'auto_to_user';
+
+ if common.str.blank(settings.username) then
+ parameters.username = 'gateway' .. gateway_id;
+ parameters.register = false;
+ else
+ parameters.username = settings.username;
+ parameters.register = true;
+ end
- if common.str.blank(settings.username) then
- parameters.username = 'gateway' .. gateway_id;
- parameters.register = false;
- else
- parameters.username = settings.username;
- parameters.register = true;
- end
-
- if not common.str.blank(settings.register) then
- parameters.register = common.str.to_b(settings.register);
- end
+ if not common.str.blank(settings.register) then
+ parameters.register = common.str.to_b(settings.register);
+ end
- if common.str.blank(settings.password) then
- parameters.password = 'gateway' .. gateway_id;
- else
- parameters.password = settings.password;
- end
+ if common.str.blank(settings.password) then
+ parameters.password = 'gateway' .. gateway_id;
+ else
+ parameters.password = settings.password;
+ end
- parameters['extension-in-contact'] = true;
+ parameters['extension-in-contact'] = true;
- if common.str.blank(settings.contact) then
- parameters['extension'] = 'gateway' .. gateway_id;
- else
- parameters['extension'] = settings.contact;
+ if common.str.blank(settings.contact) then
+ parameters['extension'] = 'gateway' .. gateway_id;
+ else
+ parameters['extension'] = settings.contact;
+ end
+ elseif technology == 'xmpp' then
+ parameters.message = 'Gemeinschaft 5 by AMOOMA';
+ parameters.dialplan = 'XML';
+ parameters.context = 'default';
+ parameters['rtp-ip'] = 'auto';
+ parameters['auto-login'] = 'true';
+ parameters.sasl = 'plain';
+ parameters.tls = 'true';
+ parameters['use-rtp-timer'] = 'true';
+ parameters.vad = 'both';
+ parameters.use_jingle = 'true';
+ parameters['candidate-acl'] = 'wan.auto';
+ parameters.name = self.GATEWAY_PREFIX .. gateway_id;
+ parameters.server = settings.server;
+ parameters.login = settings.login;
+ parameters.password = settings.password;
+ parameters.exten = settings.inbound_number or parameters.name;
end
for key, value in pairs(self:config_table_get('gateway_parameters', gateway_id)) do
diff --git a/misc/freeswitch/scripts/common/str.lua b/misc/freeswitch/scripts/common/str.lua
index 32f054e..793c191 100644
--- a/misc/freeswitch/scripts/common/str.lua
+++ b/misc/freeswitch/scripts/common/str.lua
@@ -5,6 +5,10 @@
module(...,package.seeall)
function try(array, arguments)
+ if type(arguments) ~= 'string' or type(array) ~= 'table' then
+ return nil;
+ end
+
local result = array;
arguments:gsub('([^%.]+)', function(entry)
diff --git a/misc/freeswitch/scripts/configuration.lua b/misc/freeswitch/scripts/configuration.lua
index 9e62bb6..062cf5d 100644
--- a/misc/freeswitch/scripts/configuration.lua
+++ b/misc/freeswitch/scripts/configuration.lua
@@ -29,7 +29,7 @@ function nodes(database, local_node_id)
end
-function gateways(database, profile_name)
+function sofia_gateways(database, profile_name)
require 'configuration.simple_xml'
local xml = configuration.simple_xml.SimpleXml:new();
@@ -44,8 +44,8 @@ function gateways(database, profile_name)
local gateway = gateways[index];
local gateway_profile = gateway_class:profile_get(gateway.id);
if tostring(gateway_profile) == profile_name or (profile_name == 'gemeinschaft' and common.str.blank(gateway_profile)) then
- log:debug('GATEWAY - name: ', gateway.name);
- local parameters = gateway_class:parameters_build(gateway.id);
+ log:debug('SIP_GATEWAY - name: ', gateway.name);
+ local parameters = gateway_class:parameters_build(gateway.id, 'sip');
gateways_xml = gateways_xml .. xml:element{
'gateway',
@@ -86,7 +86,7 @@ function profile(database, sofia_ini, profile_name, index, domains, node_id)
log:debug('SOFIA_PROFILE ', index,' - name: ', profile_name, ' - no domains');
end
- local gateways_xml = gateways(database, profile_name);
+ local gateways_xml = sofia_gateways(database, profile_name);
if index == 1 then
gateways_xml = gateways_xml .. nodes(database, node_id);
@@ -296,6 +296,65 @@ function conf_post_switch(database)
end
+function dingaling_profiles(database)
+ local TECHNOLOGY = 'xmpp';
+ require 'common.str'
+ require 'configuration.simple_xml'
+ local xml = configuration.simple_xml.SimpleXml:new();
+
+ require 'common.gateway'
+ local gateway_class = common.gateway.Gateway:new{ log = log, database = database};
+ local gateways = gateway_class:list(TECHNOLOGY);
+
+ local gateways_xml = '';
+ for index=1, #gateways do
+ local gateway = gateways[index];
+ local gateway_profile = gateway_class:profile_get(gateway.id);
+ log:debug('XMPP_GATEWAY - name: ', gateway.name);
+ local parameters = gateway_class:parameters_build(gateway.id, TECHNOLOGY);
+
+ gateways_xml = gateways_xml .. xml:element{
+ 'profile',
+ ['type'] = 'client',
+ xml:from_hash('param', parameters, 'name', 'value'),
+ };
+ end
+
+ return gateways_xml;
+end
+
+
+function conf_dingaling(database)
+ require 'configuration.simple_xml'
+ local xml = configuration.simple_xml.SimpleXml:new();
+
+ require 'common.configuration_table';
+ local parameters = common.configuration_table.get(database, 'dingaling', 'parameters') or {};
+
+ local profiles_xml = dingaling_profiles(database) or '';
+
+ XML_STRING = xml:element{
+ 'document',
+ ['type'] = 'freeswitch/xml',
+ xml:element{
+ 'section',
+ name = 'configuration',
+ description = 'Gemeinschaft 5 FreeSWITCH configuration',
+ xml:element{
+ 'configuration',
+ name = 'dingaling.conf',
+ description = 'Jingle endpoint configuration',
+ xml:element{
+ 'settings',
+ xml:from_hash('param', parameters, 'name', 'value'),
+ },
+ profiles_xml,
+ },
+ },
+ };
+end
+
+
function directory_sip_account(database)
require 'configuration.simple_xml'
local xml = configuration.simple_xml.SimpleXml:new();
@@ -480,6 +539,8 @@ if XML_REQUEST.section == 'configuration' and XML_REQUEST.tag_name == 'configura
if XML_REQUEST.key_value == 'sofia.conf' then
conf_sofia(database);
+ elseif XML_REQUEST.key_value == "dingaling.conf" then
+ conf_dingaling(database);
elseif XML_REQUEST.key_value == "conference.conf" then
conf_conference(database);
elseif XML_REQUEST.key_value == "voicemail.conf" then
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua
index b92dc70..ff4adc6 100644
--- a/misc/freeswitch/scripts/dialplan/dialplan.lua
+++ b/misc/freeswitch/scripts/dialplan/dialplan.lua
@@ -135,7 +135,7 @@ 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('sip', self.caller);
+ local gateway = gateway_class:authenticate(self.caller);
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);
@@ -565,6 +565,7 @@ function Dialplan.faxaccount(self, destination)
if not fax_account:insert_document(fax_document) then
self.log:error('FAX_RECEIVE - error inserting fax document to database - fax_account=', fax_account.id, '/', fax_account.uuid, ', file: ', fax_document.filename);
end
+ fax_account:trigger_notification(fax_account.id, self.caller.uuid);
end
return { continue = false, code = 200, phrase = 'OK' }
diff --git a/misc/freeswitch/scripts/dialplan/fax.lua b/misc/freeswitch/scripts/dialplan/fax.lua
index aa29ff6..49a45d9 100644
--- a/misc/freeswitch/scripts/dialplan/fax.lua
+++ b/misc/freeswitch/scripts/dialplan/fax.lua
@@ -230,3 +230,10 @@ function Fax.insert_document(self, record)
return self.database:query(sql_query);
end
+
+function Fax.trigger_notification(self, fax_document_id, uuid)
+ local command = 'http_request.lua ' .. uuid .. ' http://127.0.0.1/trigger/fax?fax_account_id=' .. tostring(fax_document_id);
+
+ require 'common.fapi'
+ return common.fapi.FApi:new():execute('luarun', command);
+end
diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua
index 7e64d7b..cdcb58b 100644
--- a/misc/freeswitch/scripts/dialplan/router.lua
+++ b/misc/freeswitch/scripts/dialplan/router.lua
@@ -52,27 +52,27 @@ function Router.read_table(self, table_name)
end
-function Router.expand_variables(self, line, variables)
+function Router.expand_variables(self, line, variables, variables2)
return (line:gsub('{([%a%d%._]+)}', function(captured)
- return common.str.try(variables, captured) or '';
+ return common.str.try(variables, captured) or common.str.try(variables2, captured) or '';
end))
end
-function Router.element_match(self, pattern, search_string, replacement)
+function Router.element_match(self, pattern, search_string, replacement, route_variables)
local success, result = pcall(string.find, search_string, pattern);
if not success then
self.log:error('ELEMENT_MATCH - table error - pattern: ', pattern, ', search_string: ', search_string);
elseif result then
- return true, search_string:gsub(pattern, self:expand_variables(replacement, self.variables));
+ return true, search_string:gsub(pattern, self:expand_variables(replacement, route_variables, self.variables));
end
return false;
end
-function Router.element_match_group(self, pattern, groups, replacement, use_key)
+function Router.element_match_group(self, pattern, groups, replacement, use_key, route_variables)
if type(groups) ~= 'table' then
return false;
end
@@ -81,7 +81,7 @@ function Router.element_match_group(self, pattern, groups, replacement, use_key)
if use_key then
value = key;
end
- result, replaced_value = self:element_match(pattern, tostring(value), replacement);
+ result, replaced_value = self:element_match(pattern, tostring(value), replacement, route_variables);
if result then
return true, replaced_value;
end
@@ -94,7 +94,8 @@ function Router.route_match(self, route)
gateway = 'gateway' .. route.endpoint_id,
['type'] = route.endpoint_type,
id = route.endpoint_id,
- channel_variables = {}
+ destination_number = common.str.try(self, 'caller.destination_number'),
+ channel_variables = {},
};
local route_matches = false;
@@ -108,13 +109,16 @@ function Router.route_match(self, route)
if element.action ~= 'none' then
if common.str.blank(element.var_in) or common.str.blank(element.pattern) and element.action == 'set' then
result = true;
- replacement = self:expand_variables(element.replacement, self.variables);
+ replacement = self:expand_variables(element.replacement, destination, self.variables);
else
local command, variable_name = common.str.partition(element.var_in, ':');
- if not command or not variable_name or command == 'var' then
- local search_string = tostring(common.str.try(self.caller, element.var_in))
- result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement));
+ if not command or not variable_name then
+ local search_string = tostring(common.str.try(destination, element.var_in) or common.str.try(self.caller, element.var_in));
+ result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement), destination);
+ elseif command == 'var' then
+ local search_string = tostring(common.str.try(self.caller, element.var_in));
+ result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement));
elseif command == 'key' or command == 'val' then
local groups = common.str.try(self.caller, variable_name);
result, replacement = self:element_match_group(tostring(element.pattern), groups, tostring(element.replacement), command == 'key');
diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua
index 3f56753..d1557e9 100644
--- a/misc/freeswitch/scripts/dialplan/sip_call.lua
+++ b/misc/freeswitch/scripts/dialplan/sip_call.lua
@@ -89,20 +89,21 @@ function SipCall.fork(self, destinations, arg )
for index, destination in ipairs(destinations) do
local origination_variables = { 'gs_fork_index=' .. index }
- self.log:info('FORK ', index, '/', #destinations, ' - ', destination.type, '=', destination.id, '/', destination.gateway or destination.uuid, '@', destination.node_id, ', number: ', destination.number, ', caller_id: "', destination.caller_id_name, '" <', destination.caller_id_number, '>');
+ self.log:info('FORK ', index, '/', #destinations, ' - ', destination.type, '=', destination.id, '/', destination.uuid, '@', destination.node_id, ', number: ', destination.number, ', caller_id: "', destination.caller_id_name, '" <', destination.caller_id_number, '>');
if not common.str.to_b(arg.update_callee_display) then
table.insert(origination_variables, 'ignore_display_updates=true');
end
- if not destination.node_local or destination.type == 'node' then
+ if not destination.node_local then
require 'common.node'
- local node = nil;
- if tonumber(destination.gateway) then
- node = common.node.Node:new{ log = self.log, database = self.database }:find_by_id(tonumber(destination.gateway));
- else
- node = common.node.Node:new{ log = self.log, database = self.database }:find_by_id(destination.node_id);
+ local node = common.node.Node:new{ log = self.log, database = self.database }:find_by_id(destination.node_id);
+ if node then
+ table.insert(origination_variables, 'sip_h_X-GS_node_id=' .. self.caller.local_node_id);
+ table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/gateway/' .. node.record.name .. '/' .. destination.number);
end
+ elseif destination.type == 'node' then
+ local node = common.node.Node:new{ log = self.log, database = self.database }:find_by_id(destination.id);
if node then
table.insert(origination_variables, 'sip_h_X-GS_node_id=' .. self.caller.local_node_id);
table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/gateway/' .. node.record.name .. '/' .. destination.number);
@@ -129,18 +130,26 @@ function SipCall.fork(self, destinations, arg )
call_result = { code = 486, phrase = 'User busy', disposition = 'USER_BUSY' };
end
elseif destination.type == 'gateway' then
- if destination.caller_id_number then
- table.insert(origination_variables, "origination_caller_id_number='" .. destination.caller_id_number .. "'");
- end
- if destination.caller_id_name then
- table.insert(origination_variables, "origination_caller_id_name='" .. destination.caller_id_name .. "'");
- end
- if destination.channel_variables then
- for key, value in pairs(destination.channel_variables) do
- table.insert(origination_variables, tostring(key) .. "='" .. tostring(value) .. "'");
+ require 'common.gateway'
+ local gateway = common.gateway.Gateway:new{ log = self.log, database = self.database}:find_by_id(destination.id);
+
+ if gateway and gateway.outbound then
+ if destination.caller_id_number then
+ table.insert(origination_variables, "origination_caller_id_number='" .. destination.caller_id_number .. "'");
+ end
+ if destination.caller_id_name then
+ table.insert(origination_variables, "origination_caller_id_name='" .. destination.caller_id_name .. "'");
end
+ if destination.channel_variables then
+ for key, value in pairs(destination.channel_variables) do
+ table.insert(origination_variables, tostring(key) .. "='" .. tostring(value) .. "'");
+ end
+ end
+
+ table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']' .. gateway:call_url(destination.number));
+ else
+ self.log:notice('FORK - gateway not found - gateway=', destination.id);
end
- table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/gateway/' .. tostring(destination.gateway) .. '/' .. tostring(destination.number));
elseif destination.type == 'dial' then
if destination.caller_id_number then
table.insert(origination_variables, "origination_caller_id_number='" .. destination.caller_id_number .. "'");
@@ -173,8 +182,10 @@ function SipCall.fork(self, destinations, arg )
self.caller:execute('ring_ready');
end
+ local session_dialstring = '{local_var_clobber=true}' .. table.concat(dial_strings, ',');
+ self.log:debug('FORK SESSION_START - call_url: ', session_dialstring);
local start_time = os.time();
- local session_callee = freeswitch.Session('{local_var_clobber=true}' .. table.concat(dial_strings, ','), self.caller.session);
+ local session_callee = freeswitch.Session(session_dialstring, self.caller.session);
self.log:debug('FORK SESSION_INIT - dial_time: ', os.time() - start_time);
local answer_result = self:wait_answer(self.caller.session, session_callee, arg.timeout, start_time);
local fork_index = nil;
diff --git a/misc/freeswitch/scripts/dialplan/voicemail.lua b/misc/freeswitch/scripts/dialplan/voicemail.lua
index 5d79ba3..4c96fbe 100644
--- a/misc/freeswitch/scripts/dialplan/voicemail.lua
+++ b/misc/freeswitch/scripts/dialplan/voicemail.lua
@@ -117,6 +117,7 @@ function Voicemail.leave(self, caller, phone_number)
caller.uuid .. "'"
);
caller:set_variable('voicemail_message_len', duration);
+ self:trigger_notification(caller);
else
caller:set_variable('voicemail_message_len');
end
@@ -125,14 +126,11 @@ function Voicemail.leave(self, caller, phone_number)
end
-function Voicemail.send_notify(self, caller)
- self.log:debug('VOICEMAIL_NOTIFY - account: ' .. self.record.auth_name .. ", id: " .. tostring(caller.uuid));
+function Voicemail.trigger_notification(self, caller)
+ local command = 'http_request.lua ' .. caller.uuid .. ' http://127.0.0.1/trigger/voicemail?sip_account_id=' .. tostring(self.id);
- local file = io.popen("/opt/GS5/script/voicemail_new '" .. tostring(self.record.auth_name) .. "' '" .. tostring(caller.uuid) .. "' 2>&1");
- self.log:debug('VOICEMAIL_NOTIFY - result: ' .. tostring(file:read("*a")));
- file:close();
-
- return true;
+ require 'common.fapi'
+ return common.fapi.FApi:new():execute('luarun', command);
end
diff --git a/misc/freeswitch/scripts/event_manager.lua b/misc/freeswitch/scripts/event_manager.lua
index 4e78ccf..1e61baf 100644
--- a/misc/freeswitch/scripts/event_manager.lua
+++ b/misc/freeswitch/scripts/event_manager.lua
@@ -1,4 +1,4 @@
--- Gemeinschaft 5.0 event handler
+-- Gemeinschaft 5 event handler
-- (c) AMOOMA GmbH 2012-2013
--
diff --git a/misc/freeswitch/scripts/fax_daemon.lua b/misc/freeswitch/scripts/fax_daemon.lua
index 6609fe6..94d343a 100644
--- a/misc/freeswitch/scripts/fax_daemon.lua
+++ b/misc/freeswitch/scripts/fax_daemon.lua
@@ -1,4 +1,4 @@
--- Gemeinschaft 5.0 fax daemon
+-- Gemeinschaft 5 fax daemon
-- (c) AMOOMA GmbH 2012-2013
--
diff --git a/misc/freeswitch/scripts/http_request.lua b/misc/freeswitch/scripts/http_request.lua
new file mode 100644
index 0000000..8acdcb6
--- /dev/null
+++ b/misc/freeswitch/scripts/http_request.lua
@@ -0,0 +1,31 @@
+-- Gemeinschaft 5 fire and forget http request script
+-- (c) AMOOMA GmbH 2013
+--
+
+http = require('socket.http');
+http.TIMEOUT = 10;
+http.USERAGENT = 'Gemeinschaft 5';
+
+local log_identifier = argv[1];
+local url = argv[2];
+local user = argv[3];
+local password = argv[4];
+
+if not log_identifier or not url then
+ return;
+end
+
+-- Set logger
+require 'common.log';
+local log = common.log.Log:new();
+log.prefix = '#R# [' .. log_identifier .. '] ';
+
+local headers = {};
+
+if user and password then
+ mime = require('mime');
+ headers.Authorization = 'Basic ' .. (mime.b64(user .. ':' .. password));
+end
+
+local success, result, response_headers = http.request{url = url, headers = headers };
+log:debug('HTTP_REQUEST - url: ', url, ', auth: ', tostring(headers.Authorization ~= nil), ', result: ', result);
diff --git a/misc/freeswitch/scripts/phones/phone.lua b/misc/freeswitch/scripts/phones/phone.lua
index 856398b..6da20f0 100644
--- a/misc/freeswitch/scripts/phones/phone.lua
+++ b/misc/freeswitch/scripts/phones/phone.lua
@@ -28,10 +28,10 @@ function Phone.list_by_sql(self, sql_query)
if phone.record.ieee_name == 'snom technology ag' then
require 'phones.snom'
- phone.model = phones.snom.Snom:new();
+ phone.model = phones.snom.Snom:new{ log = self.log };
elseif account_entry.ieee_name == 'siemens enterprise communicationsgmbh & co. kg' then
require 'phones.siemens'
- phone.model = phones.siemens.Siemens:new();
+ phone.model = phones.siemens.Siemens:new{ log = self.log };
end
table.insert(account_phones, phone);
end)
@@ -120,5 +120,8 @@ function Phone.resync(self, arg)
end
arg.ip_address = arg.ip_address or self.record.ip_address;
+ arg.http_user = arg.http_user or self.record.http_user;
+ arg.http_password = arg.http_password or self.record.http_password;
+
return self.model:resync(arg);
-end \ No newline at end of file
+end
diff --git a/misc/freeswitch/scripts/phones/snom.lua b/misc/freeswitch/scripts/phones/snom.lua
index 096ccb7..bb17796 100644
--- a/misc/freeswitch/scripts/phones/snom.lua
+++ b/misc/freeswitch/scripts/phones/snom.lua
@@ -53,13 +53,8 @@ function Snom.resync_http(self, ip_address, http_user, http_password, http_port)
port_str = ':' .. http_port;
end
- get_command = 'wget --no-proxy -q -O /dev/null -o /dev/null -b --tries=2 --timeout=10 --user="' .. (http_user or '') .. '" --password="' .. (http_password or '') .. '"' ..
- ' wget http://' .. tostring(ip_address):gsub('[^0-9%.]', '') .. port_str .. '/advanced.htm?reboot=Reboot' ..
- ' 1>>/dev/null 2>>/dev/null &';
+ local command = 'http_request.lua snom_resync http://' .. tostring(ip_address):gsub('[^0-9%.]', '') .. port_str .. '/advanced.htm?reboot=Reboot ' .. (http_user or '') .. ' ' .. (http_password or '');
- result = os.execute(get_command);
-
- if result and tonumber(result) == 0 then
- return true;
- end
+ require 'common.fapi'
+ return common.fapi.FApi:new():execute('luarun', command);
end
diff --git a/misc/freeswitch/scripts/send_fax.lua b/misc/freeswitch/scripts/send_fax.lua
index 11cd1d7..e3dc4cc 100644
--- a/misc/freeswitch/scripts/send_fax.lua
+++ b/misc/freeswitch/scripts/send_fax.lua
@@ -1,4 +1,4 @@
--- Gemeinschaft 5.0
+-- Gemeinschaft 5
-- (c) AMOOMA GmbH 2012-2013
--