Giter VIP home page Giter VIP logo

Comments (4)

dustin avatar dustin commented on July 29, 2024

Do you have a failing test case I can try?

from go-coap.

orian avatar orian commented on July 29, 2024

80 2 122 35 177 69 15 11 115 112 97 114 107 47 99 99 51 48 48 48 45 112 97 116 99 104 45 118 101 114 115 105 111 110 255 49 46 50 56

This are the bytes (received from Spark Core). ;-)

I think any valid message with token will do. It's not visible as long as one Marshal and Unmarshal using go-coap. But I deal with multilanguage system and this is how I've spot a problem.

Please compare:
http://tools.ietf.org/html/draft-ietf-core-coap-10#section-3
and
http://tools.ietf.org/html/rfc7252#section-3

The UnmarshalBinary reads tokenLen but never really reads the token:
https://github.com/dustin/go-coap/blob/master/message.go#L452

Somewhere after the line 455 you should add:
m.Token = make([]byte, tokenLen)
copy(m.Token, data[4:4+tokenLen])
b := data[4+tokenLen:]

I've also checked and the option parsing implements an old version of RFC.

BTW thanks for a library 👍

from go-coap.

orian avatar orian commented on July 29, 2024

I've integrated other's changes into my branch of your code. I've also fixed a memory leak. Unfortunately, the test are broken for now.

If you care, my repo is here, please consider pulling it: https://github.com/orian/go-coap

from go-coap.

dustin avatar dustin commented on July 29, 2024

The difference in parsing that data between what I've already got and your example seems negligible:

Before:

coap.Message{Type:0x1, Code:0x2, MessageID:0x7a23, Token:[]uint8(nil), Payload:[]uint8{0x31, 0x2e, 0x32, 0x38}, opts:coap.options{coap.option{ID:0xb, Value:"E"}, coap.option{ID:0xb, Value:"spark/cc3000-patch-version"}}}

After:

coap.Message{Type:0x1, Code:0x2, MessageID:0x7a23, Token:[]uint8{}, Payload:[]uint8{0x31, 0x2e, 0x32, 0x38}, opts:coap.options{coap.option{ID:0xb, Value:"E"}, coap.option{ID:0xb, Value:"spark/cc3000-patch-version"}}}

Do you have an example that uses tokens?

I'm open to bringing in your changes, but they're not quite done in the style I'm used to. i.e. merges, fixes, etc… How do you feel about an am+cleanup import of the changes? Authors keep their names, but merges and fixups would be removed.

from go-coap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.