summaryrefslogtreecommitdiffstats
path: root/examples/dumpdns.lua
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-07-17 07:11:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-07-17 07:11:16 +0000
commita68848db159cc1cafa82f9d383432fda459c8745 (patch)
tree5fd1cd2cd6f298bebbbb0ce5db29fa6de68a2acc /examples/dumpdns.lua
parentAdding debian version 1.1.0+debian-1. (diff)
downloaddnsjit-a68848db159cc1cafa82f9d383432fda459c8745.tar.xz
dnsjit-a68848db159cc1cafa82f9d383432fda459c8745.zip
Merging upstream version 1.2.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/dumpdns.lua')
-rwxr-xr-xexamples/dumpdns.lua18
1 files changed, 15 insertions, 3 deletions
diff --git a/examples/dumpdns.lua b/examples/dumpdns.lua
index 7c6fb8c..3b90034 100755
--- a/examples/dumpdns.lua
+++ b/examples/dumpdns.lua
@@ -1,18 +1,30 @@
#!/usr/bin/env dnsjit
local pcap = arg[2]
+local compression = arg[3]
if pcap == nil then
- print("usage: "..arg[1].." <pcap>")
+ print("usage: "..arg[1].." <pcap> [compression]")
return
end
local object = require("dnsjit.core.objects")
local input = require("dnsjit.input.pcap").new()
+local zinput = require("dnsjit.input.zpcap").new()
local layer = require("dnsjit.filter.layer").new()
local dns = require("dnsjit.core.object.dns").new()
-input:open_offline(pcap)
-layer:producer(input)
+if string.lower(string.sub(pcap, -4)) == ".zst" or compression == "zstd" then
+ zinput:zstd()
+ zinput:open(pcap)
+ layer:producer(zinput)
+elseif string.lower(string.sub(pcap, -4)) == ".lz4" or compression == "lz4" then
+ zinput:lz4()
+ zinput:open(pcap)
+ layer:producer(zinput)
+else
+ input:open_offline(pcap)
+ layer:producer(input)
+end
local producer, ctx = layer:produce()
while true do