{"id":24991493,"url":"https://github.com/genmon/sirius","last_synced_at":"2025-04-12T02:05:07.849Z","repository":{"id":20671412,"uuid":"23954164","full_name":"genmon/sirius","owner":"genmon","description":null,"archived":false,"fork":false,"pushed_at":"2022-11-22T00:31:12.000Z","size":264,"stargazers_count":113,"open_issues_count":29,"forks_count":38,"subscribers_count":38,"default_branch":"master","last_synced_at":"2025-04-12T02:05:03.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/genmon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-12T09:09:57.000Z","updated_at":"2025-03-07T19:33:24.000Z","dependencies_parsed_at":"2022-09-03T10:11:54.436Z","dependency_job_id":null,"html_url":"https://github.com/genmon/sirius","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genmon%2Fsirius","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genmon%2Fsirius/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genmon%2Fsirius/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genmon%2Fsirius/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/genmon","download_url":"https://codeload.github.com/genmon/sirius/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505862,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T13:49:17.493Z","updated_at":"2025-04-12T02:05:07.814Z","avatar_url":"https://github.com/genmon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using Sirius\n\nFirst point your bridge at your laptop, port 5002 (or similar).\n\nThen run:\n\n```console\n$ bin/gunicorn -k flask_sockets.worker manage:app -b 0.0.0.0:5002 -w 1\n```\n\nNavigate browser to http://127.0.0.1:5002/\n\n\n## Environment variables\n\nThe server can be configured with the following variables:\n\n```\nTWITTER_CONSUMER_KEY=...\nTWITTER_CONSUMER_SECRET=...\nFLASK_CONFIG=...\n```\n\nFor dokku this means using e.g.:\n\n```\ndokku config:set sirius FLASK_CONFIG=heroku\ndokku config:set sirius TWITTER_CONSUMER_KEY=DdrpQ1uqKuQouwbCsC6OMA4oF\ndokku config:set sirius TWITTER_CONSUMER_SECRET=S8XGuhptJ8QIJVmSuIk7k8wv3ULUfMiCh9x1b19PmKSsBh1VDM\n```\n\n## Creating fake printers and friends\n\nResetting the actual hardware all the time gets a bit tiresome so\nthere's a fake command that creates unclaimed fake little printers:\n\n```console\n$ ./manage.py fake printer\n[...]\nCreated printer\n     address: 602d48d344b746f5\n       DB id: 8\n      secret: 66a596840f\n  claim code: 5oop-e9dp-hh7v-fjqo\n```\n\nFunctionally there is no difference between resetting and creating a new printer so we don't distinguish between the two.\n\nTo create a fake friend from twitter who signed up do this:\n\n```console\n$ ./manage.py fake user stephenfry\n```\n\nYou can also claim a printer in somebody else's name:\n\n```console\n$ ./manage.py fake claim b7235a2b432585eb quentinsf 342f-eyh0-korc-msej testprinter\n```\n\n# Sirius Architecture\n\n## Layers\n\nThe design is somewhat stratified: each layer only talks to the one\nbelow and above. The ugliest bits are how database and protocol loop\ninteract.\n\n```\nUI / database\n----------------------------\nprotocol_loop / send_message\n----------------------------\nencoders / decoders\n----------------------------\nwebsockets\n----------------------------\n```\n\n## Information flow (websockets)\n\nThe entry point for the bridge is in `sirius.web.webapp`. Each new\nwebsocket connection spawns a gevent thread (specified by running the\nflask_sockets gunicorn worker) which runs\n`sirius.protocol.protocol_loop.accept` immediately. `accept` registers\nthe websocket/bridge_address mapping in a global dictionary; it then\nloops forever, decoding messages as they come in.\n\n\n## Claim codes\n\nDevices are associated with an account when a user enters a \"claim\ncode\". This claim code contains a \"hardware-xor\" which is derived via\na lossy 3-byte hash from the device address. The XOR-code for a device\nis always the same even though the address changes!\n\nThe claim codes are meant to be used \"timely\", i.e. within a short\nwindow of the printer reset. If there are multiple, conflicting claim\ncodes we always pick the most recently created code.\n\nWe are also deriving this hardware xor when a device calls home with\nan \"encryption_key_required\". In that case we connect the device to\nthe claim code via the hardware-xor and send back the correct\nencryption key.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenmon%2Fsirius","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenmon%2Fsirius","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenmon%2Fsirius/lists"}