summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-27 11:13:13 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-27 11:13:13 +0100
commit361a226ac8167b2c6a552960155e89ecb344ec0c (patch)
treefe9e3f8921749015803f0efcb03169fcc226c333
parentf5a09733ae0b6f77211eea03ab161e0c9122465b (diff)
parent45af07cb093eb0202967cf0d0fc058ca58f0b782 (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
-rw-r--r--app/controllers/gateways_controller.rb2
-rw-r--r--app/models/gateway.rb2
-rw-r--r--app/models/gateway_setting.rb10
-rw-r--r--app/views/gateway_settings/_form_core.html.haml2
-rw-r--r--app/views/gateways/_form_core.html.haml2
-rw-r--r--db/migrate/20130127073800_add_dingaling_parameter.rb10
-rw-r--r--misc/freeswitch/conf/freeswitch.xml1
-rw-r--r--misc/freeswitch/scripts/common/gateway.lua85
-rw-r--r--misc/freeswitch/scripts/configuration.lua69
-rw-r--r--misc/freeswitch/scripts/dialplan/dialplan.lua2
10 files changed, 149 insertions, 36 deletions
diff --git a/app/controllers/gateways_controller.rb b/app/controllers/gateways_controller.rb
index 5741195..d3362e0 100644
--- a/app/controllers/gateways_controller.rb
+++ b/app/controllers/gateways_controller.rb
@@ -13,6 +13,7 @@ class GatewaysController < ApplicationController
def new
@gateway = Gateway.new
+ @technologies = Gateway::TECHNOLOGIES
spread_breadcrumbs
end
@@ -28,6 +29,7 @@ class GatewaysController < ApplicationController
def edit
@gateway = Gateway.find(params[:id])
+ @technologies = Gateway::TECHNOLOGIES
spread_breadcrumbs
end
diff --git a/app/models/gateway.rb b/app/models/gateway.rb
index 3e791a6..a8df41f 100644
--- a/app/models/gateway.rb
+++ b/app/models/gateway.rb
@@ -1,5 +1,5 @@
class Gateway < ActiveRecord::Base
- TECHNOLOGIES = ['sip']
+ TECHNOLOGIES = ['sip', 'xmpp']
attr_accessible :name, :technology, :inbound, :outbound, :description
diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb
index c01f0a8..e3eaadb 100644
--- a/app/models/gateway_setting.rb
+++ b/app/models/gateway_setting.rb
@@ -11,6 +11,16 @@ class GatewaySetting < ActiveRecord::Base
'auth_pattern' => 'String',
'number_source' => 'String',
},
+ 'xmpp' => {
+ 'server' => 'String',
+ 'login' => 'String',
+ 'password' => 'String',
+ 'inbound_number' => 'String',
+ 'auth_source' => 'String',
+ 'auth_pattern' => 'String',
+ 'number_source' => 'String',
+ 'destination_domain' => 'String',
+ },
}
attr_accessible :gateway_id, :name, :value, :class_type, :description
diff --git a/app/views/gateway_settings/_form_core.html.haml b/app/views/gateway_settings/_form_core.html.haml
index 3e7dc49..229009b 100644
--- a/app/views/gateway_settings/_form_core.html.haml
+++ b/app/views/gateway_settings/_form_core.html.haml
@@ -1,4 +1,4 @@
.inputs
- = f.input :name, :collection => GatewaySetting::GATEWAY_SETTINGS['sip'].keys, :label => t('gateway_settings.form.name.label'), :hint => conditional_hint('gateway_settings.form.name.hint'), :autofocus => true, :include_blank => false
+ = f.input :name, :collection => GatewaySetting::GATEWAY_SETTINGS[@gateway.technology].keys, :label => t('gateway_settings.form.name.label'), :hint => conditional_hint('gateway_settings.form.name.hint'), :autofocus => true, :include_blank => false
= f.input :value, :label => t('gateway_settings.form.value.label'), :hint => conditional_hint('gateway_settings.form.value.hint')
= f.input :description, :label => t('gateway_settings.form.description.label'), :hint => conditional_hint('gateway_settings.form.description.hint')
diff --git a/app/views/gateways/_form_core.html.haml b/app/views/gateways/_form_core.html.haml
index 13ed8b1..604c223 100644
--- a/app/views/gateways/_form_core.html.haml
+++ b/app/views/gateways/_form_core.html.haml
@@ -1,6 +1,6 @@
.inputs
= f.input :name, :label => t('gateways.form.name.label'), :hint => conditional_hint('gateways.form.name.hint'), :autofocus => true
- = f.input :technology, :label => t('gateways.form.technology.label'), :hint => conditional_hint('gateways.form.technology.hint')
+ = f.input :technology, :collection => @technologies, :label => t('gateways.form.technology.label'), :hint => conditional_hint('gateways.form.technology.hint'), :include_blank => false
= f.input :inbound, :label => t('gateways.form.inbound.label'), :hint => conditional_hint('gateways.form.inbound.hint')
= f.input :outbound, :label => t('gateways.form.outbound.label'), :hint => conditional_hint('gateways.form.outbound.hint')
= f.input :description, :label => t('gateways.form.description.label'), :hint => conditional_hint('gateways.form.description.hint')
diff --git a/db/migrate/20130127073800_add_dingaling_parameter.rb b/db/migrate/20130127073800_add_dingaling_parameter.rb
new file mode 100644
index 0000000..ff5bd7c
--- /dev/null
+++ b/db/migrate/20130127073800_add_dingaling_parameter.rb
@@ -0,0 +1,10 @@
+class AddDingalingParameter < ActiveRecord::Migration
+ def up
+ GsParameter.create(:entity => 'dingaling', :section => 'parameters', :name => 'debug', :value => '0', :class_type => 'Integer', :description => 'Debug level.')
+ GsParameter.create(:entity => 'dingaling', :section => 'parameters', :name => 'codec-prefs', :value => 'PCMA,PCMU', :class_type => 'String', :description => 'Codec preferences.')
+ end
+
+ def down
+ GsParameter.where(:entity => 'dingaling', :section => 'parameters').destroy_all
+ end
+end
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);