Categorygithub.com/matrix-org/lb
modulepackage
0.0.0-20220825094957-51973560b225
Repository: https://github.com/matrix-org/lb.git
Documentation: pkg.go.dev

# README

Low Bandwidth Matrix

Go Reference

This repository implements MSC3079 in Go. It also provides several command line tools to get up to speed with existing low bandwidth enabled servers.

Mobile implementations

See mobile for Android/iOS bindings.

Command Line Tools

  • jc: This tool can be used to convert JSON <--> CBOR.
  • coap: This tool can be used to send a single CoAP request/response, similar to curl.
  • proxy: This tool can be used to add low bandwidth support to any Matrix homeserver.

These can be tied together to interact with low-bandwidth enabled Matrix servers. For example:

# convert inline JSON to CBOR then pipe into coap to localhost:8008 then convert the CBOR response back to JSON and print to stdout
./jc -out "-" '{"auth":{"type":"m.login.dummy"},"username":"foo","password":"barbarbar"}' \
| ./coap -X POST -d '-' -H "Content-Type: application/cbor" -k  https://localhost:8008/_matrix/client/r0/register \
| ./jc -c2j -out '-' '-'

# Packages

No description provided by the author

# Functions

CBORToJSONHandler transparently wraps JSON http handlers to accept and produce CBOR.
NewCBORCodec creates a CBOR codec which will map the enum keys given.
NewCBORCodecV1 creates a v1 codec capable of converting JSON <--> CBOR.
NewCoAPHTTP returns various mapping functions and a wrapped HTTP handler for transparently mapping to and from HTTP.
NewCoAPPath makes a CoAPPath with the path mappings given.
NewCoAPPathV1 creates CoAP enum path mappings for version 1.
NewObservations makes a new observations struct.
NewSyncObservations returns an Observations capable of processing Matrix /sync requests.

# Variables

The CoAP Option ID corresponding to the access_token for Matrix requests.

# Structs

CBORCodec allows the conversion between JSON and CBOR.
CoAPHTTP provides many ways to convert to and from HTTP/CoAP.
CoAPPath handles mapping to and from HTTP/CoAP paths The mapping function converts things like: /_matrix/client/r0/sync => /7 /_matrix/client/r0/user/@frank:localhost/account_data/im.vector.setting.breadcrumbs => /r/@frank:localhost/im.vector.setting.breadcrumbs All static path segments are folded down into a single URI friendly byte, then dynamic path segments are overlaid in the order they appear in the the full format.
Observations is capable of handling CoAP OBSERVE requests and handles long-polling http.Handler requests on the client's behalf.

# Interfaces

Logger is an interface which can be satisfied to print debug logging when things go wrong.

# Type aliases

HasUpdatedFn is a function which returns true if the responses indicate some form of change that the client should be notified about.
ObserveUpdateFn is a function which can update the long-poll request between calls.