nfqueue-go icon indicating copy to clipboard operation
nfqueue-go copied to clipboard

Setting callback to method of a type

Open arun1587 opened this issue 8 years ago • 2 comments

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

arun1587 avatar Jul 27 '17 20:07 arun1587

Go tthe same problem. Any solution?

lstep avatar Jul 16 '18 06:07 lstep

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.

arun1587 avatar Jul 18 '18 19:07 arun1587