From 857e0584d19e0abbc9f73a7ea9aea24be6a6786e Mon Sep 17 00:00:00 2001 From: hyperion Date: Fri, 30 Oct 2020 12:00:11 +0100 Subject: Refactoring repository structure and building basic nix module --- README.md | 46 ++- brook-metrics/.gitignore | 1 - brook-metrics/Cargo.lock | 767 ---------------------------------------------- brook-metrics/Cargo.toml | 16 - brook-metrics/build | 3 - brook-metrics/metrics.csv | 52 ---- brook-metrics/shell.nix | 6 - brook-metrics/src/main.rs | 152 --------- docs/logo.png | Bin 0 -> 92035 bytes docs/logo.svg | 67 ++++ index.html | 97 ------ logo.png | Bin 92035 -> 0 bytes logo.svg | 67 ---- metrics/.gitignore | 1 + metrics/Cargo.lock | 767 ++++++++++++++++++++++++++++++++++++++++++++++ metrics/Cargo.toml | 16 + metrics/build | 3 + metrics/metrics.csv | 141 +++++++++ metrics/shell.nix | 6 + metrics/src/main.rs | 154 ++++++++++ nix/dash.nix | 44 +++ nix/default.nix | 10 + nix/metrics.nix | 30 ++ nix/nginx.nix | 57 ++++ nix/prosody.nix | 60 ++++ static/ajax.min.js | 2 - static/main.css | 69 ----- static/test-video.webm | Bin 4685023 -> 0 bytes web/default.nix | 6 + web/index.html | 96 ++++++ web/static/ajax.min.js | 2 + web/static/main.css | 69 +++++ 32 files changed, 1574 insertions(+), 1233 deletions(-) delete mode 100644 brook-metrics/.gitignore delete mode 100644 brook-metrics/Cargo.lock delete mode 100644 brook-metrics/Cargo.toml delete mode 100644 brook-metrics/build delete mode 100644 brook-metrics/metrics.csv delete mode 100644 brook-metrics/shell.nix delete mode 100644 brook-metrics/src/main.rs create mode 100644 docs/logo.png create mode 100644 docs/logo.svg delete mode 100644 index.html delete mode 100644 logo.png delete mode 100644 logo.svg create mode 100644 metrics/.gitignore create mode 100644 metrics/Cargo.lock create mode 100644 metrics/Cargo.toml create mode 100644 metrics/build create mode 100644 metrics/metrics.csv create mode 100644 metrics/shell.nix create mode 100644 metrics/src/main.rs create mode 100644 nix/dash.nix create mode 100644 nix/default.nix create mode 100644 nix/metrics.nix create mode 100644 nix/nginx.nix create mode 100644 nix/prosody.nix delete mode 100755 static/ajax.min.js delete mode 100644 static/main.css delete mode 100644 static/test-video.webm create mode 100644 web/default.nix create mode 100644 web/index.html create mode 100755 web/static/ajax.min.js create mode 100644 web/static/main.css diff --git a/README.md b/README.md index 5e34d98..8d092fb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@
- +

brook

