tree: e32a97d262be411714dd1a69bac78422bde96007 [path history] [tgz]
  1. tpl/
  2. BUILD.bazel
  3. locker.go
  4. main.go
  5. proxy.go
  6. README.md
hswaw/laserproxy/README.md

hswaw ruida laser proxy

This is a layer 7 proxy to access the Warsaw Hackerspace laser from the main LAN/wifi.

For more information about actually accessing the lasercutter in the space, see the wiki entry. The rest of this file will describe the software itself.

Architecture

The laserproxy software is a single Go binary that runs on Customs, which has access to both the Hackerspace LAN and the laser network. It proxies UDP traffic from lasercutter users to the lasercutter itself.

Only one user is allowed at a time - to implement this mutual exclusion, a Locker worker manages a single (address, note) tuple that is currently allowed to proxy traffic, and to which return traffic is forwarded back. The Locker also maintians a deadline. After the deadline expires, the lock is automatically released. A user can also release their lock ahead of time.

A lock is taken through a web interface by the user that wants to access the laser.

When a lock is taken, the Locker will notify a Proxy worker about this address. The Proxy will then perform the UDP proxying. As traffic is proxied, the Proxy will send bump updates to the Locker to extend the lock deadline.

Development setup


Something similar to this should work for you locally enough to open the web app:

bazel run //hswaw/laserproxy -- -hspki_disable -laser_network 127.0.0.1 -client_network 127.0.0.1

This will show you available flags you can pass:

bazel run //hswaw/laserproxy -- -h

If you've never used bazel, this should work for y'all macOS newbs:

brew install bazel
brew install postgresql

TODO(q3k): move this to the bazel codelab once it's finished

Deployment

You'll need root access to customs.

bazel build --platforms=@io_bazel_rules_go//go/toolchain:openbsd_amd64 //hswaw/laserproxy
ssh root@customs supervisorctl stop laserproxy
scp bazel-bin/hswaw/laserproxy/laserproxy_/laserproxy root@customs:/var/laserproxy/laserproxy
ssh root@customs supervisorctl start laserproxy