From 414d18a6daae0f4ddae396c0ff60f51ebe0de040 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Sat, 12 Jul 2025 11:59:55 +0200 Subject: [PATCH] new: queue handle is not passed to the packet proxy plugins in order to be able to drop/accept packets from within the callback (fixes #1202) --- modules/packet_proxy/packet_proxy_linux.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/packet_proxy/packet_proxy_linux.go b/modules/packet_proxy/packet_proxy_linux.go index e124976c..e69fe485 100644 --- a/modules/packet_proxy/packet_proxy_linux.go +++ b/modules/packet_proxy/packet_proxy_linux.go @@ -16,13 +16,15 @@ import ( "github.com/evilsocket/islazy/fs" ) +type hookFunc func(q *nfqueue.Nfqueue, a nfqueue.Attribute) int + type PacketProxy struct { session.SessionModule chainName string rule string queue *nfqueue.Nfqueue queueNum int - queueCb nfqueue.HookFunc + queueCb hookFunc pluginPath string plugin *plugin.Plugin } @@ -149,7 +151,7 @@ func (mod *PacketProxy) Configure() (err error) { return } else if sym, err = mod.plugin.Lookup("OnPacket"); err != nil { return - } else if mod.queueCb, ok = sym.(func(nfqueue.Attribute) int); !ok { + } else if mod.queueCb, ok = sym.(hookFunc); !ok { return fmt.Errorf("Symbol OnPacket is not a valid callback function.") } @@ -198,7 +200,7 @@ func (mod *PacketProxy) Configure() (err error) { // CGO callback ... ¯\_(ツ)_/¯ func dummyCallback(attribute nfqueue.Attribute) int { if mod.queueCb != nil { - return mod.queueCb(attribute) + return mod.queueCb(mod.queue, attribute) } else { id := *attribute.PacketID