@@ -21,3 +21,47 @@ setup. Following is a quick overview of components. viewer metrics * `prosody` - An XMPP server to back the chat room + +## Configuration + +I'm running my brook instance on NixOS, and as such a lot of the +configuration is Nix specific. For other linux distributions, or to +consider a reference implementation for other systems, check the +[`common`](./common) directory. + +### NixOS + +If you are already running an nginx, or prosody, you will have to +manually integrate [`nix`](./nix) into your configuration. In case +you don't, you can simply include the whole module. + +```nix +imports = [ + /path/to/brook/nix +]; +``` + +Then you can use the various `brook` submodules to configure your +streaming setup. If you want to use XMPP chats, you need to configure +prosody yourself - `brook` will only setup the anonymous user virtualhost +to be used by the brook-web chat. + +```nix +services.brook = { + nginx = { + enable = true; + hostAddr = "stream.spacekookie.de"; + acmeHost = "spacekookie.de"; + }; + + prosody = { + enable = true; + certRoot = "/var/lib/acme/spacekookie.de"; + }; + + dash = { + enable = true; + name = "kookie.tv"; + }; +}; +``` diff --git a/brook-metrics/.gitignore b/brook-metrics/.gitignore deleted file mode 100644 index ea8c4bf..0000000 --- a/brook-metrics/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/brook-metrics/Cargo.lock b/brook-metrics/Cargo.lock deleted file mode 100644 index 853c1ee..0000000 --- a/brook-metrics/Cargo.lock +++ /dev/null @@ -1,767 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "arc-swap" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "brook-metrics" -version = "0.1.0" -dependencies = [ - "chrono", - "hyper", - "json", - "lazy_static", - "ratman-identity", - "tokio", -] - -[[package]] -name = "bytes" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time", - "winapi 0.3.9", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures-channel" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0448174b01148032eed37ac4aed28963aaaa8cfa93569a08e5b479bbc6c2c151" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18eaa56102984bed2c88ea39026cff3ce3b4c7f508ca970cedf2450ea10d4e46" - -[[package]] -name = "futures-sink" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e3ca3f17d6e8804ae5d3df7a7d35b2b3a6fe89dac84b31872720fc3060a0b11" - -[[package]] -name = "futures-task" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d502af37186c4fef99453df03e374683f8a1eec9dcc1e66b3b82dc8278ce3c" - -[[package]] -name = "futures-util" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abcb44342f62e6f3e8ac427b8aa815f724fd705dfad060b18ac7866c15bb8e34" -dependencies = [ - "futures-core", - "futures-task", - "pin-project 1.0.1", - "pin-utils", -] - -[[package]] -name = "getrandom" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "h2" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", - "tracing-futures", -] - -[[package]] -name = "hashbrown" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" - -[[package]] -name = "hermit-abi" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" -dependencies = [ - "libc", -] - -[[package]] -name = "hex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" - -[[package]] -name = "http" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "httparse" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" - -[[package]] -name = "httpdate" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" - -[[package]] -name = "hyper" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f3afcfae8af5ad0576a31e768415edb627824129e8e5a29b8bfccb2f234e835" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project 0.4.27", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "indexmap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "itoa" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" - -[[package]] -name = "json" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" - -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "memchr" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" - -[[package]] -name = "mio" -version = "0.6.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" -dependencies = [ - "cfg-if", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow 0.2.1", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-named-pipes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" -dependencies = [ - "log", - "mio", - "miow 0.3.5", - "winapi 0.3.9", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "miow" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" -dependencies = [ - "socket2", - "winapi 0.3.9", -] - -[[package]] -name = "net2" -version = "0.2.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" -dependencies = [ - "cfg-if", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "num-integer" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "pin-project" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" -dependencies = [ - "pin-project-internal 0.4.27", -] - -[[package]] -name = "pin-project" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee41d838744f60d959d7074e3afb6b35c7456d0f61cad38a24e35e6553f73841" -dependencies = [ - "pin-project-internal 1.0.1", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a4ffa594b66bff340084d4081df649a7dc049ac8d7fc458d8e628bfbbb2f86" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "ppv-lite86" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" - -[[package]] -name = "proc-macro2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "quote" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - -[[package]] -name = "ratman-identity" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463e8a9937dd2525717feb9f85fbf5da115076eb812b894e255d6ce00bdda289" -dependencies = [ - "cfg-if", - "hex", - "rand", - "serde", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "serde" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "signal-hook-registry" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035" -dependencies = [ - "arc-swap", - "libc", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "socket2" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "winapi 0.3.9", -] - -[[package]] -name = "syn" -version = "1.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", -] - -[[package]] -name = "tokio" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "iovec", - "lazy_static", - "libc", - "memchr", - "mio", - "mio-named-pipes", - "mio-uds", - "num_cpus", - "pin-project-lite", - "signal-hook-registry", - "slab", - "tokio-macros", - "winapi 0.3.9", -] - -[[package]] -name = "tokio-macros" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-util" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tower-service" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" - -[[package]] -name = "tracing" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" -dependencies = [ - "cfg-if", - "log", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tracing-futures" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" -dependencies = [ - "pin-project 0.4.27", - "tracing", -] - -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] diff --git a/brook-metrics/Cargo.toml b/brook-metrics/Cargo.toml deleted file mode 100644 index a19ccfc..0000000 --- a/brook-metrics/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "brook-metrics" -description = "A server to handle brook metric reporting" -version = "0.1.0" -authors = ["Mx Kookie "] -edition = "2018" - -[dependencies] -ratman-identity = { version = "*", features = ["random", "aligned"] } -chrono = "0.4" -hyper = "0.13" -json = "0.12" -lazy_static = "1.0" - -#TODO: remove this when async-h2 comes out -tokio = { version = "0.2", features = ["full"] } \ No newline at end of file diff --git a/brook-metrics/build b/brook-metrics/build deleted file mode 100644 index 67e8e8a..0000000 --- a/brook-metrics/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -nix-shell --run "cargo build" \ No newline at end of file diff --git a/brook-metrics/metrics.csv b/brook-metrics/metrics.csv deleted file mode 100644 index cf55087..0000000 --- a/brook-metrics/metrics.csv +++ /dev/null @@ -1,52 +0,0 @@ -2020-10-30_04:26:57 UTC,0 -2020-10-30_04:27:12 UTC,2 -2020-10-30_04:27:27 UTC,2 -2020-10-30_04:27:42 UTC,2 -2020-10-30_04:27:57 UTC,2 -2020-10-30_04:28:12 UTC,2 -2020-10-30_04:28:27 UTC,1 -2020-10-30_04:39:47 UTC,0 -2020-10-30_04:40:02 UTC,1 -2020-10-30_04:40:17 UTC,1 -2020-10-30_04:40:32 UTC,1 -2020-10-30_04:40:47 UTC,2 -2020-10-30_04:41:02 UTC,2 -2020-10-30_04:41:17 UTC,2 -2020-10-30_04:41:32 UTC,2 -2020-10-30_04:41:47 UTC,2 -2020-10-30_04:42:04 UTC,0 -2020-10-30_04:42:19 UTC,2 -2020-10-30_04:42:34 UTC,2 -2020-10-30_04:42:49 UTC,2 -2020-10-30_04:43:04 UTC,2 -2020-10-30_04:43:19 UTC,2 -2020-10-30_04:43:34 UTC,2 -2020-10-30_04:43:49 UTC,2 -2020-10-30_04:44:04 UTC,2 -2020-10-30_04:44:19 UTC,2 -2020-10-30_04:44:54 UTC,0 -2020-10-30_04:45:09 UTC,2 -2020-10-30_04:46:15 UTC,0 -2020-10-30_04:46:30 UTC,2 -2020-10-30_04:46:45 UTC,2 -2020-10-30_04:46:57 UTC,0 -2020-10-30_04:47:12 UTC,2 -2020-10-30_04:47:27 UTC,3 -2020-10-30_04:55:41 UTC,0 -2020-10-30_04:55:56 UTC,1 -2020-10-30_04:56:11 UTC,1 -2020-10-30_05:00:45 UTC,0 -2020-10-30_05:01:00 UTC,0 -2020-10-30_05:01:15 UTC,0 -2020-10-30_05:01:30 UTC,0 -2020-10-30_05:01:45 UTC,0 -2020-10-30_05:02:00 UTC,0 -2020-10-30_05:02:15 UTC,0 -2020-10-30_05:02:42 UTC,0 -2020-10-30_05:02:57 UTC,1 -2020-10-30_05:03:12 UTC,3 -2020-10-30_05:04:15 UTC,0 -2020-10-30_05:04:30 UTC,1 -2020-10-30_05:04:45 UTC,1 -2020-10-30_05:05:00 UTC,2 -2020-10-30_05:05:15 UTC,2 diff --git a/brook-metrics/shell.nix b/brook-metrics/shell.nix deleted file mode 100644 index 2fa04ad..0000000 --- a/brook-metrics/shell.nix +++ /dev/null @@ -1,6 +0,0 @@ -with import {}; - -stdenv.mkDerivation { - name = "brook-metrics"; - buildInputs = with pkgs; [ rustup clangStdenv ]; -} diff --git a/brook-metrics/src/main.rs b/brook-metrics/src/main.rs deleted file mode 100644 index 649ddd9..0000000 --- a/brook-metrics/src/main.rs +++ /dev/null @@ -1,152 +0,0 @@ -use chrono::Utc; -use hyper::{ - service::{make_service_fn, service_fn}, - Body, Method, Request, Response, Server, StatusCode, -}; -use lazy_static::lazy_static; -use ratman_identity::Identity; -use std::{ - collections::BTreeMap, - convert::Infallible, - env, - fs::OpenOptions, - io::Write, - net::SocketAddr, - path::PathBuf, - sync::{ - atomic::{AtomicUsize, Ordering}, - Mutex, - }, - thread, - time::Duration, -}; - -lazy_static! { - static ref STATE: Mutex> = Mutex::new(BTreeMap::new()); -} - -/// An entry of metrics data -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] -struct MetricEntry {} - -fn dump_metrics() { - let p = env::var("BROOK_METRICS_PATH").unwrap_or("metrics.csv".into()); - let path = PathBuf::new().join(p); - - loop { - let time = Utc::now(); - let mut map = STATE.lock().unwrap(); - let metrics: Vec<()> = map.iter().map(|_| ()).collect(); - map.clear(); - drop(map); - - let line = format!( - "{},{}\n", - time.format("%Y-%m-%d_%H:%M:%S UTC"), - metrics.len(), - ); - let mut file = OpenOptions::new() - .write(true) - .append(true) - .create(true) - .open(&path) - .unwrap(); - - file.write_all(line.as_bytes()).unwrap(); - - // Wait for a while before doing it again - thread::sleep(Duration::from_secs(15)); - } -} - -fn get() -> Result, Infallible> { - let mut resp = Response::new(Body::empty()); - *resp.body_mut() = Body::from( - " - -brook-metrics - -

