Skip to content

Proper CoAP abstraction to match matrix-org/go-coap #3

@ShadowJonathan

Description

@ShadowJonathan

There seems to be sparse support for specific CoAP clients that matches matrix-org/go-coap, which has the following clauses;

This is the matrix.org fork of go-coap, specialised for MSC3079. There are several reasons to fork the original implementation:

  • FIN packet handling is easier to do at the go-coap level, and is matrix.org specific. See these comments for context.
  • We were hitting many known issues with the original implementation around retry handling, congestion control (NSTART handling), accessing MIDs on UDP messages, etc.
  • We want to add WebSockets support.

This repo was originally forked from an even earlier implementation for FOSDEM 2019, but this new work is based on v2.4.0.

The go-coap provides servers and clients for DTLS, TCP-TLS, UDP, TCP in golang.

coap currently supports only plain UDP, Covertness/coap-rs#57 attempts to add DTLS to that. (for Covertness/coap-rs#16)

udp_dtls exists, but has last been updated in 2019 (and uses openssl)

rustls doesn't have DTLS support at the moment, but wants to implement it after DTLS 1.3 nears completion (rustls/rustls#40)


The goal here is to have a CoAP implementation that "just works", doesn't block (and hopefully also neatly integrate with tokio/async), takes some notes from what the matrix.org team encountered when first experimenting with dtls+coap, and remove as many footguns and "leftovers" as possible (sending DTLS close on drop, etc.).

This'd probably mean forking repos and tracking commits in Cargo.toml, i'll fork the repos under my own namespace for the moment, until there's enough interest to move it to ruma's.

This'll be the case until probably rustls supports DTLS, but we also have to be ready for a pure openssl-based implementation.


So, my proposal is this; make a sub-module (or crate) named ruma-lb-coap/ruma_lb::coap that wraps and fixes all of these problems into an abstract and manageable interface, with exclusive features openssl and later rustls to have dependent crates select which backend to use.

Have a CoAPClient in there, intended for internal plumbing (for now), that is able to open and close CoAPClientSessions to endpoints.

The same happens for servers; CoAPServer and CoAPServerSession.

So in the end, it'd look something like this;

LowBandwidthClient -> CoAPClient -> CoAPClientSession -> <DTLS>

LowBandwidthServer <- CoAPServer <- CoAPServerSession <- <DTLS>

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions