mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
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)
This commit is contained in:
parent
da2292fbb7
commit
414d18a6da
1 changed files with 5 additions and 3 deletions
|
@ -16,13 +16,15 @@ import (
|
||||||
"github.com/evilsocket/islazy/fs"
|
"github.com/evilsocket/islazy/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type hookFunc func(q *nfqueue.Nfqueue, a nfqueue.Attribute) int
|
||||||
|
|
||||||
type PacketProxy struct {
|
type PacketProxy struct {
|
||||||
session.SessionModule
|
session.SessionModule
|
||||||
chainName string
|
chainName string
|
||||||
rule string
|
rule string
|
||||||
queue *nfqueue.Nfqueue
|
queue *nfqueue.Nfqueue
|
||||||
queueNum int
|
queueNum int
|
||||||
queueCb nfqueue.HookFunc
|
queueCb hookFunc
|
||||||
pluginPath string
|
pluginPath string
|
||||||
plugin *plugin.Plugin
|
plugin *plugin.Plugin
|
||||||
}
|
}
|
||||||
|
@ -149,7 +151,7 @@ func (mod *PacketProxy) Configure() (err error) {
|
||||||
return
|
return
|
||||||
} else if sym, err = mod.plugin.Lookup("OnPacket"); err != nil {
|
} else if sym, err = mod.plugin.Lookup("OnPacket"); err != nil {
|
||||||
return
|
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.")
|
return fmt.Errorf("Symbol OnPacket is not a valid callback function.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +200,7 @@ func (mod *PacketProxy) Configure() (err error) {
|
||||||
// CGO callback ... ¯\_(ツ)_/¯
|
// CGO callback ... ¯\_(ツ)_/¯
|
||||||
func dummyCallback(attribute nfqueue.Attribute) int {
|
func dummyCallback(attribute nfqueue.Attribute) int {
|
||||||
if mod.queueCb != nil {
|
if mod.queueCb != nil {
|
||||||
return mod.queueCb(attribute)
|
return mod.queueCb(mod.queue, attribute)
|
||||||
} else {
|
} else {
|
||||||
id := *attribute.PacketID
|
id := *attribute.PacketID
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue