zubairhamed / canopus

CoAP Client/Server implementing RFC 7252 for the Go Language
Apache License 2.0
154 stars 41 forks source link

DTLS example out of date? #88

Closed ptone closed 7 years ago

ptone commented 7 years ago

The current DTLS sample uses:

req := canopus.NewRequest(canopus.MessageConfirmable, canopus.Get, canopus.GenerateMessageID())

Which gives:

# command-line-arguments ./client.go:15: too many arguments in call to canopus.NewRequest have (number, canopus.CoapCode, uint16) want (uint8, canopus.CoapCode)

The "simple" example, which works, has:

req := canopus.NewRequest(canopus.MessageConfirmable, canopus.Get)

But updating the dtls example to use the same NewRequest syntax results in: `[signal SIGSEGV: segmentation violation code=0x1 addr=0xe0 pc=0x7f12183f3c1b]

runtime stack: runtime.throw(0x6c2ccb, 0x2a) /usr/local/go/src/runtime/panic.go:596 +0x95 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:274 +0x2db

goroutine 1 [syscall, locked to thread]: runtime.cgocall(0x62b660, 0xc420049c58, 0xc420011438) /usr/local/go/src/runtime/cgocall.go:131 +0xe2 fp=0xc420049c28 sp=0xc420049be8 github.com/zubairhamed/canopus._Cfunc_SSL_connect(0x1633c60, 0x0) github.com/zubairhamed/canopus/_obj/_cgo_gotypes.go:379 +0x49 fp=0xc420049c58 sp=0xc420049c28 github.com/zubairhamed/canopus.(DTLSConnection).connect.func1(0x1633c60, 0x0) /home/ptone/go/src/github.com/zubairhamed/canopus/dtls.go:763 +0x60 fp=0xc420049c90 sp=0xc420049c58 github.com/zubairhamed/canopus.(DTLSConnection).connect(0xc4200147d0, 0x0, 0x0) /home/ptone/go/src/github.com/zubairhamed/canopus/dtls.go:763 +0x2f fp=0xc420049cc0 sp=0xc420049c90 github.com/zubairhamed/canopus.(DTLSConnection).Write(0xc4200147d0, 0xc42004c2c0, 0x21, 0x40, 0x40, 0x0, 0x0) /home/ptone/go/src/github.com/zubairhamed/canopus/dtls.go:708 +0xfe fp=0xc420049d10 sp=0xc420049cc0 github.com/zubairhamed/canopus.(DTLSConnection).sendMessage(0xc4200147d0, 0x9dffe0, 0xc420014820, 0x0, 0xc420049e80, 0x612e50, 0x6840e0) /home/ptone/go/src/github.com/zubairhamed/canopus/dtls.go:674 +0x2a8 fp=0xc420049de0 sp=0xc420049d10 github.com/zubairhamed/canopus.(*DTLSConnection).Send(0xc4200147d0, 0x9defa0, 0xc420017470, 0x7, 0x6b8f42, 0x9, 0x9de600) /home/ptone/go/src/github.com/zubairhamed/canopus/dtls.go:653 +0x5ba fp=0xc420049ec8 sp=0xc420049de0 main.main() /home/ptone/go/src/github.com/zubairhamed/canopus/examples/dtls/simple-psk/client.go:21 +0x128 fp=0xc420049f88 sp=0xc420049ec8 runtime.main() /usr/local/go/src/runtime/proc.go:185 +0x20a fp=0xc420049fe0 sp=0xc420049f88 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc420049fe8 sp=0xc420049fe0

goroutine 17 [syscall, locked to thread]: runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1`

ptone commented 7 years ago

Interestingly - I was able to get the updated syntax to work when I rebuilt the libssl.so from the OpenSSL_1_1_0-stable openssl branch