summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/common
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-11 12:30:22 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-11 12:30:22 +0100
commit766fd073042d00b588955734daa91df3f7be8bab (patch)
tree00c1a9c17670387d2720c96c0f7c9b895e09b1c3 /misc/freeswitch/scripts/common
parent3305624fc4b6de2dabaa292fa1480851ca141c96 (diff)
parent62293482479ff51c5044f536aa2aae88e5117f46 (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'misc/freeswitch/scripts/common')
-rw-r--r--misc/freeswitch/scripts/common/perimeter.lua20
1 files changed, 8 insertions, 12 deletions
diff --git a/misc/freeswitch/scripts/common/perimeter.lua b/misc/freeswitch/scripts/common/perimeter.lua
index 288e8a2..d3b601c 100644
--- a/misc/freeswitch/scripts/common/perimeter.lua
+++ b/misc/freeswitch/scripts/common/perimeter.lua
@@ -9,6 +9,9 @@ Perimeter = {}
function Perimeter.new(self, arg)
+ require 'common.str';
+ require 'common.array';
+
arg = arg or {}
object = arg.object or {}
setmetatable(object, self);
@@ -203,7 +206,7 @@ end
function Perimeter.check_bad_headers(self, event)
local points = nil;
for name, pattern in pairs(self.bad_headers[event.action]) do
- pattern = self:expand_variables(pattern, event);
+ pattern = common.array.expand_variables(pattern, event);
local success, result = pcall(string.find, event[name], pattern);
if success and result then
self.log:debug('[', event.key, '/', event.sequence, '] PERIMETER_BAD_HEADERS - ', name, '=', event[name], ' ~= ', pattern);
@@ -225,36 +228,29 @@ function Perimeter.append_blacklist_file(self, event)
event.date = self:format_date(event.timestamp);
if self.blacklist_file_comment then
- blacklist:write(self:expand_variables(self.blacklist_file_comment, event), '\n');
+ blacklist:write(common.array.expand_variables(self.blacklist_file_comment, event), '\n');
end
self.log:debug('[', event.key, '/', event.sequence, '] PERIMETER_APPEND_BLACKLIST - file: ', self.blacklist_file);
- blacklist:write(self:expand_variables(self.blacklist_file_entry, event), '\n');
+ blacklist:write(common.array.expand_variables(self.blacklist_file_entry, event), '\n');
blacklist:close();
end
function Perimeter.execute_ban(self, event)
- local command = self:expand_variables(self.ban_command, event);
+ local command = common.array.expand_variables(self.ban_command, event);
self.log:debug('[', event.key, '/', event.sequence, '] PERIMETER_EXECUTE_BAN - command: ', command);
local result = os.execute(command);
end
+
function Perimeter.update_intruder(self, event)
require 'common.intruder';
local result = common.intruder.Intruder:new{ log = self.log, database = self.database }:update_blacklist(event);
end
-function Perimeter.expand_variables(self, line, variables)
- return (line:gsub('{([%a%d%._]+)}', function(captured)
- return variables[captured] or '';
- end))
-end
-
-
function Perimeter.action_db_rescan(self, record)
- require 'common.str';
require 'common.intruder';
if common.str.blank(record.key) then