From c8db7371bc31c6ef6ab27026d5f839c2095b924f Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 9 Jan 2013 11:10:04 +0100 Subject: read dialplan configuration from database --- misc/freeswitch/scripts/dialplan_default.lua | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan_default.lua') diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index ee4a88f..91ad4e4 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -23,10 +23,18 @@ log = common.log.Log:new{ prefix = '### [' .. session:get_uuid() .. '] ' }; require 'dialplan.session' start_caller = dialplan.session.Session:new{ log = log, session = session }; +-- connect to database +require 'common.database' +local database = common.database.Database:new{ log = log }:connect(); +if not database:connected() then + log:critical('DIALPLAN_DEFAULT - database connect failed'); + return; +end + -- dialplan object require 'dialplan.dialplan' -start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller }; +start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller, database = database }; start_dialplan:configuration_read(); start_caller.local_node_id = start_dialplan.node_id; start_caller:init_channel_variables(); @@ -39,16 +47,6 @@ if not start_dialplan:check_auth() then return false; end --- connect to database -require 'common.database' -local database = common.database.Database:new{ log = log }:connect(); -if not database:connected() then - log:critical('DIALPLAN_DEFAULT - database connect failed'); - return; -end - -start_dialplan.database = database; - if start_caller.from_node and not start_dialplan:check_auth_node() then log:debug('AUTHENTICATION_REQUIRED_NODE - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain); start_dialplan:hangup(407, start_dialplan.domain); -- cgit v1.2.3 From 64c8b78bbf5880c2b8948cf7588ffe7d0a843357 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 17:15:02 +0100 Subject: display contacht host --- misc/freeswitch/scripts/dialplan_default.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'misc/freeswitch/scripts/dialplan_default.lua') diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index 91ad4e4..1c0a52e 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -42,7 +42,7 @@ start_caller:init_channel_variables(); -- session:execute('info','notice'); if not start_dialplan:check_auth() then - log:debug('AUTHENTICATION_REQUIRED - domain: ', start_dialplan.domain); + log:debug('AUTHENTICATION_REQUIRED - host: ' , start_caller.sip_contact_host, ', domain: ', start_dialplan.domain); start_dialplan:hangup(407, start_dialplan.domain); return false; end -- cgit v1.2.3 From b713c19f0a7727a14b5ea4d72f8ddaaf01736027 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 15 Jan 2013 12:30:29 +0100 Subject: tweaking authentication --- misc/freeswitch/scripts/dialplan_default.lua | 29 ++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan_default.lua') diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index 1c0a52e..42271b9 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -34,20 +34,37 @@ end -- dialplan object require 'dialplan.dialplan' -start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller, database = database }; +local start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller, database = database }; start_dialplan:configuration_read(); start_caller.local_node_id = start_dialplan.node_id; start_caller:init_channel_variables(); -- session:execute('info','notice'); -if not start_dialplan:check_auth() then - log:debug('AUTHENTICATION_REQUIRED - host: ' , start_caller.sip_contact_host, ', domain: ', start_dialplan.domain); - start_dialplan:hangup(407, start_dialplan.domain); - return false; +if start_caller.from_node and not start_dialplan:auth_node() then + log:debug('DIALPLAN_DEFAULT - node unauthorized - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain); + start_dialplan:hangup(401, start_dialplan.domain); +else + if not start_dialplan:auth_sip_account() then + local gateway = start_dialplan:auth_gateway() + + if gateway then + start_caller.gateway_name = gateway.name; + start_caller.gateway_id = gateway.id; + start_caller.from_gateway = true; + start_caller.gateway = gateway; + else + log:debug('AUTHENTICATION_REQUIRED_SIP_ACCOUNT - contact host: ' , start_caller.sip_contact_host, ', ip: ', start_caller.sip_network_ip, ', domain: ', start_dialplan.domain); + start_dialplan:hangup(407, start_dialplan.domain); + if database then + database:release(); + end + return; + end + end end -if start_caller.from_node and not start_dialplan:check_auth_node() then +if start_caller.from_node then log:debug('AUTHENTICATION_REQUIRED_NODE - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain); start_dialplan:hangup(407, start_dialplan.domain); else -- cgit v1.2.3 From 1debae060b1c4a816f4565ad55490fee61c6472b Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 09:28:38 +0100 Subject: dump_variables dialplan option added --- misc/freeswitch/scripts/dialplan_default.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'misc/freeswitch/scripts/dialplan_default.lua') diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index 42271b9..eb80ae4 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -39,7 +39,9 @@ start_dialplan:configuration_read(); start_caller.local_node_id = start_dialplan.node_id; start_caller:init_channel_variables(); --- session:execute('info','notice'); +if start_dialplan.config.parameters.dump_variables then + start_caller:execute('info', 'notice'); +end if start_caller.from_node and not start_dialplan:auth_node() then log:debug('DIALPLAN_DEFAULT - node unauthorized - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain); -- cgit v1.2.3 From 8744de13516c3fc2fbf2843e85aff08707f50de1 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Fri, 18 Jan 2013 12:54:45 +0100 Subject: adjust copyright date for 2013 --- misc/freeswitch/scripts/dialplan_default.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'misc/freeswitch/scripts/dialplan_default.lua') diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index eb80ae4..7caff57 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 default dialplan --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- -- cgit v1.2.3