diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-01 16:50:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-01 16:50:29 +0000 |
commit | 3162eafdfee5ecc46c2624a054e8a80a18d13c6f (patch) | |
tree | 71d52af65e69f3beffbd4796ca7e9b459e75a645 /contrib | |
parent | 3cddb1286bc8e2c2a0dd24fe0114e28597b34e4c (diff) | |
parent | 29802ac374a9b315423d7815eaedd81d23205545 (diff) | |
download | rspamd-3162eafdfee5ecc46c2624a054e8a80a18d13c6f.tar.gz rspamd-3162eafdfee5ecc46c2624a054e8a80a18d13c6f.zip |
Merge pull request #1388 from fatalbanana/b3
rspamadm grep
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/rspamdgrep/rspamdgrep.lua | 85 | ||||
-rwxr-xr-x | contrib/rspamdgrep/rspamdgrep.sh | 11 |
2 files changed, 0 insertions, 96 deletions
diff --git a/contrib/rspamdgrep/rspamdgrep.lua b/contrib/rspamdgrep/rspamdgrep.lua deleted file mode 100644 index 7529c7c9c..000000000 --- a/contrib/rspamdgrep/rspamdgrep.lua +++ /dev/null @@ -1,85 +0,0 @@ -local rspamd_regexp = require 'rspamd_regexp' -local rspamd_logger = require 'rspamd_logger' - -local BUF_SIZE = 10240 -local E = {} - -local buffer = {} -local matches = {} -local count = 0 - -if type(arg) ~= 'table' then - io.stderr:write('No files specified for search\n') - os.exit(1) -end - -local pattern = table.remove(arg, 1) -local re = rspamd_regexp.create(pattern) -if not re then - io.stderr:write("Couldn't compile regex: " .. pattern .. '\n') - os.exit(1) -end - -for _, n in ipairs(arg) do - local h, err - if string.match(n, '%.xz$') then - h, err = io.popen('xzcat ' .. n, 'r') - elseif string.match(n, '%.bz2$') then - h, err = io.popen('bzcat ' .. n, 'r') - elseif string.match(n, '%.gz$') then - h, err = io.popen('zcat ' .. n, 'r') - elseif string.match(n, '%.log$') then - h, err = io.open(n, 'r') - else - io.stderr:write("Couldn't identify log format: " .. n .. '\n') - end - if not h then - if err then - io.stderr:write("Couldn't open file (" .. n .. '): ' .. err .. '\n') - end - else - for line in h:lines() do - local hash = string.match(line, '^%d+-%d+-%d+ %d+:%d+:%d+ #%d+%(%a+%) <(%x+)>') - if hash then - if matches[hash] then - table.insert(matches[hash], line) - else - if buffer[hash] then - table.insert(buffer[hash], line) - else - buffer[hash] = {line} - end - count = count + 1 - if count >= BUF_SIZE then - local k = next(buffer) - buffer[k] = nil - count = count - 1 - end - end - end - if re:match(line) then - if not hash then - hash = 'orphaned' - end - if matches[hash] then - table.insert(matches[hash], line) - else - local old = buffer[hash] or E - table.insert(old, line) - matches[hash] = old - end - end - local is_end = string.match(line, '^%d+-%d+-%d+ %d+:%d+:%d+ #%d+%(%a+%) <%x+>; task; rspamd_protocol_http_reply:') - if is_end then - buffer[hash] = nil - end - end - end -end - -for k, v in pairs(matches) do - for _, vv in ipairs(v) do - print(vv) - end - print() -end diff --git a/contrib/rspamdgrep/rspamdgrep.sh b/contrib/rspamdgrep/rspamdgrep.sh deleted file mode 100755 index 08a5fea2f..000000000 --- a/contrib/rspamdgrep/rspamdgrep.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# Process command-line arguments -LARG="" -for i in "$@" -do - LARG="$LARG -a $i" -done - -# Call rspamadm lua -rspamadm lua $LARG rspamdgrep.lua |