nfqueue-go
nfqueue-go copied to clipboard
Setting callback to method of a type
Hi all, Is it possible to have a callback method which is of any specific type? example:
type nfqCallback struct {
pool *redis.Pool
}
func(n nfqCallback) real_callback(payload *nfqueue.Payload) int {
// access the pool here
}
// some where in main
w := nfqCallback{pool: p}
queue.SetCallback(w.real_callback)
I tried to run the code but it panic'ed with the following trace.
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 10 [running]:
panic(0x995e40, 0xc42120ecc0)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
bitbucket.org/acklio/vdm/vendor/github.com/chifflier/nfqueue-go/nfqueue._cgoCheckPointer0(0xc4212122a0, 0x0, 0x0, 0x0, 0x0)
??:0 +0x59
bitbucket.org/acklio/vdm/vendor/github.com/chifflier/nfqueue-go/nfqueue.(*Queue).CreateQueue(0xc4212122a0, 0x0, 0x0, 0x0)
/home/arun/work/src/bitbucket.org/acklio/vdm/vendor/github.com/chifflier/nfqueue-go/nfqueue/nfqueue.go:165 +0x155
Go tthe same problem. Any solution?
well, I used github.com/AkihiroSuda/go-netfilter-queue implementation which extracts the packets from nfqueue to a channel, and from there it is quite flexible.