-Your brook-metrics server is now reachable! \ -Point your brook clients towards $ADDR/report -

- -", - ); - - Ok(resp) -} - -async fn post(req: Request) -> Result, Infallible> { - let full_body = hyper::body::to_bytes(req.into_body()).await.unwrap(); - let body_str = String::from_utf8(full_body.to_vec()).unwrap(); - - let parsed = json::parse(&body_str).unwrap(); - - // Either get the ID or create a new one - let id = match parsed { - json::JsonValue::Object(mut obj) => obj.remove("id"), - _ => unreachable!(), - } - .map(|jv| match jv { - json::JsonValue::String(ref s) => Identity::from_string(s), - _ => unreachable!(), - }) - .map(|id| { - eprintln!("[DEBUG] Returning client {}", id); - id - }) - .unwrap_or_else(|| { - eprintln!("[DEBUG] Adding new stream client!"); - Identity::random() - }); - - STATE.lock().unwrap().insert(id, MetricEntry {}); - - Ok(Response::builder() - .header("Content-Type", "text/json") - .status(StatusCode::OK) - .body(Body::from(format!("{{ \"id\": \"{}\" }}", id.to_string()))) - .unwrap()) -} - -fn get_current() -> Result, Infallible> { - let len = STATE.lock().unwrap().len(); - Ok(Response::builder() - .header("Content-Type", "text/json") - .status(StatusCode::OK) - .body(Body::from(format!("{{ \"num\": {} }}", len))) - .unwrap()) -} - -async fn handle_request(req: Request) -> Result, Infallible> { - match (req.method(), req.uri().path()) { - // TODO: make this prefix configurable - (&Method::GET, "/metrics") => get(), - (&Method::GET, "/metrics/current") => get_current(), - (&Method::POST, "/metrics/update") => post(req).await, - _ => { - let resp = Response::builder() - .status(StatusCode::NOT_FOUND) - .body(Body::from("Nothing here, I'm afraid!")) - .unwrap(); - - Ok(resp) - } - } -} - -#[tokio::main] -async fn main() { - thread::spawn(|| dump_metrics()); - - let addr = SocketAddr::from(([0, 0, 0, 0], 7667)); - let service = make_service_fn(|_c| async { Ok::<_, Infallible>(service_fn(handle_request)) }); - - eprintln!("Bindng address: 0.0.0.0:7667"); - let server = Server::bind(&addr).serve(service); - - if let Err(e) = server.await { - eprintln!("[ERROR]: {}", e); - } -} diff --git a/docs/logo.png b/docs/logo.png new file mode 100644 index 0000000..c2404d1 Binary files /dev/null and b/docs/logo.png differ diff --git a/docs/logo.svg b/docs/logo.svg new file mode 100644 index 0000000..69ab078 --- /dev/null +++ b/docs/logo.svg @@ -0,0 +1,67 @@ + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/index.html b/index.html deleted file mode 100644 index 5eb8fac..0000000 --- a/index.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - stream.spacekookie.de - - - - - - - - - - -
-

stream.spacekookie.de

-

OFFLINE

- -
- - -
-

Welcome to the stream! ✨

-

- The stream chat is backed by an XMPP - room: stream@rooms.spacekookie.de — Feel free to join - it from your favourite XMPP client to say hello! -

-
- -
- - -
-
-
-
- -
-

Viewers: ?

-
- - - - - - diff --git a/logo.png b/logo.png deleted file mode 100644 index c2404d1..0000000 Binary files a/logo.png and /dev/null differ diff --git a/logo.svg b/logo.svg deleted file mode 100644 index 69ab078..0000000 --- a/logo.svg +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - diff --git a/metrics/.gitignore b/metrics/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/metrics/.gitignore @@ -0,0 +1 @@ +/target diff --git a/metrics/Cargo.lock b/metrics/Cargo.lock new file mode 100644 index 0000000..290b8a0 --- /dev/null +++ b/metrics/Cargo.lock @@ -0,0 +1,767 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "arc-swap" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "brook-metrics" +version = "0.1.0" +dependencies = [ + "chrono", + "hyper", + "json", + "lazy_static", + "ratman-identity", + "tokio", +] + +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time", + "winapi 0.3.9", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures-channel" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0448174b01148032eed37ac4aed28963aaaa8cfa93569a08e5b479bbc6c2c151" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18eaa56102984bed2c88ea39026cff3ce3b4c7f508ca970cedf2450ea10d4e46" + +[[package]] +name = "futures-sink" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e3ca3f17d6e8804ae5d3df7a7d35b2b3a6fe89dac84b31872720fc3060a0b11" + +[[package]] +name = "futures-task" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d502af37186c4fef99453df03e374683f8a1eec9dcc1e66b3b82dc8278ce3c" + +[[package]] +name = "futures-util" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abcb44342f62e6f3e8ac427b8aa815f724fd705dfad060b18ac7866c15bb8e34" +dependencies = [ + "futures-core", + "futures-task", + "pin-project 1.0.1", + "pin-utils", +] + +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "h2" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", + "tracing-futures", +] + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "hermit-abi" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" + +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" + +[[package]] +name = "httpdate" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" + +[[package]] +name = "hyper" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3afcfae8af5ad0576a31e768415edb627824129e8e5a29b8bfccb2f234e835" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project 0.4.27", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "indexmap" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" + +[[package]] +name = "json" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" + +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "mio" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +dependencies = [ + "cfg-if", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow 0.2.1", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-named-pipes" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" +dependencies = [ + "log", + "mio", + "miow 0.3.5", + "winapi 0.3.9", +] + +[[package]] +name = "mio-uds" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" +dependencies = [ + "iovec", + "libc", + "mio", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "miow" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +dependencies = [ + "socket2", + "winapi 0.3.9", +] + +[[package]] +name = "net2" +version = "0.2.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" +dependencies = [ + "cfg-if", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "pin-project" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" +dependencies = [ + "pin-project-internal 0.4.27", +] + +[[package]] +name = "pin-project" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee41d838744f60d959d7074e3afb6b35c7456d0f61cad38a24e35e6553f73841" +dependencies = [ + "pin-project-internal 1.0.1", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a4ffa594b66bff340084d4081df649a7dc049ac8d7fc458d8e628bfbbb2f86" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "ratman-identity" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea478515f7e7c6be14890da4a68f7eac07c3e2f395ddc4d855e9d39f773f2783" +dependencies = [ + "cfg-if", + "hex", + "rand", + "serde", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "serde" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "signal-hook-registry" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035" +dependencies = [ + "arc-swap", + "libc", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "socket2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.9", +] + +[[package]] +name = "syn" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi 0.3.9", +] + +[[package]] +name = "tokio" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "iovec", + "lazy_static", + "libc", + "memchr", + "mio", + "mio-named-pipes", + "mio-uds", + "num_cpus", + "pin-project-lite", + "signal-hook-registry", + "slab", + "tokio-macros", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-macros" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + +[[package]] +name = "tracing" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tracing-futures" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" +dependencies = [ + "pin-project 0.4.27", + "tracing", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] diff --git a/metrics/Cargo.toml b/metrics/Cargo.toml new file mode 100644 index 0000000..93ea887 --- /dev/null +++ b/metrics/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "brook-metrics" +description = "A server to handle brook metric reporting" +version = "0.1.0" +authors = ["Mx Kookie "] +edition = "2018" + +[dependencies] +ratman-identity = { version = "0.5", features = ["random"] } +chrono = "0.4" +hyper = "0.13" +json = "0.12" +lazy_static = "1.0" + +#TODO: remove this when async-h2 comes out +tokio = { version = "0.2", features = ["full"] } \ No newline at end of file diff --git a/metrics/build b/metrics/build new file mode 100644 index 0000000..67e8e8a --- /dev/null +++ b/metrics/build @@ -0,0 +1,3 @@ +#!/bin/sh + +nix-shell --run "cargo build" \ No newline at end of file diff --git a/metrics/metrics.csv b/metrics/metrics.csv new file mode 100644 index 0000000..7a323b2 --- /dev/null +++ b/metrics/metrics.csv @@ -0,0 +1,141 @@ +2020-10-30_04:26:57 UTC,0 +2020-10-30_04:27:12 UTC,2 +2020-10-30_04:27:27 UTC,2 +2020-10-30_04:27:42 UTC,2 +2020-10-30_04:27:57 UTC,2 +2020-10-30_04:28:12 UTC,2 +2020-10-30_04:28:27 UTC,1 +2020-10-30_04:39:47 UTC,0 +2020-10-30_04:40:02 UTC,1 +2020-10-30_04:40:17 UTC,1 +2020-10-30_04:40:32 UTC,1 +2020-10-30_04:40:47 UTC,2 +2020-10-30_04:41:02 UTC,2 +2020-10-30_04:41:17 UTC,2 +2020-10-30_04:41:32 UTC,2 +2020-10-30_04:41:47 UTC,2 +2020-10-30_04:42:04 UTC,0 +2020-10-30_04:42:19 UTC,2 +2020-10-30_04:42:34 UTC,2 +2020-10-30_04:42:49 UTC,2 +2020-10-30_04:43:04 UTC,2 +2020-10-30_04:43:19 UTC,2 +2020-10-30_04:43:34 UTC,2 +2020-10-30_04:43:49 UTC,2 +2020-10-30_04:44:04 UTC,2 +2020-10-30_04:44:19 UTC,2 +2020-10-30_04:44:54 UTC,0 +2020-10-30_04:45:09 UTC,2 +2020-10-30_04:46:15 UTC,0 +2020-10-30_04:46:30 UTC,2 +2020-10-30_04:46:45 UTC,2 +2020-10-30_04:46:57 UTC,0 +2020-10-30_04:47:12 UTC,2 +2020-10-30_04:47:27 UTC,3 +2020-10-30_04:55:41 UTC,0 +2020-10-30_04:55:56 UTC,1 +2020-10-30_04:56:11 UTC,1 +2020-10-30_05:00:45 UTC,0 +2020-10-30_05:01:00 UTC,0 +2020-10-30_05:01:15 UTC,0 +2020-10-30_05:01:30 UTC,0 +2020-10-30_05:01:45 UTC,0 +2020-10-30_05:02:00 UTC,0 +2020-10-30_05:02:15 UTC,0 +2020-10-30_05:02:42 UTC,0 +2020-10-30_05:02:57 UTC,1 +2020-10-30_05:03:12 UTC,3 +2020-10-30_05:04:15 UTC,0 +2020-10-30_05:04:30 UTC,1 +2020-10-30_05:04:45 UTC,1 +2020-10-30_05:05:00 UTC,2 +2020-10-30_05:05:15 UTC,2 +2020-10-30_05:25:15 UTC,0 +2020-10-30_05:25:30 UTC,1 +2020-10-30_05:25:45 UTC,1 +2020-10-30_05:26:00 UTC,1 +2020-10-30_05:26:15 UTC,1 +2020-10-30_05:26:30 UTC,1 +2020-10-30_05:26:45 UTC,0 +2020-10-30_05:27:00 UTC,0 +2020-10-30_05:27:15 UTC,0 +2020-10-30_05:27:30 UTC,0 +2020-10-30_05:27:45 UTC,0 +2020-10-30_05:28:00 UTC,0 +2020-10-30_05:28:15 UTC,0 +2020-10-30_05:28:30 UTC,0 +2020-10-30_05:28:45 UTC,0 +2020-10-30_05:29:00 UTC,0 +2020-10-30_05:29:15 UTC,0 +2020-10-30_05:29:30 UTC,0 +2020-10-30_05:29:45 UTC,0 +2020-10-30_05:30:00 UTC,1 +2020-10-30_05:30:15 UTC,1 +2020-10-30_05:30:30 UTC,1 +2020-10-30_05:30:47 UTC,0 +2020-10-30_05:32:33 UTC,0 +2020-10-30_05:38:55 UTC,0 +2020-10-30_05:39:10 UTC,0 +2020-10-30_05:39:25 UTC,0 +2020-10-30_05:39:40 UTC,0 +2020-10-30_05:39:53 UTC,0 +2020-10-30_05:40:09 UTC,0 +2020-10-30_05:40:24 UTC,1 +2020-10-30_05:40:35 UTC,0 +2020-10-30_05:40:50 UTC,1 +2020-10-30_05:41:05 UTC,1 +2020-10-30_05:41:20 UTC,1 +2020-10-30_05:41:35 UTC,1 +2020-10-30_05:41:50 UTC,1 +2020-10-30_05:42:05 UTC,1 +2020-10-30_05:42:20 UTC,1 +2020-10-30_05:42:35 UTC,1 +2020-10-30_05:42:50 UTC,1 +2020-10-30_05:43:05 UTC,0 +2020-10-30_05:43:20 UTC,0 +2020-10-30_05:43:35 UTC,0 +2020-10-30_05:44:07 UTC,0 +2020-10-30_05:44:22 UTC,0 +2020-10-30_05:44:37 UTC,0 +2020-10-30_05:44:52 UTC,1 +2020-10-30_05:45:07 UTC,1 +2020-10-30_05:45:22 UTC,1 +2020-10-30_05:45:37 UTC,1 +2020-10-30_05:45:52 UTC,1 +2020-10-30_05:46:07 UTC,1 +2020-10-30_05:46:32 UTC,0 +2020-10-30_05:46:47 UTC,1 +2020-10-30_05:47:02 UTC,1 +2020-10-30_05:47:17 UTC,1 +2020-10-30_05:47:32 UTC,2 +2020-10-30_05:47:47 UTC,1 +2020-10-30_05:48:02 UTC,2 +2020-10-30_05:48:17 UTC,2 +2020-10-30_05:48:32 UTC,2 +2020-10-30_05:48:47 UTC,2 +2020-10-30_05:49:02 UTC,1 +2020-10-30_05:49:17 UTC,1 +2020-10-30_05:49:32 UTC,1 +2020-10-30_05:49:47 UTC,1 +2020-10-30_05:50:02 UTC,1 +2020-10-30_05:50:17 UTC,1 +2020-10-30_05:50:32 UTC,2 +2020-10-30_05:50:47 UTC,1 +2020-10-30_05:51:02 UTC,1 +2020-10-30_05:51:17 UTC,1 +2020-10-30_05:51:32 UTC,1 +2020-10-30_05:51:47 UTC,1 +2020-10-30_05:52:02 UTC,1 +2020-10-30_05:52:17 UTC,1 +2020-10-30_05:52:32 UTC,1 +2020-10-30_05:52:47 UTC,1 +2020-10-30_05:53:02 UTC,1 +2020-10-30_05:53:17 UTC,2 +2020-10-30_05:53:32 UTC,1 +2020-10-30_05:53:47 UTC,1 +2020-10-30_05:54:02 UTC,1 +2020-10-30_05:54:17 UTC,1 +2020-10-30_05:54:32 UTC,1 +2020-10-30_05:54:47 UTC,1 +2020-10-30_05:55:02 UTC,1 +2020-10-30_05:55:17 UTC,1 diff --git a/metrics/shell.nix b/metrics/shell.nix new file mode 100644 index 0000000..2fa04ad --- /dev/null +++ b/metrics/shell.nix @@ -0,0 +1,6 @@ +with import {}; + +stdenv.mkDerivation { + name = "brook-metrics"; + buildInputs = with pkgs; [ rustup clangStdenv ]; +} diff --git a/metrics/src/main.rs b/metrics/src/main.rs new file mode 100644 index 0000000..af489dd --- /dev/null +++ b/metrics/src/main.rs @@ -0,0 +1,154 @@ +use chrono::Utc; +use hyper::{ + service::{make_service_fn, service_fn}, + Body, Method, Request, Response, Server, StatusCode, +}; +use lazy_static::lazy_static; +use ratman_identity::Identity; +use std::{ + collections::BTreeMap, + convert::Infallible, + env, + fs::OpenOptions, + io::Write, + net::SocketAddr, + path::PathBuf, + sync::{ + atomic::{AtomicUsize, Ordering}, + Mutex, + }, + thread, + time::Duration, +}; + +lazy_static! { + static ref STATE: Mutex> = Mutex::new(BTreeMap::new()); +} + +/// An entry of metrics data +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +struct MetricEntry {} + +fn dump_metrics() { + let p = env::var("BROOK_METRICS_PATH").unwrap_or("metrics.csv".into()); + let path = PathBuf::new().join(p); + + loop { + let time = Utc::now(); + let mut map = STATE.lock().unwrap(); + let metrics: Vec<()> = map.iter().map(|_| ()).collect(); + map.clear(); + drop(map); + + let line = format!( + "{},{}\n", + time.format("%Y-%m-%d_%H:%M:%S UTC"), + metrics.len(), + ); + let mut file = OpenOptions::new() + .write(true) + .append(true) + .create(true) + .open(&path) + .unwrap(); + + file.write_all(line.as_bytes()).unwrap(); + + // Wait for a while before doing it again + thread::sleep(Duration::from_secs(15)); + } +} + +fn get() -> Result, Infallible> { + let mut resp = Response::new(Body::empty()); + *resp.body_mut() = Body::from( + " + +brook-metrics + +

+Your brook-metrics server is now reachable! \ +Point your brook clients towards $ADDR/report +

+ +", + ); + + Ok(resp) +} + +async fn post(req: Request) -> Result, Infallible> { + let full_body = hyper::body::to_bytes(req.into_body()).await.unwrap(); + let body_str = String::from_utf8(full_body.to_vec()).unwrap(); + + let parsed = json::parse(&body_str).unwrap(); + + // Either get the ID or create a new one + let id = match parsed { + json::JsonValue::Object(mut obj) => obj.remove("id"), + _ => unreachable!(), + } + .map(|jv| match jv { + json::JsonValue::String(ref s) => Identity::from_string(s), + _ => unreachable!(), + }) + .map(|id| { + eprintln!("[DEBUG] Returning client {}", id); + id + }) + .unwrap_or_else(|| { + eprintln!("[DEBUG] Adding new stream client!"); + Identity::random() + }); + + STATE.lock().unwrap().insert(id, MetricEntry {}); + + Ok(Response::builder() + .header("Content-Type", "text/json") + .status(StatusCode::OK) + .body(Body::from(format!("{{ \"id\": \"{}\" }}", id.to_string()))) + .unwrap()) +} + +fn get_current() -> Result, Infallible> { + let len = STATE.lock().unwrap().len(); + Ok(Response::builder() + .header("Content-Type", "text/json") + .status(StatusCode::OK) + .body(Body::from(format!("{{ \"num\": {} }}", len))) + .unwrap()) +} + +async fn handle_request(req: Request) -> Result, Infallible> { + match (req.method(), req.uri().path()) { + // TODO: make this prefix configurable + (&Method::GET, "/metrics") => get(), + (&Method::GET, "/metrics/current") => get_current(), + (&Method::POST, "/metrics/update") => post(req).await, + _ => { + let resp = Response::builder() + .status(StatusCode::NOT_FOUND) + .body(Body::from("Nothing here, I'm afraid!")) + .unwrap(); + + Ok(resp) + } + } +} + +#[tokio::main] +async fn main() { + eprintln!("ID Length: {}", ratman_identity::ID_LEN); + thread::spawn(|| dump_metrics()); + + let addr = SocketAddr::from(([0, 0, 0, 0], 7667)); + let service = make_service_fn(|_c| async { Ok::<_, Infallible>(service_fn(handle_request)) }); + + eprintln!("Bindng address: 0.0.0.0:7667"); + let server = Server::bind(&addr).serve(service); + + + if let Err(e) = server.await { + eprintln!("[ERROR]: {}", e); + } +} diff --git a/nix/dash.nix b/nix/dash.nix new file mode 100644 index 0000000..c0af4d7 --- /dev/null +++ b/nix/dash.nix @@ -0,0 +1,44 @@ +{ config, lib, pkgs, ... }: + +with lib; +let + cfg = config.services.brook; +in +{ + options.services.brook.dash = { + enable = mkEnableOption "ffmpeg dash server"; + + name = mkOption { + type = types.str; + description = '' + The name of the rtmp endpoint of the stream. This might show up as + metadata in some clients + ''; + }; + }; + + config = mkIf cfg.dash.enable { + systemd.services.brook-ffmpeg = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + serviceConfig = { + StateDirectory = "dash"; + Group = "nginx"; + }; + + script = let + ffmpeg = "${pkgs.ffmpeg}/bin/ffmpeg"; + in + '' + ${ffmpeg}-listen 1 -i rtmp://0.0.0.0:1935/${cfg.dash.name}/live \ + -c:v libx264 -x264opts "keyint=24:min-keyint=24:no-scenecut" -r 24 \ + -c:a aac -b:a 128k \ + -bf 1 -b_strategy 0 -sc_threshold 0 -pix_fmt yuv420p \ + -map 0:v:0 -map 0:a:0 -map 0:v:0 \ + -map 0:a:0 -map 0:v:0 -map 0:a:0 \ + /var/lib/dash/live.mpd + ''; + }; + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..f5f4954 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,10 @@ +{ ... }: + +{ + imports = [ + ./dash.nix + ./metrics.nix + ./nginx.nix + ./prosody.nix + ]; +} diff --git a/nix/metrics.nix b/nix/metrics.nix new file mode 100644 index 0000000..8dfc881 --- /dev/null +++ b/nix/metrics.nix @@ -0,0 +1,30 @@ +{ lib, config, ... }: + +with lib; +let + cfg = config.services.brook; +in +{ + options.services.brook.metrics = { + enable = mkEnableOption "brook-web metrics backend"; + + port = mkOption { + type = types.int; + description = '' + Port to bind the brook-metrics backend server to. + ''; + }; + + path = mkOption { + type = types.str; + description = '' + Set the BROOK_METRICS_PATH environment variable to let + brook-metrics know where to export the csv output to. + ''; + }; + }; + + config = mkIf cfg.enable { + + }; +} diff --git a/nix/nginx.nix b/nix/nginx.nix new file mode 100644 index 0000000..d60b884 --- /dev/null +++ b/nix/nginx.nix @@ -0,0 +1,57 @@ +{ lib, config, pkgs, ... }: + +with lib; +let + cfg = config.services.brook; +in +{ + options.services.brook.nginx = { + enable = mkEnableOption "brook nginx host handling"; + + hostAddr = mkOption { + type = types.str; + example = "stream.example.com"; + description = '' + Set the virtual host address to use for streaming + If nginx is not already enabled, this module will + enable it for you. + ''; + }; + + acmeHost = mkOption { + type = types.str; + description = '' + An additional host address to use for acme handling. Not setting + this option will disable `useACMEHost` and `forceSSL` for this + virtualhost. + ''; + }; + }; + + config = mkIf cfg.nginx.enable { + services.nginx.virtualHosts."${cfg.nginx.hostAddr}" = { + serverAliases = [ cfg.nginx.acmeHost ]; + enableACME = false; + useACMEHost = cfg.nginx.acmeHost; + forceSSL = true; + + locations."/xmpp-bosh" = mkIf cfg.prosody.enable { + proxyPass = "https://localhost:${cfg.prosody.port}/http-bind"; + extraConfig = '' + proxy_set_header Host ${cfg.prosody.guest-domain}; + proxy_set_header X-Forwarded-For ${cfg.prosody.guest-domain}; + proxy_buffering off; + tcp_nodelay on; + ''; + }; + + locations."/dash" = { + root = "/var/lib"; + }; + + locations."/metrics" = mkIf cfg.metrics.enable { + proxyPass = "http://localhost:${cfg.metrics.port}"; + }; + }; + }; +} diff --git a/nix/prosody.nix b/nix/prosody.nix new file mode 100644 index 0000000..cfbc551 --- /dev/null +++ b/nix/prosody.nix @@ -0,0 +1,60 @@ +{ lib, config, ... }: + +with lib; +let + cfg = config.services.brook; +in +{ + options.services.brook.prosody = { + enable = mkEnableOption "brook XMPP chat with prosody"; + + port = mkOption { + type = types.int; + default = 5281; + description = '' + Specify the port that prosody's web server is listening on. + ''; + }; + + guest-domain = mkOption { + type = types.string; + description = '' + The virtualhost prosody uses as an anonymous user scope. + By default prosody can either run in normal user mode, or in + anonymous mode. Becuase the stream chat doesn't require registration, + this creates a new virtualhost to achieve this. + ''; + }; + + certRoot = mkOption { + type = types.string; + description = '' + Pass in the root path to the certificates that the + prosody virtualhost should use. + ''; + }; + }; + + config = mkIf cfg.prosody.enable { + services.prosody = { + modules = { bosh = true; websocket = true; }; + + virtualHosts."${cfg.prosody.guest-domain}" = { + enable = true; + domain = "${cfg.prosody.guest-domain}"; + ssl = { + cert = "${cfg.prosody.certRoot}/fullchain.pem"; + key = "${cfg.prosody.certRoot}/key.pem"; + }; + extraConfig = '' + authentication = "anonymous" + http_host = ${cfg.prosody.guest-domain} + ''; + }; + + extraConfig = services.prosody.extraConfig + '' + consider_bosh_secure = true + ''; + }; + }; +} diff --git a/static/ajax.min.js b/static/ajax.min.js deleted file mode 100755 index 9697988..0000000 --- a/static/ajax.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/* ainojs-ajax v1.1.2 - October 9th 2015 - (c) Aino - MIT Licensed */ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Ajax=e()}}(function(){return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s0?t:0);return new n(function(t,n){i.push(function(e,r){e?n(e):t(r)});var o=e.apply(r,i);!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then||t(o)})}},n.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),i="function"==typeof t[t.length-1]?t.pop():null,o=this;try{return e.apply(this,arguments).nodeify(i,o)}catch(s){if(null===i||"undefined"==typeof i)return new n(function(e,t){t(s)});r(function(){i.call(o,s)})}}},n.prototype.nodeify=function(e,t){return"function"!=typeof e?this:(this.then(function(n){r(function(){e.call(t,null,n)})},function(n){r(function(){e.call(t,n)})}),void 0)}},{"./core.js":3,asap:9}],9:[function(e,t){"use strict";function n(){if(u.length)throw u.shift()}function r(e){var t;t=s.length?s.pop():new i,t.task=e,o(t)}function i(){this.task=null}var o=e("./raw"),s=[],u=[],f=o.makeRequestCallFromTimer(n);t.exports=r,i.prototype.call=function(){try{this.task.call()}catch(e){r.onerror?r.onerror(e):(u.push(e),f())}finally{this.task=null,s[s.length]=this}}},{"./raw":10}],10:[function(e,t){(function(e){"use strict";function n(e){u.length||(s(),f=!0),u[u.length]=e}function r(){for(;ca){for(var t=0,n=u.length-c;n>t;t++)u[t]=u[t+c];u.length-=c,c=0}}u.length=0,c=0,f=!1}function i(e){var t=1,n=new l(e),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(){t=-t,r.data=t}}function o(e){return function(){function t(){clearTimeout(n),clearInterval(r),e()}var n=setTimeout(t,0),r=setInterval(t,50)}}t.exports=n;var s,u=[],f=!1,c=0,a=1024,l=e.MutationObserver||e.WebKitMutationObserver;s="function"==typeof l?i(r):o(r),n.requestFlush=s,n.makeRequestCallFromTimer=o}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],11:[function(e,t){(function(n){"use strict";function r(e){f.length||(o(),c=!0),f[f.length]=e}function i(){for(;al){for(var t=0,n=f.length-a;n>t;t++)f[t]=f[t+a];f.length-=a,a=0}}f.length=0,a=0,c=!1}function o(){var t=n.domain;t&&(s||(s=e("domain")),s.active=n.domain=null),c&&u?setImmediate(i):n.nextTick(i),t&&(s.active=n.domain=t)}var s,u="function"==typeof setImmediate;t.exports=r;var f=[],c=!1,a=0,l=1024;r.requestFlush=o}).call(this,e("FWaASH"))},{FWaASH:14,domain:12}],12:[function(e,t){t.exports=function(){var t=e("events"),n={};return n.createDomain=n.create=function(){function e(e){n.emit("error",e)}var n=new t.EventEmitter;return n.add=function(t){t.on("error",e)},n.remove=function(t){t.removeListener("error",e)},n.run=function(e){try{e()}catch(t){this.emit("error",t)}return this},n.dispose=function(){return this.removeAllListeners(),this},n},n}.call(this)},{events:13}],13:[function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,u,f,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,u=new Array(i-1),f=1;i>f;f++)u[f-1]=arguments[f];n.apply(this,u)}else if(o(n)){for(i=arguments.length,u=new Array(i-1),f=1;i>f;f++)u[f-1]=arguments[f];for(c=n.slice(),i=c.length,f=0;i>f;f++)c[f].apply(this,u)}return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned){var i;i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,u;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(u=s;u-->0;)if(n[u]===t||n[u].listener&&n[u].listener===t){i=u;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?r(e._events[t])?1:e._events[t].length:0}},{}],14:[function(e,t){function n(){}var r=t.exports={};r.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/static/main.css b/static/main.css deleted file mode 100644 index a5305a4..0000000 --- a/static/main.css +++ /dev/null @@ -1,69 +0,0 @@ -body { - margin: 0; - font-family: "Roboto", sans-serif; - font-weight: 300; - display: flex; - flex-direction: column; - min-height: 100vh; - background: #424242; - color: #ffffff; - font-family: "Roboto", "Open Sans", "Montserrat", sans-serif; - font-size: 1.25em; - -} - -header { - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; - background: #703f96; - padding: 0 2rem; - color: white; -} - -.stream-status { - border-bottom: solid 1px white; - animation: flash 0.75s infinite alternate; - font-size: 1.5rem; -} - -.content { - display: flex; - justify-content: center; - padding: 2rem 0; -} - -code { - font-family: "Iosekva", "Inconsolata", monospace; - font-size: 1.25em; -} - -.block { - display: flex; - flex-direction: column; - max-width: 75%; - align-self: center; -} - -a { - color: #FF88FF; - text-decoration: none; -} -a:hover { - border-bottom: solid 1px #FF88FF; -} - -#conversejs { - border: solid 2px black; -} - -.chat { - width: 27%; -} - -.stream { - border: solid 2px black; - align-self: flex-start; - width: 70%; -} diff --git a/static/test-video.webm b/static/test-video.webm deleted file mode 100644 index 642e562..0000000 Binary files a/static/test-video.webm and /dev/null differ diff --git a/web/default.nix b/web/default.nix new file mode 100644 index 0000000..f292398 --- /dev/null +++ b/web/default.nix @@ -0,0 +1,6 @@ +{ stdenv, pkgs, ... }: + +stdenv.mkDerivation { + name = "brook-web"; + src = ./.; +} diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..fe5cfaf --- /dev/null +++ b/web/index.html @@ -0,0 +1,96 @@ + + + + + + stream.spacekookie.de + + + + + + + + + + +
+

stream.spacekookie.de

+

OFFLINE

+ +
+ + +
+

Welcome to the stream! ✨

+

+ The stream chat is backed by an XMPP + room: stream@rooms.spacekookie.de — Feel free to join + it from your favourite XMPP client to say hello! +

+
+ +
+ + +
+
+
+
+ +
+

Viewers: ?

+
+ + + + + + diff --git a/web/static/ajax.min.js b/web/static/ajax.min.js new file mode 100755 index 0000000..9697988 --- /dev/null +++ b/web/static/ajax.min.js @@ -0,0 +1,2 @@ +/* ainojs-ajax v1.1.2 - October 9th 2015 - (c) Aino - MIT Licensed */ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Ajax=e()}}(function(){return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s0?t:0);return new n(function(t,n){i.push(function(e,r){e?n(e):t(r)});var o=e.apply(r,i);!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then||t(o)})}},n.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),i="function"==typeof t[t.length-1]?t.pop():null,o=this;try{return e.apply(this,arguments).nodeify(i,o)}catch(s){if(null===i||"undefined"==typeof i)return new n(function(e,t){t(s)});r(function(){i.call(o,s)})}}},n.prototype.nodeify=function(e,t){return"function"!=typeof e?this:(this.then(function(n){r(function(){e.call(t,null,n)})},function(n){r(function(){e.call(t,n)})}),void 0)}},{"./core.js":3,asap:9}],9:[function(e,t){"use strict";function n(){if(u.length)throw u.shift()}function r(e){var t;t=s.length?s.pop():new i,t.task=e,o(t)}function i(){this.task=null}var o=e("./raw"),s=[],u=[],f=o.makeRequestCallFromTimer(n);t.exports=r,i.prototype.call=function(){try{this.task.call()}catch(e){r.onerror?r.onerror(e):(u.push(e),f())}finally{this.task=null,s[s.length]=this}}},{"./raw":10}],10:[function(e,t){(function(e){"use strict";function n(e){u.length||(s(),f=!0),u[u.length]=e}function r(){for(;ca){for(var t=0,n=u.length-c;n>t;t++)u[t]=u[t+c];u.length-=c,c=0}}u.length=0,c=0,f=!1}function i(e){var t=1,n=new l(e),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(){t=-t,r.data=t}}function o(e){return function(){function t(){clearTimeout(n),clearInterval(r),e()}var n=setTimeout(t,0),r=setInterval(t,50)}}t.exports=n;var s,u=[],f=!1,c=0,a=1024,l=e.MutationObserver||e.WebKitMutationObserver;s="function"==typeof l?i(r):o(r),n.requestFlush=s,n.makeRequestCallFromTimer=o}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],11:[function(e,t){(function(n){"use strict";function r(e){f.length||(o(),c=!0),f[f.length]=e}function i(){for(;al){for(var t=0,n=f.length-a;n>t;t++)f[t]=f[t+a];f.length-=a,a=0}}f.length=0,a=0,c=!1}function o(){var t=n.domain;t&&(s||(s=e("domain")),s.active=n.domain=null),c&&u?setImmediate(i):n.nextTick(i),t&&(s.active=n.domain=t)}var s,u="function"==typeof setImmediate;t.exports=r;var f=[],c=!1,a=0,l=1024;r.requestFlush=o}).call(this,e("FWaASH"))},{FWaASH:14,domain:12}],12:[function(e,t){t.exports=function(){var t=e("events"),n={};return n.createDomain=n.create=function(){function e(e){n.emit("error",e)}var n=new t.EventEmitter;return n.add=function(t){t.on("error",e)},n.remove=function(t){t.removeListener("error",e)},n.run=function(e){try{e()}catch(t){this.emit("error",t)}return this},n.dispose=function(){return this.removeAllListeners(),this},n},n}.call(this)},{events:13}],13:[function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,u,f,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,u=new Array(i-1),f=1;i>f;f++)u[f-1]=arguments[f];n.apply(this,u)}else if(o(n)){for(i=arguments.length,u=new Array(i-1),f=1;i>f;f++)u[f-1]=arguments[f];for(c=n.slice(),i=c.length,f=0;i>f;f++)c[f].apply(this,u)}return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned){var i;i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,u;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(u=s;u-->0;)if(n[u]===t||n[u].listener&&n[u].listener===t){i=u;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?r(e._events[t])?1:e._events[t].length:0}},{}],14:[function(e,t){function n(){}var r=t.exports={};r.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/web/static/main.css b/web/static/main.css new file mode 100644 index 0000000..a5305a4 --- /dev/null +++ b/web/static/main.css @@ -0,0 +1,69 @@ +body { + margin: 0; + font-family: "Roboto", sans-serif; + font-weight: 300; + display: flex; + flex-direction: column; + min-height: 100vh; + background: #424242; + color: #ffffff; + font-family: "Roboto", "Open Sans", "Montserrat", sans-serif; + font-size: 1.25em; + +} + +header { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + background: #703f96; + padding: 0 2rem; + color: white; +} + +.stream-status { + border-bottom: solid 1px white; + animation: flash 0.75s infinite alternate; + font-size: 1.5rem; +} + +.content { + display: flex; + justify-content: center; + padding: 2rem 0; +} + +code { + font-family: "Iosekva", "Inconsolata", monospace; + font-size: 1.25em; +} + +.block { + display: flex; + flex-direction: column; + max-width: 75%; + align-self: center; +} + +a { + color: #FF88FF; + text-decoration: none; +} +a:hover { + border-bottom: solid 1px #FF88FF; +} + +#conversejs { + border: solid 2px black; +} + +.chat { + width: 27%; +} + +.stream { + border: solid 2px black; + align-self: flex-start; + width: 70%; +} -- cgit v1.2.3