summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/dialplan/router.lua
diff options
context:
space:
mode:
Diffstat (limited to 'misc/freeswitch/scripts/dialplan/router.lua')
-rw-r--r--misc/freeswitch/scripts/dialplan/router.lua21
1 files changed, 20 insertions, 1 deletions
diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua
index 50653d8..c2b229d 100644
--- a/misc/freeswitch/scripts/dialplan/router.lua
+++ b/misc/freeswitch/scripts/dialplan/router.lua
@@ -160,13 +160,21 @@ function Router.route_match(self, route)
table.insert(arguments, common.array.expand_variables(argument, destination, self.variables));
end
result, replacement = self['fun_' .. variable_name](self, unpack(arguments))
- if self.log_details or true then
+ if not common.str.blank(element.pattern) then
+ if self.log_details then
+ self.log:debug('ELEMENT_FUNCTION - function: ', variable_name, '(', table.concat(arguments, ', '), ') => ', replacement);
+ end
+ result, replacement = self:element_match(tostring(element.pattern), tostring(replacement), tostring(replacement));
+ end
+ if self.log_details then
if result then
self.log:debug('ELEMENT_MATCH - function: ', variable_name, '(', table.concat(arguments, ', '), ') => ', replacement);
else
self.log:debug('ELEMENT_NO_MATCH - function: ', variable_name, '(', table.concat(arguments, ', '), ') => ', tostring(replacement));
end
end
+ else
+ self.log:error('ELEMENT_FUNCTION - function not found: ', 'fun_' .. variable_name);
end
end
end
@@ -267,3 +275,14 @@ function Router.fun_speeddial(self, number, name)
end
end
end
+
+
+function Router.fun_expression(self, expression_str)
+ expression_str = expression_str:gsub('[^%d%.%+%(%)%^%%%*%/-<>]', '');
+ result = loadstring("return (" .. expression_str .. ")")();
+ if result then
+ return true, result;
+ else
+ return false, result;
+ end
+end