summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/freeswitch/scripts/common/log.lua4
-rw-r--r--misc/freeswitch/scripts/dialplan/router.lua1
-rw-r--r--misc/freeswitch/scripts/test_route.lua58
3 files changed, 63 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/common/log.lua b/misc/freeswitch/scripts/common/log.lua
index b7c8d09..e6aa7fa 100644
--- a/misc/freeswitch/scripts/common/log.lua
+++ b/misc/freeswitch/scripts/common/log.lua
@@ -12,6 +12,7 @@ function Log.new(self, arg)
object = arg.object or {}
setmetatable(object, self);
self.__index = self;
+ self.disabled = arg.disabled or false;
self.prefix = arg.prefix or '### ';
self.level_console = arg.level_console or 0;
@@ -27,6 +28,9 @@ function Log.new(self, arg)
end
function Log.message(self, log_level, message_arguments )
+ if self.disabled then
+ return
+ end
local message = tostring(self.prefix);
for index, value in pairs(message_arguments) do
if type(index) == 'number' then
diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua
index 277958a..2d82f91 100644
--- a/misc/freeswitch/scripts/dialplan/router.lua
+++ b/misc/freeswitch/scripts/dialplan/router.lua
@@ -98,6 +98,7 @@ function Router.route_match(self, route)
id = route.endpoint_id,
destination_number = common.array.try(self, 'caller.destination_number'),
channel_variables = {},
+ route_id = route.id,
};
local route_matches = false;
diff --git a/misc/freeswitch/scripts/test_route.lua b/misc/freeswitch/scripts/test_route.lua
new file mode 100644
index 0000000..4ff10b5
--- /dev/null
+++ b/misc/freeswitch/scripts/test_route.lua
@@ -0,0 +1,58 @@
+-- Gemeinschaft 5 routing test module
+-- (c) AMOOMA GmbH 2013
+--
+
+require 'common.array';
+
+local arguments = {};
+local value = nil;
+
+for index=1, #argv do
+ if math.mod(index, 2) == 0 then
+ common.array.set(arguments, argv[index], value);
+ else
+ value = argv[index];
+ end
+end
+
+local caller = arguments.caller or {};
+local channel_variables = arguments.chv or {};
+
+function caller.to_s(variable)
+ return common.str.to_s(arguments[variable])
+end
+
+-- initialize logging
+require 'common.log';
+log = common.log.Log:new{ disabled = true };
+
+-- connect to database
+require 'common.database';
+local database = common.database.Database:new{ log = log }:connect();
+if not database:connected() then
+ log:critical('TEST_ROUTE - database connection failed');
+ return;
+end
+
+-- dialplan object
+require 'dialplan.dialplan'
+local dialplan_object = dialplan.dialplan.Dialplan:new{ log = log, caller = caller, database = database };
+dialplan_object:configuration_read();
+caller.dialplan = dialplan_object;
+caller.local_node_id = dialplan_object.node_id;
+
+dialplan_object:retrieve_caller_data();
+
+require 'dialplan.router';
+local routes = dialplan.router.Router:new{ log = log, database = database, caller = caller, variables = caller }:route_run(arguments.table or 'outbound');
+
+local result = {
+ routes = routes
+}
+
+stream:write(common.array.to_json(result));
+
+-- release database handle
+if database then
+ database:release();
+end