summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/dialplan_default.lua
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /misc/freeswitch/scripts/dialplan_default.lua
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'misc/freeswitch/scripts/dialplan_default.lua')
-rw-r--r--misc/freeswitch/scripts/dialplan_default.lua64
1 files changed, 64 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua
new file mode 100644
index 0000000..ee4a88f
--- /dev/null
+++ b/misc/freeswitch/scripts/dialplan_default.lua
@@ -0,0 +1,64 @@
+-- Gemeinschaft 5 default dialplan
+-- (c) AMOOMA GmbH 2012
+--
+
+
+function hangup_hook_caller(s, status, arg)
+ log:info('HANGUP_HOOK: ', status)
+ if tostring(status) == 'transfer' then
+ if start_caller and start_caller.destination then
+ log:info('CALL_TRANSFERRED - destination was: ', start_caller.destination.type, '=', start_caller.destination.id,', number: ' .. tostring(start_caller.destination.number) .. ', to: ' .. start_caller:to_s('sip_refer_to'));
+ start_caller.auth_account = start_dialplan:object_find(start_caller.destination.type, start_caller.destination.id);
+ start_caller.forwarding_number = start_caller.destination.number;
+ start_caller.forwarding_service = 'transfer';
+ end
+ end
+end
+
+-- initialize logging
+require 'common.log'
+log = common.log.Log:new{ prefix = '### [' .. session:get_uuid() .. '] ' };
+
+-- caller session object
+require 'dialplan.session'
+start_caller = dialplan.session.Session:new{ log = log, session = session };
+
+-- dialplan object
+require 'dialplan.dialplan'
+
+start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller };
+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 - domain: ', start_dialplan.domain);
+ start_dialplan:hangup(407, start_dialplan.domain);
+ 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);
+else
+ start_destination = { type = 'unknown' }
+ start_caller.session:setHangupHook('hangup_hook_caller', 'destination_number');
+ start_dialplan:run(start_destination);
+end
+
+-- release database handle
+if database then
+ database:release();
+end