From ef0a0dbe1f58a2c4a69a28eeb21349cefb673964 Mon Sep 17 00:00:00 2001 From: Tom Hunger Date: Sun, 25 Jan 2015 20:17:28 +0000 Subject: [PATCH] Update documentation. --- README.md | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 7e6a3cd..1f0ace3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ $ bin/gunicorn -k flask_sockets.worker sirius.server:app -b 0.0.0.0:5002 -w 1 Navigate browser to http://127.0.0.1:5002/ -## Creating fake printers +## Creating fake printers and friends Resetting the actual hardware all the time gets a bit tiresome so there's a fake command that creates unclaimed fake little printers: @@ -29,10 +29,20 @@ Created printer Functionally there is no difference between resetting and creating a new printer so we don't distinguish between the two. +To create a fake friend from twitter who signed up do this: + +```console +$ ./manage.py fake user stephenfry +``` + # Sirius Architecture ## Layers +The design is somewhat stratified: each layer only talks to the one +below and above. The ugliest bits are how database and protocol loop +interact. + ``` UI / database ---------------------------- @@ -54,39 +64,18 @@ the websocket/bridge_address mapping in a global dictionary; it then loops forever, decoding messages as they come in. -## Information flow (user-facing) - -So far we aren't sending any messages to the devices or bridges other -than encryption keys derived from claim codes (see below). - -In order to inject messages into the flow we need to look up a device -in the `connected_devices` member of -`sirius.protocol.protocol_loop.BridgeState`. If we found a matching -`BridgeState` we can use its websocket to send the message. - -As gunicorn spawns several processes we'll need to publish updates -over the process boundary which will probably necessitate a message -broker like redis. - - ## Claim codes Devices are associated with an account when a user enters a "claim code". This claim code contains a "hardware-xor" which is derived via -a lossy 3-byte hash from the device address. These codes are meant to -be used "timely", i.e. within a short window of the printer -reset. Hence collisions shouldn't be an issue. +a lossy 3-byte hash from the device address. The XOR-code for a device +is always the same even though the address changes! + +The claim codes are meant to be used "timely", i.e. within a short +window of the printer reset. If there are multiple, conflicting claim +codes we always pick the most recently created code. We are also deriving this hardware xor when a device calls home with an "encryption_key_required". In that case we connect the device to the claim code via the hardware-xor and send back the correct encryption key. - - -## TODO - -* Can't read images from the net because we're rendering a local file - with phantomjs. The way to fix is probably to run an in-process - web-server for the duration of rendering (urg). -* What to do with twitter users that have > 5000 followers? More - generally the UI becomes unusable. -- 2.47.3