Giter Site home page Giter Site logo

turt2live / matrix-appservice-iot-proxy Goto Github PK

View Code? Open in Web Editor NEW
7.0 5.0 0.0 21 KB

A proxy for the matrix client/server API to ensure users exist for a given appservice before attempting a call. Ideal for IoT scenarios.

License: MIT License

Go 100.00%
matrix iot appservice virtual device proxy client server api users

matrix-appservice-iot-proxy's Introduction

matrix-appservice-iot-proxy

#iotproxy:t2bot.io TravisCI badge

A proxy for the matrix client/server API to help offload some requirements from the client. This is written with IoT in mind where the client device is intended to have the appservice token and a user ID to use. The IoT device will not receive appservice traffic, however the device may safely make calls to the proxy without registering the user - the proxy will ensure the desired user is created.

Installing

Assuming Go 1.9 is already installed on your PATH:

# Get it
git clone https://github.com/turt2live/matrix-appservice-iot-proxy
cd matrix-appservice-iot-proxy

# Set up the build tools
currentDir=$(pwd)
export GOPATH="$currentDir/vendor/src:$currentDir/vendor:$currentDir:"$GOPATH
go get github.com/constabulary/gb/...
export PATH=$PATH":$currentDir/vendor/bin:$currentDir/vendor/src/bin"

# Build it
gb vendor restore
gb build

# Configure it (edit iot-proxy.yaml to meet your needs)
cp config.sample.yaml iot-proxy.yaml

# Run it
bin/matrix_iot_proxy

Example IoT Code

This project allows IoT devices to simplify their code, making sure that virtual users exist and have joined the room. For instance, consider a simple sensor (that happens to be powered by cURL) data logging device:

curl -X PUT -H "Content-Type: application/json" --data-binary '{"temperature":22,"units":"Celsius"}' 'http://my.iot.proxy.com:4232/_matrix/client/r0/rooms/!myroom:domain.com/send/com.custom.temperature/_txn_?access_token=YourAppserviceToken&[email protected]:domain.com'

Note how the IoT device does not need to register @.sensor.temperature:domain.com and it does not need to join !myroom:domain.com - both are handled automatically by this proxy. Please note that your IoT devices will need to have the appservice token, and therefore you'll need to register the appservice yourself.

The IoT Proxy will additionally replace _txn_ with a unique value when sending events so your devices do not need to track state. If you don't want to use this functionality, simply don't use the _txn_ keyword in your request.

matrix-appservice-iot-proxy's People

Contributors

turt2live avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

matrix-appservice-iot-proxy's Issues

Support templated transaction IDs for /send

This doesn't need to be complicated, but it does need to generate unique transactions that don't conflict. The idea would be that devices hardcode a namespace with some kind of template variable to be intercepted and replaced by the proxy to have the smallest chance of collisions.

For now, the easiest to probably just support milliseconds as a variable. Template-wise this could be just {time}.

If there's no template variables in the transaction ID, then we won't touch it.

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.