summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2017-02-01 17:31:08 +0200
committerAndrew Lewis <nerf@judo.za.org>2017-02-01 17:31:08 +0200
commit29802ac374a9b315423d7815eaedd81d23205545 (patch)
tree231da9f342437b287c4c7801c159771b47aee5e5 /contrib
parent5ad02a7ad991404072c674b1e8d5e946a899730d (diff)
downloadrspamd-29802ac374a9b315423d7815eaedd81d23205545.tar.gz
rspamd-29802ac374a9b315423d7815eaedd81d23205545.zip
[Minor] Recreate grep tool as `rspamadm grep`
Diffstat (limited to 'contrib')
-rw-r--r--contrib/rspamdgrep/rspamdgrep.lua92
-rwxr-xr-xcontrib/rspamdgrep/rspamdgrep.sh11
2 files changed, 0 insertions, 103 deletions
diff --git a/contrib/rspamdgrep/rspamdgrep.lua b/contrib/rspamdgrep/rspamdgrep.lua
deleted file mode 100644
index 4a4341f5e..000000000
--- a/contrib/rspamdgrep/rspamdgrep.lua
+++ /dev/null
@@ -1,92 +0,0 @@
-local rspamd_regexp = require 'rspamd_regexp'
-
-local E = {}
-
-local buffer = {}
-local matches = {}
-
-if type(arg) ~= 'table' then
- io.stderr:write('Syntax: rspamdgrep <pattern> [sources]\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
-
-if not arg[1] then
- arg = {'stdin'}
-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 n == 'stdin' then
- h = io.input()
- else
- h, err = io.open(n, 'r')
- end
- if not h then
- if err then
- io.stderr:write("Couldn't open file (" .. n .. '): ' .. err .. '\n')
- else
- io.stderr:write("Couldn't open file (" .. n .. '): no error')
- 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
- end
- end
- if re:match(line) then
- if not hash then
- print('*** orphaned ***')
- print(line)
- print()
- else
- 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
- 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
- if matches[hash] then
- for _, v in ipairs(matches[hash]) do
- print(v)
- end
- print()
- matches[hash] = nil
- end
- end
- end
- end
-end
-for _, v in pairs(matches) do
- print('*** partial ***')
- 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