diff options
Diffstat (limited to 'misc/freeswitch')
-rw-r--r-- | misc/freeswitch/conf/freeswitch.xml | 1 | ||||
-rw-r--r-- | misc/freeswitch/scripts/common/gateway.lua | 85 | ||||
-rw-r--r-- | misc/freeswitch/scripts/configuration.lua | 69 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/dialplan.lua | 2 |
4 files changed, 124 insertions, 33 deletions
diff --git a/misc/freeswitch/conf/freeswitch.xml b/misc/freeswitch/conf/freeswitch.xml index 33a743e..fd6ab67 100644 --- a/misc/freeswitch/conf/freeswitch.xml +++ b/misc/freeswitch/conf/freeswitch.xml @@ -634,6 +634,7 @@ <load module="mod_say_en"/> <load module="mod_spandsp"/> <load module="mod_snmp"/> + <load module="mod_dingaling"/> </modules> </configuration> <configuration name="lua.conf" description="LUA Configuration"> diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua index 1b3b832..c1b50a7 100644 --- a/misc/freeswitch/scripts/common/gateway.lua +++ b/misc/freeswitch/scripts/common/gateway.lua @@ -84,20 +84,30 @@ end 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, technology, caller) +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; @@ -142,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/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 49d698b..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); |