From 7711bcc22069c3e0fba91fcc3c7407eda2c7679b Mon Sep 17 00:00:00 2001 From: Laika Date: Tue, 12 Mar 2024 22:28:05 +0100 Subject: [PATCH] Initial commit --- .gitignore | 7 + LICENSE | 21 + README.md | 50 + SECURITY.md | 19 + TODO.md | 19 + backend/.vscode/launch.json | 45 + backend/Cargo.lock | 2236 ++++++++++++++++++++++++++++ backend/Cargo.toml | 24 + backend/Dockerfile | 17 + backend/src/api/mod.rs | 10 + backend/src/api/routes/aircraft.rs | 84 ++ backend/src/api/routes/overview.rs | 10 + backend/src/api/server.rs | 62 + backend/src/api/state.rs | 347 +++++ backend/src/config.rs | 37 + backend/src/main.rs | 97 ++ backend/src/ogn/aircraft.rs | 146 ++ backend/src/ogn/aprs/client.rs | 172 +++ backend/src/ogn/aprs/conversion.rs | 498 +++++++ backend/src/ogn/aprs/status.rs | 49 + backend/src/ogn/ddb/client.rs | 38 + backend/src/ogn/ddb/conversion.rs | 121 ++ backend/src/ogn/ddb/error.rs | 19 + backend/src/ogn/mod.rs | 21 + backend/src/position.rs | 90 ++ backend/src/time.rs | 27 + config.example.json | 11 + docker/.env.example | 7 + docker/docker-compose.yml | 23 + docker/nginx.conf | 53 + docker/privacy-policy.html | 1 + frontend/Dockerfile | 32 + frontend/package-lock.json | 111 ++ frontend/package.json | 25 + frontend/src/index.html | 103 ++ frontend/src/main.js | 109 ++ frontend/src/privacy-policy.html | 1 + frontend/src/style.css | 73 + frontend/src/table.handlebars | 91 ++ openapi.yml | 231 +++ 40 files changed, 5137 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 TODO.md create mode 100644 backend/.vscode/launch.json create mode 100644 backend/Cargo.lock create mode 100644 backend/Cargo.toml create mode 100644 backend/Dockerfile create mode 100644 backend/src/api/mod.rs create mode 100644 backend/src/api/routes/aircraft.rs create mode 100644 backend/src/api/routes/overview.rs create mode 100644 backend/src/api/server.rs create mode 100644 backend/src/api/state.rs create mode 100644 backend/src/config.rs create mode 100644 backend/src/main.rs create mode 100644 backend/src/ogn/aircraft.rs create mode 100644 backend/src/ogn/aprs/client.rs create mode 100644 backend/src/ogn/aprs/conversion.rs create mode 100644 backend/src/ogn/aprs/status.rs create mode 100644 backend/src/ogn/ddb/client.rs create mode 100644 backend/src/ogn/ddb/conversion.rs create mode 100644 backend/src/ogn/ddb/error.rs create mode 100644 backend/src/ogn/mod.rs create mode 100644 backend/src/position.rs create mode 100644 backend/src/time.rs create mode 100644 config.example.json create mode 100644 docker/.env.example create mode 100644 docker/docker-compose.yml create mode 100644 docker/nginx.conf create mode 100644 docker/privacy-policy.html create mode 100644 frontend/Dockerfile create mode 100644 frontend/package-lock.json create mode 100644 frontend/package.json create mode 100644 frontend/src/index.html create mode 100644 frontend/src/main.js create mode 100644 frontend/src/privacy-policy.html create mode 100644 frontend/src/style.css create mode 100644 frontend/src/table.handlebars create mode 100644 openapi.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bff9624 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.env +config.json +/backend/target +/frontend/node_modules +/frontend/dist +/docker/privacy-policy.html +.idea/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ac09a1e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Laika Schmidt + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e31edc4 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# above_me +## Goal +This projects listens to the APRS-servers of the [Open Glider Network](http://wiki.glidernet.org/) and keeps track of all incoming aircraft status. It provides an API that returns the latest status for each aircraft within a given location and range. It also provides a simple website that fetches and lists those aircraft status based on your device location automatically. + +## Set up +### Native +#### Build +##### Backend +- `cd backend/` +- `cargo build --release` + +##### Frontend +- `cd frontend/` +- `npm run copy-dependencies` +- `npm run compile` + +#### Run +- Either run `RUST_LOG=error cargo run` inside the [backend/](backend) directory or build the backend and run `RUST_LOG=error ./backend/target/release/above_me`. +- Build the frontend and serve the _frontend/dist_ directory. + (For **development**, you may run `npm run dev` inside the [frontend/](frontend) directory. Requires _Python 3_.) + +#### Configuration +Only the backend must be configured. Frontend will run as-is. There are three ways for configuration: + +1. _/config.json_ (copy [config.example.json](config.example.json)) +2. _/backend/config.json_ (copy [config.example.json](config.example.json), overrides _1._) +3. by environment variables with the prefix _ABOVE\_ME\_\__ (see [/docker/.env.example](docker/.env.example), overrides _1._ and _2._) + +### Docker +Configure by setting up _/docker/.env_ (copy [/docker/.env.example](docker/.env.example)) and run `docker compose up`. + +(Please note that the _bind\_url_ should be left unconfigured as it is used in the [/docker/docker-compose.yml](docker/docker-compose.yml) config file. Otherwise the proxy-pass may break.) + +### Privacy policy +The website contains links to _privacy-policy.html_. You can (and should) set up this privacy policy page. Empty dummy files already exist in the [_docker/_](docker) and [_frontend/src/_](frontend/src) directories. + +## API +API-Documentation: [openapi.yml](openapi.yml) + +## Status +This project is up and running. I'd say it's "feature-complete" for my use-case. +I'll maybe start building a nicer frontend sometimes. (see [TODO.md](TODO.md)) + +## License +This code is licensed under the MIT-License (see [LICENSE](LICENSE)). Before using it, make sure to not violate against OGN rules: + +see [OGN data usage](https://www.glidernet.org/ogn-data-usage/) +see [ODbL summary](https://opendatacommons.org/licenses/odbl/summary/) + +(This project complies to those rules by only publishing data that's [at most 5 minutes old](backend/src/api/state.rs#L127) and [only for aircraft that don't have stealth- or no-tracking-mode active](backend/src/ogn/aprs/conversion.rs#L26).) \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..b1ac39a --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,19 @@ +# Security Policy + +## Supported Versions + +Support is limited to the latest version and also the current state in the main branch. + +| Version | Supported | +| ------------- | ------------------ | +| _main_ | :white_check_mark: | +| 0.1.4 | :white_check_mark: | +| 0.1.3 | :x: | +| <= 0.1.2 | :x: | + +## Reporting a Vulnerability + +If you want to report a vulnerability, check if it's possible to create an issue without endangering other users. +If that's not the case, send a mail to the address on my ([its-laika](https://github.com/its-laika)) profile. +I check my mails pretty frequently so expect a reply within a few days. From there on, I'll do my best to fix the vulnerability asap. +If you want to, you can also provide patches directly or via pull requests. A new version is pushed as soon as the vulnerability is fixed. diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..a1344a1 --- /dev/null +++ b/TODO.md @@ -0,0 +1,19 @@ +# TODOs + +## 🦀 Backend +- [x] For some reason, the backend service suddenly stops after a week or so. Find out why and fix this bug. +- [x] Add aircraft type parsing ([doc](http://wiki.glidernet.org/wiki:ogn-flavoured-aprs#toc2)) +- [x] Check whether APRS client needs to send regular keep alives +- [x] Documentation + - [x] Code + - [x] API + +## 🅰️ Frontend +- [ ] Build a better, fancy frontend + - [ ] Cleaner build process +- [x] Build a frontend +- [x] Add privacy site + +## ☁️ Deploy +- [x] Docker support + - [x] Create a _docker-compose.yml_ configuration file \ No newline at end of file diff --git a/backend/.vscode/launch.json b/backend/.vscode/launch.json new file mode 100644 index 0000000..eb8950c --- /dev/null +++ b/backend/.vscode/launch.json @@ -0,0 +1,45 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'above_me'", + "cargo": { + "args": [ + "build", + "--bin=above_me", + "--package=above_me" + ], + "filter": { + "name": "above_me", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'above_me'", + "cargo": { + "args": [ + "test", + "--no-run", + "--bin=above_me", + "--package=above_me" + ], + "filter": { + "name": "above_me", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/backend/Cargo.lock b/backend/Cargo.lock new file mode 100644 index 0000000..a04dd76 --- /dev/null +++ b/backend/Cargo.lock @@ -0,0 +1,2236 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "above_me" +version = "0.1.4" +dependencies = [ + "axum", + "config", + "env_logger", + "log", + "regex", + "reqwest", + "serde", + "serde_json", + "tokio", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "axum" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b098575ebe77cb6d14fc7f32749631a6e44edbef6b796f89b020e99ba20d425" +dependencies = [ + "axum-core", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59446ce19cd142f8833f856eb31f3eb097812d1479ab224f54d72428ca21ea22" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +dependencies = [ + "serde_core", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "bytes" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" + +[[package]] +name = "cc" +version = "1.2.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "config" +version = "0.15.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b30fa8254caad766fc03cb0ccae691e14bf3bd72bfff27f72802ce729551b3d6" +dependencies = [ + "async-trait", + "convert_case", + "json5", + "pathdiff", + "ron", + "rust-ini", + "serde-untagged", + "serde_core", + "serde_json", + "toml", + "winnow", + "yaml-rust2", +] + +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.16", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dlv-list" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env_filter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "erased-serde" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89e8918065695684b2b0702da20382d5ae6065cf3327bc2d6436bd49a71ce9f3" +dependencies = [ + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "h2" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.5", +] + +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "system-configuration", + "tokio", + "tower-service", + "tracing", + "windows-registry", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +dependencies = [ + "equivalent", + "hashbrown 0.16.0", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f867b9d1d896b67beb18518eda36fdb77a32ea590de864f1325b294a6d14397" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "jiff" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "js-sys" +version = "0.3.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "json5" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" +dependencies = [ + "pest", + "pest_derive", + "serde", +] + +[[package]] +name = "libc" +version = "0.2.177" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" + +[[package]] +name = "linux-raw-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "openssl" +version = "0.10.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "ordered-multimap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" +dependencies = [ + "dlv-list", + "hashbrown 0.14.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pest" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4" +dependencies = [ + "memchr", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "187da9a3030dbafabbbfb20cb323b976dc7b7ce91fcd84f2f74d6e31d378e2de" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49b401d98f5757ebe97a26085998d6c0eecec4995cad6ab7fc30ffdf4b052843" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a" +dependencies = [ + "pest", + "sha2", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] +name = "reqwest" +version = "0.12.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "ron" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd490c5b18261893f14449cbd28cb9c0b637aebf161cd77900bfdedaff21ec32" +dependencies = [ + "bitflags", + "once_cell", + "serde", + "serde_derive", + "typeid", + "unicode-ident", +] + +[[package]] +name = "rust-ini" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "796e8d2b6696392a43bea58116b667fb4c29727dc5abd27d6acf338bb4f688c7" +dependencies = [ + "cfg-if", + "ordered-multimap", +] + +[[package]] +name = "rustix" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "533f54bc6a7d4f647e46ad909549eda97bf5afc1585190ef692b4286b198bd8f" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94182ad936a0c91c324cd46c6511b9510ed16af436d7b5bab34beab0afd55f7a" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "schannel" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde-untagged" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9faf48a4a2d2693be24c6289dbe26552776eb7737074e6722891fadbe6c5058" +dependencies = [ + "erased-serde", + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", + "serde_core", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[package]] +name = "serde_spanned" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.110" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" +dependencies = [ + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" +dependencies = [ + "winnow", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "551f88106c6d5e7ccc7cd9a16f312dd3b5d36ea8b4954304657d5dfba115d4a0" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "winnow" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yaml-rust2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2462ea039c445496d8793d052e13787f2b90e750b833afee748e601c17621ed9" +dependencies = [ + "arraydeque", + "encoding_rs", + "hashlink", +] + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/backend/Cargo.toml b/backend/Cargo.toml new file mode 100644 index 0000000..ee7ccea --- /dev/null +++ b/backend/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "above_me" +version = "0.1.4" +edition = "2024" +authors = ["Laika Schmidt "] +description = "This project contains the backend for above_me, a service that lets you see what aircraft are currently flying above you." +readme = "../README.md" +license = "MIT" +keywords = ["ogn", "openglidernet", "open-glider-net", "aircraft", "glider"] +exclude = ["Dockerfile", "target/"] + +[dependencies] +axum = "0.8.7" +config = "0.15.19" +regex = { version = "1.12.2", features = ["std"] } +reqwest = "0.12" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +tokio = { version = "1", features = ["full"] } +log = "0.4" +env_logger = "0.11.8" + +[profile.release] +strip = true diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..0c7339b --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,17 @@ +FROM rust:latest AS build + +WORKDIR /app + +COPY src src +COPY Cargo.lock . +COPY Cargo.toml . + +RUN cargo build --release + +FROM rust:slim + +WORKDIR /app + +COPY --from=build /app/target/release/above_me . + +CMD ["./above_me"] \ No newline at end of file diff --git a/backend/src/api/mod.rs b/backend/src/api/mod.rs new file mode 100644 index 0000000..7425b76 --- /dev/null +++ b/backend/src/api/mod.rs @@ -0,0 +1,10 @@ +pub use server::init; +pub use state::App; + +mod routes { + pub mod aircraft; + pub mod overview; +} + +mod server; +mod state; diff --git a/backend/src/api/routes/aircraft.rs b/backend/src/api/routes/aircraft.rs new file mode 100644 index 0000000..d50a31b --- /dev/null +++ b/backend/src/api/routes/aircraft.rs @@ -0,0 +1,84 @@ +use axum::{ + extract::{Path, State}, + Json, +}; +use serde::Serialize; + +use crate::{ + api::App, + ogn::{aprs::Status, Aircraft}, + position::Position, +}; + +/// Handler for route _/r/:latitude/:longitude/:range_ +/// +/// Responds with a list of aircraft in the _:range_ around _:latitude_ and _:longitude_ +pub async fn handler( + Path((latitude, longitude, range)): Path<(f32, f32, f32)>, + State(app): State, +) -> Json { + /* Ensure range can be used as f32 */ + let position = Position { + latitude, + longitude, + }; + + Json(Response { + latitude, + longitude, + range, + states: app.get_filtered_status_dtos(&position, range), + }) +} + +#[derive(Serialize)] +pub struct Response { + /// Equals given latitude parameter + latitude: f32, + /// Equals given longitude parameter + longitude: f32, + /// Equals given range parameter + range: f32, + /// The aircraft states that match the given parameters + states: Vec, +} + +/// Dto representation of an aircraft status, containing the distance to the +/// requested postion in km. +#[derive(Clone, Serialize)] +pub struct StatusDto { + /// Affected aircraft + pub aircraft: Aircraft, + /// Position of aircraft + pub position: Position, + /// Speed in _km/h_ + pub speed: Option, + /// Vertical speed in _m/s_ + pub vertical_speed: Option, + /// Altitude in _m_ + pub altitude: Option, + /// Turn rate in _turns/min_ + pub turn_rate: Option, + /// Course of aircraft + pub course: Option, + /// Timestamp of receiving status + pub time_stamp: u64, + /// Distance to given postion in km + pub distance: f32, +} + +impl StatusDto { + pub fn from(status: &Status, distance: f32) -> Self { + Self { + aircraft: status.aircraft.clone(), + position: status.position.clone(), + speed: status.speed, + vertical_speed: status.vertical_speed, + altitude: status.altitude, + turn_rate: status.turn_rate, + course: status.course, + time_stamp: status.time_stamp, + distance, + } + } +} diff --git a/backend/src/api/routes/overview.rs b/backend/src/api/routes/overview.rs new file mode 100644 index 0000000..4f3112a --- /dev/null +++ b/backend/src/api/routes/overview.rs @@ -0,0 +1,10 @@ +use axum::{extract::State, Json}; + +use crate::api::{App, state::Overview}; + +/// Handler for route _/status_ +/// +/// Responds with an overview of the currently stored states +pub async fn handler(State(app): State) -> Json { + Json(app.get_overview()) +} diff --git a/backend/src/api/server.rs b/backend/src/api/server.rs new file mode 100644 index 0000000..09e5428 --- /dev/null +++ b/backend/src/api/server.rs @@ -0,0 +1,62 @@ +use axum::{routing::get, Router}; +use log::info; +use tokio::sync::oneshot; +use std::io::Error; +use tokio::{net::TcpListener, net::ToSocketAddrs}; + +use super::routes::{aircraft, overview}; +use super::state::App; + +/// Initializes a tcp server that serves our API +/// +/// # Arguments +/// +/// * `address` - The address that the server will bind to +/// * `app` - The `App` that the API will use for its data +/// * `shutdown_rx` - A shotgun `Receiver<()>` that will shut down the server gracefully when a +/// message is received. +/// +/// # Returns +/// +/// Future that will either result to () or Error when an error occurs. +/// +/// # Examples +/// +/// ``` +/// use api::App; +/// use tokio::{spawn, sync::oneshot}; +/// +/// let address = "127.0.0.1:8080"; +/// let (shutdown_tx, shutdown_rx) = oneshot::channel(); +/// let app = App::create(); +/// +/// spawn(async move { +/// api::init(&address, app, shutdown_rx) +/// .await +/// .expect("API server failed"); +/// }); +/// +/// // Shuts down API server +/// shutdown_tx.send(()).unwrap(); +/// ``` +pub async fn init( + address: &A, + app: App, + shutdown_rx: oneshot::Receiver<()>, +) -> Result<(), Error> { + let app = Router::new() + .route("/r/{latitude}/{longitude}/{range}", get(aircraft::handler)) + .route("/status", get(overview::handler)) + .with_state(app); + + let listener = TcpListener::bind(address).await?; + + axum::serve(listener, app) + .with_graceful_shutdown(async { + let _ = shutdown_rx.await; + info!("API received shutdown signal"); + }) + .await?; + + Ok(()) +} diff --git a/backend/src/api/state.rs b/backend/src/api/state.rs new file mode 100644 index 0000000..7fd62b4 --- /dev/null +++ b/backend/src/api/state.rs @@ -0,0 +1,347 @@ +use std::{ + collections::HashMap, + sync::{ + atomic::{AtomicU64, Ordering}, + Arc, Mutex, MutexGuard, + }, +}; + +use serde::Serialize; + +use crate::{ + aprs::Status, + position::{calculate_distance, Position}, + time::get_current_timestamp, +}; + +use super::routes::aircraft::StatusDto; + +const MAX_AGE_DIFF: u64 = 60 * 5; /* 5 minutes */ + +/// Our shared application state for the API +#[derive(Clone)] +pub struct App { + /// Reference to all currently stored states + states: Arc>>, + /// Timestamp of last APRS line received + last_aprs_update: Arc, +} + +/// DTO for status overview +#[derive(Serialize)] +pub struct Overview { + /// Number of currently stored states + pub count: usize, + /// Timestamp of last status update, if states is not empty + pub last_status_update: Option, + /// Timestamp of last APRS update received + pub last_aprs_update: Option, +} + +impl App { + /// Creates a new `App` + /// + /// # Examples + /// + /// ``` + /// use api::App; + /// + /// let app = App::create(); + /// ``` + pub fn create() -> App { + App { + states: Arc::new(Mutex::new(HashMap::new())), + last_aprs_update: Arc::new(AtomicU64::new(0)), + } + } + + /// Returns the states in the `App` that match given filters as dtos. + /// + /// # Arguments + /// * `position` - The position that should be searched for + /// * `range` - Range around given `position` that should be searched for. + /// + /// # Returns + /// + /// Returns dtos of the states within `range` around given `position`, sorted in ascending + /// oder by distance to `position`. + /// + /// # Examples + /// + /// * test `state::get_filtered_states_checks_age` + /// * test `state::get_filtered_states_checks_range` + /// * test `state::get_filtered_states_orders_correctly` + pub fn get_filtered_status_dtos(&self, position: &Position, range: f32) -> Vec { + let mut states = self.states.lock().expect("Mutex was poisoned"); + + App::remove_outdated_states(&mut states); + + let mut status_dtos = states + .values() + .map(|status| (status, calculate_distance(position, &status.position))) + .filter(|&(_, distance)| distance <= range) + .map(|(status, distance)| StatusDto::from(status, distance)) + .collect::>(); + + status_dtos.sort_unstable_by(|status_dto_1, status_dto_2| { + status_dto_1 + .distance + .partial_cmp(&status_dto_2.distance) + .unwrap() + }); + + status_dtos + } + + /// Stores / updates a new status in the `App` + /// + /// # Arguments + /// + /// * `status` - The status to store / update + /// + /// # Examples + /// + /// * test `state::get_filtered_states_checks_age` + /// * test `state::get_filtered_states_checks_range` + pub fn push_status(&self, new_status: Status) { + let mut states = self.states.lock().expect("Mutex was poisoned"); + + App::remove_outdated_states(&mut states); + + states.insert(new_status.aircraft.id.clone(), new_status); + } + + /// Updates timestamp of latest APRS update in the `App` + /// + /// # Arguments + /// + /// * `timestamp` - Timestamp of latest APRS update + /// + /// # Examples + /// + /// * test `state::get_overview_works` + pub fn push_last_aprs_update_timestamp(&self, timestamp: u64) { + self.last_aprs_update.store(timestamp, Ordering::Relaxed); + } + + /// Returns an overview of the currently stored states + /// + /// # Examples + /// + /// * test `state::get_overview_works` + pub fn get_overview(&self) -> Overview { + /* Shortcut: As AtomicU64 seems to be the best choice for a shared timestamp value, + * we can't use an `Option` directly in the `App`. But as the timestamp is initialized + * with 0, we can just convert the 0 to `None`. */ + let last_aprs_update = match self.last_aprs_update.load(Ordering::Relaxed) { + 0 => None, + v => Some(v), + }; + + let mut states = self.states.lock().expect("Mutex was poisoned"); + App::remove_outdated_states(&mut states); + + Overview { + count: states.len(), + last_status_update: states.values().map(|s| s.time_stamp).max(), + last_aprs_update, + } + } + + /// Removes outdated states (by max age) + /// + /// # Arguments + /// + /// * `states` - `MutexGuard` of states map + fn remove_outdated_states(states: &mut MutexGuard>) { + let current_timestamp = get_current_timestamp(); + + let outdated_keys = states + .values() + .filter(|e| current_timestamp - e.time_stamp > MAX_AGE_DIFF) + .map(|e| e.aircraft.id.clone()) + .collect::>(); + + for key in outdated_keys { + states.remove(&key); + } + } +} + +#[cfg(test)] +mod tests { + use crate::ogn::Aircraft; + + use super::*; + + #[test] + fn get_filtered_status_dtos_checks_age() { + let sut = App::create(); + let current_timestamp = get_current_timestamp(); + let outdated_timestamp = current_timestamp - MAX_AGE_DIFF - 1; + + let position = Position { + longitude: 48.858222, + latitude: 2.2945, + }; + + sut.push_status(create_status( + String::from("AB1234"), + position.clone(), + current_timestamp, + )); + sut.push_status(create_status( + String::from("CD5678"), + position.clone(), + outdated_timestamp, + )); + + let result = sut.get_filtered_status_dtos(&position, 1.0); + assert_eq!(result.len(), 1); + assert_eq!(result[0].aircraft.id, "AB1234"); + } + + #[test] + fn get_filtered_status_dtos_checks_range() { + let sut = App::create(); + let current_timestamp = get_current_timestamp(); + + let position = Position { + latitude: 48.858222, + longitude: 2.2945, + }; + + sut.push_status(create_status( + String::from("AB1234"), + position.clone(), + current_timestamp, + )); + + sut.push_status(create_status( + String::from("CD5678"), + Position { + /* see position.rs -> 3.16 km */ + latitude: 48.86055, + longitude: 2.3376, + }, + current_timestamp, + )); + + sut.push_status(create_status( + String::from("EF9012"), + Position { + longitude: 48.84, + latitude: 2.2, + }, + current_timestamp, + )); + + let result = sut.get_filtered_status_dtos(&position, 4.0); + + assert_eq!(result.len(), 2); + assert!(result.iter().any(|s| s.aircraft.id == "AB1234")); + assert!(result.iter().any(|s| s.aircraft.id == "CD5678")); + } + + #[test] + fn get_filtered_status_dtos_orders_correctly() { + let sut = App::create(); + let current_timestamp = get_current_timestamp(); + + let position = Position { + latitude: 48.858222, + longitude: 2.2945, + }; + + sut.push_status(create_status( + String::from("CD5678"), + Position { + latitude: position.latitude + 0.0001, + longitude: position.longitude + 0.0001, + }, + current_timestamp, + )); + + sut.push_status(create_status( + String::from("AB1234"), + Position { + latitude: position.latitude, + longitude: position.longitude, + }, + current_timestamp, + )); + + sut.push_status(create_status( + String::from("EF9012"), + Position { + latitude: position.latitude + 0.0002, + longitude: position.longitude + 0.0002, + }, + current_timestamp, + )); + + let result = sut.get_filtered_status_dtos(&position, 4.0); + + assert_eq!(result.len(), 3); + assert_eq!(result[0].aircraft.id, "AB1234"); + assert_eq!(result[1].aircraft.id, "CD5678"); + assert_eq!(result[2].aircraft.id, "EF9012"); + } + + #[test] + fn get_overview_works() { + let sut = App::create(); + + let result_empty = sut.get_overview(); + + let current_timestamp = get_current_timestamp(); + + let position = Position { + latitude: 48.858222, + longitude: 2.2945, + }; + + sut.push_status(create_status( + String::from("AB1234"), + position.clone(), + current_timestamp - 50, + )); + + sut.push_status(create_status( + String::from("CD5678"), + position.clone(), + current_timestamp, + )); + + sut.push_last_aprs_update_timestamp(current_timestamp); + + let result_filled = sut.get_overview(); + + assert_eq!(result_empty.count, 0); + assert_eq!(result_empty.last_status_update, None); + assert_eq!(result_empty.last_aprs_update, None); + + assert_eq!(result_filled.count, 2); + assert_eq!(result_filled.last_status_update, Some(current_timestamp)); + assert_eq!(result_filled.last_aprs_update, Some(current_timestamp)); + } + + fn create_status(aircraft_id: String, position: Position, time_stamp: u64) -> Status { + Status { + aircraft: Aircraft { + id: aircraft_id, + call_sign: None, + registration: None, + model: None, + visible: true, + }, + position, + speed: None, + vertical_speed: None, + altitude: None, + turn_rate: None, + course: None, + time_stamp, + } + } +} diff --git a/backend/src/config.rs b/backend/src/config.rs new file mode 100644 index 0000000..b3d6d1c --- /dev/null +++ b/backend/src/config.rs @@ -0,0 +1,37 @@ +use config::{ConfigError, Environment, File, FileFormat}; +use serde::Deserialize; + +use crate::aprs; + +/// Name of the config file (".json" is added by the `config` crate automatically) +pub const PROJECT_CONFIG_FILE: &str = "../config"; +pub const BACKEND_CONFIG_FILE: &str = "config"; +pub const ENVIRONMENT_PREFIX: &str = "ABOVE_ME"; +const ENVIRONMENT_SEPARATOR: &str = "__"; + +/// Representation of program configuration +#[derive(Deserialize)] +pub struct Config { + /// Config for connecting to the APRS server + pub aprs: aprs::Config, + /// Url of the DDB server to fetch aircraft information + pub ddb_url: String, + /// Url that the API server should bind to + pub bind_to: String, +} + +/// Tries loading configuration from config files or environment +/// +/// # Examples +/// ``` +/// let config = load_config().expect("Could not load config by file"); +/// print!("Server will bind to: {}", config.bind_to); +/// ``` +pub fn load() -> Result { + config::Config::builder() + .add_source(File::new(PROJECT_CONFIG_FILE, FileFormat::Json).required(false)) + .add_source(File::new(BACKEND_CONFIG_FILE, FileFormat::Json).required(false)) + .add_source(Environment::with_prefix(ENVIRONMENT_PREFIX).separator(ENVIRONMENT_SEPARATOR)) + .build()? + .try_deserialize::() +} diff --git a/backend/src/main.rs b/backend/src/main.rs new file mode 100644 index 0000000..be93645 --- /dev/null +++ b/backend/src/main.rs @@ -0,0 +1,97 @@ +use crate::ogn::{aprs, ddb::fetch_aircraft}; +use log::{error, info}; +use tokio::{sync::oneshot, select, sync::mpsc, task::JoinSet}; + +mod api; +mod config; +mod ogn; +mod position; +mod time; + +#[tokio::main] +async fn main() { + env_logger::init(); + + info!("Loading config..."); + let config = match config::load() { + Ok(c) => { + info!("Loaded config successfully!"); + c + } + Err(e) => { + error!("Could not load config: {e}"); + return; + } + }; + + info!("Loading aircraft data..."); + let aircraft = match fetch_aircraft(&config.ddb_url).await { + Ok(a) => { + info!("Loaded aircraft data successfully!"); + a + } + Err(e) => { + error!("Could not fetch aircraft data: {e}"); + return; + } + }; + + let mut join_set = JoinSet::new(); + + let (shutdown_tx, shutdown_rx) = oneshot::channel(); + let (status_tx, mut status_rx) = mpsc::channel(32); + let (line_received_tx, mut line_received_rx) = mpsc::channel(32); + + let app = api::App::create(); + let app_update = app.clone(); + + join_set.spawn(async move { + info!("Initializing API..."); + + if let Err(e) = api::init(&config.bind_to, app, shutdown_rx).await { + error!("API stopped with error: {e}"); + } else { + info!("API stopped"); + } + }); + + join_set.spawn(async move { + info!("Initializing APRS client..."); + + loop { + if let Err(e) = aprs::init(&config.aprs, &status_tx, &line_received_tx, &aircraft).await + { + error!("Client stopped with error: {e}"); + break; + } + + /* Server may disconnect us at some point. Just reconnect and carry on. */ + info!("Client disconnected. Reconnecting..."); + } + + if shutdown_tx.send(()).is_err() { + error!("Could not send shutdown signal. You need to kill this program :("); + } + }); + + join_set.spawn(async move { + info!("Initializing updates from client to API..."); + + loop { + select! { + Some(status) = status_rx.recv() => { + app_update.push_status(status); + }, + Some(timestamp) = line_received_rx.recv() => { + app_update.push_last_aprs_update_timestamp(timestamp); + }, + else => break + } + } + + info!("Updates from client to API stopped"); + }); + + while (join_set.join_next().await).is_some() {} + info!("Shutdown"); +} diff --git a/backend/src/ogn/aircraft.rs b/backend/src/ogn/aircraft.rs new file mode 100644 index 0000000..70ff4cb --- /dev/null +++ b/backend/src/ogn/aircraft.rs @@ -0,0 +1,146 @@ +use std::fmt::{Display, Formatter, Result}; + +use serde::Serialize; + +/// Representing information about an aircraft. +#[derive(Clone, Serialize)] +pub struct Aircraft { + /// DDB id of the aircraft + #[serde(skip_serializing)] + pub id: String, + /// Call sign, e.g. "G1" + pub call_sign: Option, + /// Registration, e.g. "D-6507" + pub registration: Option, + /// Aircraft model type, e.g. "ASK-21" + pub model: Option, + /// Should the aircraft be identified and tracked? + #[serde(skip_serializing)] + pub visible: bool, +} + +impl Aircraft { + /// Clones `Aircraft` with a given `model` name + /// + /// # Arguments + /// * `model` - The new model name that the resulting aircraft + /// should have + /// + /// # Examples + /// + /// ``` + /// let aircraft = Aircraft { + /// id: String::from("AB1234"), + /// call_sign: String::from("G1"), + /// registration: String::from("D-6507"), + /// model: String::from(""), + /// visible: true, + /// }; + /// + /// let aircraft_with_model = aircraft.with_model(Some(String::new("ASK-21"))); + /// + /// assert!(aircraft_with_model.model.is_some()); + /// assert_eq!(aircraft_with_model.model.unwrap(), "ASK-21"); + /// ``` + pub fn with_model(&self, model: Option) -> Aircraft { + Aircraft { + id: self.id.clone(), + call_sign: self.call_sign.clone(), + registration: self.registration.clone(), + model, + visible: self.visible, + } + } +} + +/// Representation of generic aicraft types. +#[derive(PartialEq)] +pub enum Type { + Glider, + Tow, + Helicopter, + SkyDiver, + DropPlane, + HangGlider, + Paraglider, + MotorAircraft, + Jet, + Balloon, + Blimp, + Unmanned, + Obstacle, +} + +impl Type { + /// Tries getting aircaft type for the APRS aircraft type value + /// (encoded inside the aircraft id field). + /// + /// # Arguments + /// + /// * `id` - Aircraft type id + /// + /// # Examples + /// ``` + /// assert_eq!(Type::from_aprs_u8(15), Type::Obstacle); + /// assert_eq!(Type::from_aprs_u8(0), None); + /// ``` + /// + /// # References + /// - `aprs::get_aircraft_type_by_capture` + /// - [OGN Wiki](http://wiki.glidernet.org/wiki:ogn-flavoured-aprs#toc2) + pub fn from_aprs_u8(id: u8) -> Option { + match id { + 1 => Some(Self::Glider), + 2 => Some(Self::Tow), + 3 => Some(Self::Helicopter), + 4 => Some(Self::SkyDiver), + 5 => Some(Self::DropPlane), + 6 => Some(Self::HangGlider), + 7 => Some(Self::Paraglider), + 8 => Some(Self::MotorAircraft), + 9 => Some(Self::Jet), + 11 => Some(Self::Balloon), + 12 => Some(Self::Blimp), + 13 => Some(Self::Unmanned), + 15 => Some(Self::Obstacle), + _ => None, + } + } + + /// Returns the (english) name of a `Type` + /// + /// # Examples + /// ``` + /// assert_eq!(Type::Glider.get_name(), "(Motor) Glider"); + /// ``` + pub fn get_name(&self) -> &'static str { + match self { + Self::Glider => "(Motor) Glider", + Self::Tow => "Tow plane", + Self::Helicopter => "Helicopter / Gyrocopter", + Self::SkyDiver => "Skydiver / Parachute", + Self::DropPlane => "Drop plane", + Self::HangGlider => "Hang glider", + Self::Paraglider => "Paraglider", + Self::MotorAircraft => "Motor aircaft", + Self::Jet => "Jet", + Self::Balloon => "Balloon", + Self::Blimp => "Blimp", + Self::Unmanned => "Unmanned (Drone)", + Self::Obstacle => "Obstacle", + } + } +} + +/// Alias for `String`, just for readability. +pub type Id = String; + +impl Display for Aircraft { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + write!( + f, + "[ Id: {}, Call sign: {:?}, Registration: {:?}, Type: {:?}, Visible: {} ]", + self.id, self.call_sign, self.registration, self.model, self.visible + ) + } +} diff --git a/backend/src/ogn/aprs/client.rs b/backend/src/ogn/aprs/client.rs new file mode 100644 index 0000000..3a7ff3b --- /dev/null +++ b/backend/src/ogn/aprs/client.rs @@ -0,0 +1,172 @@ +use std::{ + collections::HashMap, + io::Error, +}; + +use log::{debug, error}; +use serde::Deserialize; +use tokio::io::{AsyncBufReadExt, BufReader, BufWriter}; +use tokio::{ + io::AsyncWriteExt, + net::{TcpStream, ToSocketAddrs}, + sync::mpsc::Sender, +}; + +use crate::{ + ogn::{Aircraft, AircraftId}, + time::get_current_timestamp, +}; + +use super::conversion::convert; +use super::status::Status; + +/// Messages starting with a hashtag are comments (e.g. keep alive messages) +const IDENTIFIER_COMMENT: char = '#'; +/// Messages starting with this sequence are connection details +const IDENTIFIER_TCP_PACKET: &str = "TCPIP*"; +/// Approx. interval of keep alive messages to the server (in seconds) +const KEEPALIVE_INTERVAL_SECONDS: u64 = 60 * 10; +/// Keep alive message +const KEEPALIVE_MESSAGE: &[u8; 12] = b"#keep alive\n"; + +/// Configuration for connecting to an APRS server +#[derive(Deserialize)] +pub struct Config { + /// Address to connect to, e.g. "aprs.example.com" + pub address: A, + /// User name for authentication + pub user_name: String, + /// Password for authentication + pub password: String, + /// Name of the application + pub client_id: String, + /// APRS filter that will be applied + pub filter: Option, +} + +/// Initiates a `TcpClient` that connects to an APRS server based on given `ClientConfig` and +/// transmits incoming aircraft states. Sends incoming APRS states via `status_tx`. +/// +/// # Arguments +/// +/// * `config` - Information on where to connect & login +/// * `status_tx` - A `Sender` that will send incoming states from the server +/// * `line_received_tx` - A `Sender` that will send timestamps of incoming APRS +/// lines from the server +/// * `aircraft` - Mapping of `AircraftId` => `Aircraft`, necessary for conversion +/// +/// # Returns +/// +/// Future that will either result to () or Error when an error occurs. +/// +/// # Examples +/// +/// ``` +/// use ogn::{Aircraft, AircraftId}; +/// use std::collections::HashMap; +/// use tokio::{spawn, sync::mpsc::channel}; +/// +/// let config = aprs::ClientConfig { ... }; +/// let (status_tx, status_rx) = channel(32); +/// let (line_received_tx, line_received_rx) = channel(32); +/// let aircraft: HashMap = HashMap::new(); +/// +/// spawn(async move { +/// aprs::init(&config, &status_tx, &line_received_tx, &aircraft) +/// .await +/// .expect("Client failed"); +/// }); +/// +/// while let Some(status) = status_rx.recv().await { +/// println!("Got status: {}", status); +/// } +/// ``` +pub async fn init( + config: &Config, + status_tx: &Sender, + line_received_tx: &Sender, + aircraft: &HashMap, +) -> Result<(), Error> { + let mut tcp_stream = TcpStream::connect(&config.address).await?; + let (mut read_half, mut write_half) = tcp_stream.split(); + + let mut tcp_stream_reader = BufReader::new(&mut read_half); + let mut tcp_stream_writer = BufWriter::new(&mut write_half); + + /* Login to server */ + let login_message = if let Some(filter) = &config.filter { + format!( + "user {} pass {} vers {} filter {}\n", + config.user_name, config.password, config.client_id, filter + ) + } else { + format!( + "user {} pass {} vers {}\n", + config.user_name, config.password, config.client_id + ) + }; + + let mut last_keep_alive_timestamp = get_current_timestamp(); + + tcp_stream_writer + .write_all(login_message.as_bytes()) + .await?; + tcp_stream_writer.flush().await?; + + loop { + let mut line = String::new(); + + match tcp_stream_reader.read_line(&mut line).await { + Ok(0) => { + debug!("Connection closed"); + return Ok(()); + } + Ok(_) => (), + Err(e) => { + /* This may happen */ + error!("Error while reading line: {e}"); + continue; + } + }; + + let current_timestamp = get_current_timestamp(); + + debug!("Got line: '{line}'"); + + line_received_tx + .send(current_timestamp) + .await + .or(Err(Error::other("Could not send line received timestamp")))?; + + /* APRS server sends a keep alive ever 20 - 30 seconds. As we don't want to worry about + * *another* async interval shit, we just check if the last keep alive was 10 - 11 minutes + * ago and, if so, send a new one. We won't run into a timeout if we're 30 seconds late, + * so KISS FTW. */ + if current_timestamp - last_keep_alive_timestamp >= KEEPALIVE_INTERVAL_SECONDS { + last_keep_alive_timestamp = current_timestamp; + + tcp_stream_writer.write_all(KEEPALIVE_MESSAGE).await?; + tcp_stream_writer.flush().await?; + + debug!("Sent keep alive"); + } + + if line.starts_with(IDENTIFIER_COMMENT) || line.contains(IDENTIFIER_TCP_PACKET) { + continue; + } + + if let Some(status) = convert(&line, aircraft) { + if !status.aircraft.visible { + debug!("Got message for non-visible aircraft. Discard."); + continue; + } + + debug!("Passing message for aircraft '{}'", status.aircraft.id); + + status_tx + .send(status) + .await + .or(Err(Error::other("Could not send status")))?; + } + } +} diff --git a/backend/src/ogn/aprs/conversion.rs b/backend/src/ogn/aprs/conversion.rs new file mode 100644 index 0000000..7f75dde --- /dev/null +++ b/backend/src/ogn/aprs/conversion.rs @@ -0,0 +1,498 @@ +use std::{collections::HashMap, sync::LazyLock}; + +use log::debug; +use regex::{Captures, Regex}; + +use crate::{ + ogn::{Aircraft, AircraftId, AircraftType}, + position::Position, + time::get_current_timestamp, +}; + +use super::status::Status; + +/// Regex pattern to extract data from valid APRS messages +/// +/// # Notes +/// +/// At the part of "idXXYYYYYY", "XX" must not be 40 or higher! +/// This is due to the fact that this 2-digit hex number contains the tracking-information as +/// _binary_ in the form of _0bSTxxxxxx_ and if _S_ = _1_ or _T_ = _1_, we should discard the +/// message. So all "allowed" values are in the range of _0b00000000_ - _0b00111111_, or in hex: +/// _0x00_ - _0x3f_, therefore we can discard all messages not in this range. +/// +/// see: [dbursem/ogn-client-php](https://github.com/dbursem/ogn-client-php/blob/master/lib/OGNClient.php#L87) +const LINE_PATTERN: &str = r"h(?[0-9.]+[NS])[/\\]?.(?[0-9.]+[WE]).(?:(?\d{3})/(?\d{3})/A=(?\d+))?.*?id(?[0-3]{1}[A-Fa-f0-9]{1})(?[A-Za-z0-9]+)(?: (?[-+0-9]+)fpm)?(?: (?[-+.0-9]+)rot)?"; + +/// Factor to convert knots to km/h +const FACTOR_KNOTS_TO_KM_H: f32 = 1.852; +/// Factor to convert ft to m +const FACTOR_FT_TO_M: f32 = 0.3048; +/// Factor to convert ft/min to m/s +const FACTOR_FT_MIN_TO_M_SEC: f32 = 0.00508; +/// Factor to convert "turns/2min" to "turns/min" +const FACTOR_TURNS_TWO_MIN_TO_TURNS_MIN: f32 = 0.5; + +static LINE_REGEX: LazyLock = LazyLock::new(|| Regex::new(LINE_PATTERN).unwrap()); + +/// Tries converting an APRS line into a `Status` +/// +/// # Arguments +/// +/// * `line` - The APRS line of the APRS server +/// * `aircraft` - Mapping of `AircraftId` => `Aircraft`, necessary for conversion +/// +/// # Examples +/// +/// ``` +/// use ogn::{Aircraft, AircraftId} +/// use std::collections::HashMap; +/// +/// let aircraft = Aircraft { +/// id: String::from("AB1234"), +/// call_sign: String::from("G1"), +/// registration: String::from("D-6507"), +/// aircraft_type: String::from("ASK-21"), +/// visible: true, +/// }; +/// +/// let mapping = HashMap::from([(aircraft.id.clone(), aircraft.clone())]); +/// +/// let line = "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N/00102.04W'086/007/A=000607 id0AAB1234 -019fpm +0.0rot 5.5dB 3e -4.3kHz"; +/// +/// let result = convert(line, &mapping); +/// assert!(result.is_some()); +/// assert_eq!(result.unwrap().aircraft.id, aircraft.id); +/// ``` +pub fn convert(line: &str, aircraft: &HashMap) -> Option { + let Some(captures) = LINE_REGEX.captures(line) else { + debug!("Line not parseable"); + return None; + }; + + let id = captures.name("id")?.as_str(); + + let aircraft = if let Some(a) = aircraft.get(id) { + if a.model.is_some() { + a.clone() + } else { + let model = get_aircraft_type_by_capture(&captures, "type") + .map(|t| t.get_name()) + .map(String::from); + + a.with_model(model) + } + } else { + debug!("Unknown aircraft id '{id}'"); + + let model = get_aircraft_type_by_capture(&captures, "type") + .map(|t| t.get_name()) + .map(String::from); + + Aircraft { + id: String::from(id), + call_sign: None, + registration: None, + model, + visible: true, + } + }; + + let status = Status { + aircraft, + position: Position { + latitude: capture_as_coordinate_value(&captures, "latitude")?, + longitude: capture_as_coordinate_value(&captures, "longitude")?, + }, + speed: capture_as_u16(&captures, "speed", FACTOR_KNOTS_TO_KM_H), + vertical_speed: capture_as_f32(&captures, "verticalSpeed", FACTOR_FT_MIN_TO_M_SEC), + altitude: capture_as_u16(&captures, "altitude", FACTOR_FT_TO_M), + turn_rate: capture_as_f32(&captures, "turnRate", FACTOR_TURNS_TWO_MIN_TO_TURNS_MIN), + course: capture_as_u16(&captures, "course", 1.0), + time_stamp: get_current_timestamp(), + }; + + Some(status) +} + +/// Tries converting a `Captures` value to `f32` and multiply it to a `conversion_factor` +/// +/// # Arguments +/// +/// * `captures` - The regex `Captures` to look up +/// * `name` - Name of the captured value that should be converted +/// * `conversion_factor` - The factor that the value should be multiplied with +/// +/// # Examples +/// +/// ``` +/// let captures = Regex::new(r"(?[\d.]+)") +/// .unwrap() +/// .captures("12.34") +/// .unwrap(); +/// +/// assert!(capture_as_f32(&captures, "value", 1.0).is_some_and(|f| f == 12.34)); +/// ``` +fn capture_as_f32(captures: &Captures, name: &str, conversion_factor: f32) -> Option { + let string_value = captures.name(name)?.as_str(); + let value = string_value.parse::().ok()?; + + Some(value * conversion_factor) +} + +/// Tries converting a `Captures` value to `u16` and multiply it to a `conversion_factor` +/// +/// # Arguments +/// +/// * `captures` - The regex `Captures` to look up +/// * `name` - Name of the captured value that should be converted +/// * `conversion_factor` - The factor that the value should be multiplied with +/// +/// # Examples +/// +/// ``` +/// let captures = Regex::new(r"(?\d+)") +/// .unwrap() +/// .captures("1234") +/// .unwrap(); +/// +/// assert!(capture_as_u16(&captures, "value", 1.0).is_some_and(|f| f == 1234)); +/// ``` +/// # Notes +/// +/// Returns `None` if _value_ * `conversion_factor` would under- / overflow `u16` ranges +fn capture_as_u16(captures: &Captures, name: &str, conversion_factor: f32) -> Option { + let string_value = captures.name(name)?.as_str(); + let value = string_value.parse::().ok()?; + let converted_value = f32::from(value) * conversion_factor; + + if converted_value < f32::from(u16::MIN) || converted_value > f32::from(u16::MAX) { + return None; + } + + /* We check for range and also sign. */ + #[allow(clippy::cast_possible_truncation)] + #[allow(clippy::cast_sign_loss)] + Some(converted_value as u16) +} + +/// Tries converting a `Captures` APRS coordinate value to a latitude / longitude value as `f32` +/// +/// # Arguments +/// +/// * `captures` - The regex `Captures` to look up +/// * `name` - Name of the captured value that should be converted +/// +/// # Examples +/// +/// ``` +/// let captures = Regex::new(r"(?.+)") +/// .unwrap() +/// .captures("1029.35S") +/// .unwrap(); +/// +/// assert!(capture_as_coordinate_value(&captures, "value").is_some_and(|f| f == -10.489166)); +/// ``` +fn capture_as_coordinate_value(captures: &Captures, name: &str) -> Option { + /* Latitude and longitude (by APRS-standard) are given as following: ddmm.mmD where d = "degree", + * m = "minute" and D = "direction". + * Notice that minutes are decimals, so 0.5 minutes equal 0 minutes, 30 secs. + * We'll separate degrees and minutes, so we can convert it to a "degree"-only value. */ + + let string_value = captures.name(name)?.as_str(); + let aprs_value = string_value + .chars() + .filter(char::is_ascii_digit) + .collect::() + .parse::() + .ok()?; + + let orientation = string_value.chars().last()?; /* "N", "E", "S" or "W" */ + + let degrees = f32::floor(aprs_value / 1_0000.0); // Separating "dd" from "ddmmmm" + let minutes = f32::floor(aprs_value % 1_0000.0) // Separating "mmmm" from "ddmmmm" + / 60.0 // because 60 minutes = 1 degree + / 100.0; // because of the removed decimal separator + + if (f64::from(degrees) + f64::from(minutes)) > f64::from(f32::MAX) { + /* Don't think that's possible but just to be sure */ + return None; + } + + let value = degrees + minutes; + + if orientation == 'S' || orientation == 'W' { + Some(-value) + } else { + Some(value) + } +} + +/// Tries extracting the aircraft type from a `Capture` of the first encoded id field +/// +/// # Arguments +/// +/// * `captures` - The regex `Captures` to look up +/// * `name` - Name of the captured value that should be converted +/// +/// # Examples +/// +/// ``` +/// let capture = Regex::new(r"(?.*)") +/// .unwrap() +/// .captures("2D") +/// .unwrap(); +/// +/// let aircraft_type = et_aircraft_type_by_capture(&capture, "value"); +/// +/// assert!(aircraft_typ.is_some()); +/// assert!(aircraft_type.unwrap() == AircraftType::Balloon); +/// ``` +/// +/// # References +/// +/// - [OGN Wiki](http://wiki.glidernet.org/wiki:ogn-flavoured-aprs#toc2) +fn get_aircraft_type_by_capture(captures: &Captures, name: &str) -> Option { + let string_value = captures.name(name)?.as_str(); + let value = u8::from_str_radix(string_value, 16).ok()?; + + /* Aircraft id field is built like this: "id" + "XX" + "YYYYYY" where the last part is the + * aircraft identifier (that matches DDB). "XX" is a 2-digit hex value built like this: + * 0bSTttttaa where "S" indicates stealth mode (should *NEVER* be sent over OGN), "T" is + * no-tracking mode (should *NEVER* be parsed by above_me), "tttt" is the aircraft type + * and "aa" is the address type. As we only need "tttt", we shift the whole number two + * digits to the left and just care for the lowest four bytes. */ + + /* This should *NEVER* happen! */ + assert_eq!( + value & 0b1000_0000, + 0, + "Line to be parsed has stealth mode active" + ); + + /* This should *NEVER* happen! */ + assert_eq!( + value & 0b0100_0000, + 0, + "Line to be parsed has no-tracking mode active" + ); + + let aircraft_type_value = (value >> 2) & 0b1111; + AircraftType::from_aprs_u8(aircraft_type_value) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn get_type_works() { + let regex = Regex::new(r"(?.*)").unwrap(); + + assert!( + get_aircraft_type_by_capture(®ex.captures("2D").unwrap(), "value") + .is_some_and(|t| t == AircraftType::Balloon) + ); + + assert!( + get_aircraft_type_by_capture(®ex.captures("07").unwrap(), "value") + .is_some_and(|t| t == AircraftType::Glider) + ); + + assert!(get_aircraft_type_by_capture(®ex.captures("00").unwrap(), "XXX").is_none()); + assert!(get_aircraft_type_by_capture(®ex.captures("ZZZZ").unwrap(), "value").is_none()); + assert!(get_aircraft_type_by_capture(®ex.captures("00").unwrap(), "value").is_none()); + } + + #[test] + #[should_panic] + fn get_type_panics_on_stealth_mode() { + let regex = Regex::new(r"(?.*)").unwrap(); + get_aircraft_type_by_capture(®ex.captures("80").unwrap(), "value"); + } + + #[test] + #[should_panic] + fn get_type_panics_on_no_tracking_mode() { + let regex = Regex::new(r"(?.*)").unwrap(); + get_aircraft_type_by_capture(®ex.captures("40").unwrap(), "value"); + } + + #[test] + fn convert_works() { + let valid_aircraft = Aircraft { + id: String::from("AB1234"), + call_sign: None, + registration: None, + model: None, + visible: true, + }; + + let mapping = HashMap::from([(valid_aircraft.id.clone(), valid_aircraft.clone())]); + + let data_set = &[ + ( + "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N/00102.04W'086/007/A=000607 id0AAB1234 -019fpm +0.0rot 5.5dB 3e -4.3kHz", + valid_aircraft.id.as_str(), + 51.188667, + Some(12), + Some(-0.09652), + Some(185), + Some(0.0), + Some(86) + ), + ( + "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N\\00102.04W'086/007/A=000607 id0AAB1234 5.5dB 3e -4.3kHz", + valid_aircraft.id.as_str(), + 51.188667, + Some(12), + None, + Some(185), + None, + Some(86) + ), + ( + "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N\\00102.04W' id0AAB1234 5.5dB 3e -4.3kHz", + valid_aircraft.id.as_str(), + 51.188667, + None, + None, + None, + None, + None + ), + ( + "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N/00102.04W' id0AAB1234 -019fpm +0.0rot 5.5dB 3e -4.3kHz", + valid_aircraft.id.as_str(), + 51.188667, + None, + Some(-0.09652), + None, + Some(0.0), + None + ), + ( + "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N/00102.04W'086/007/A=000607 id0AAB1234 +0.0rot 5.5dB 3e -4.3kHz", + valid_aircraft.id.as_str(), + 51.188667, + Some(12), + None, + Some(185), + Some(0.0), + Some(86) + ), + ( + "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N/00102.04W' id0AAB1234 +0.0rot 5.5dB 3e -4.3kHz", + valid_aircraft.id.as_str(), + 51.188667, + None, + None, + None, + Some(0.0), + None + ), + ]; + + for (line, aircraft_id, latitude, speed, vertical_speed, altitude, turn_rate, course) in + data_set + { + let result = convert(line, &mapping); + assert!(result.is_some()); + + let status = result.unwrap(); + assert_eq!(&status.aircraft.id, aircraft_id); + assert_eq!(&status.position.latitude, latitude); + assert_eq!(&status.speed, speed); + assert_eq!(&status.vertical_speed, vertical_speed); + assert_eq!(&status.altitude, altitude); + assert_eq!(&status.turn_rate, turn_rate); + assert_eq!(&status.course, course); + assert!(status.time_stamp > 0); + } + } + + #[test] + fn convert_works_with_unknown_aircraft() { + let mapping = HashMap::new(); + + let line = "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N/00102.04W'086/007/A=000607 id0AAB1234 -019fpm +0.0rot 5.5dB 3e -4.3kHz"; + + let result = convert(line, &mapping); + assert!(result.is_some()); + + let status = result.unwrap(); + assert_eq!(status.aircraft.id, "AB1234"); + assert!(status.aircraft.call_sign.is_none()); + assert!(status.aircraft.registration.is_none()); + assert!(status.aircraft.model.is_some_and(|v| v == "Tow plane")); + assert!(status.aircraft.visible); + } + + #[test] + fn convert_ignores_stealth_mode() { + let mapping = HashMap::new(); + let line = "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N/00102.04W'086/007/A=000607 id8AAB1234 -019fpm +0.0rot 5.5dB 3e -4.3kHz"; + assert!(convert(line, &mapping).is_none()); + } + + #[test] + fn convert_ignores_no_tracking_mode() { + let mapping = HashMap::new(); + let line = "FLRDDE626>APRS,qAS,EGHL:/074548h5111.32N/00102.04W'086/007/A=000607 id4AAB1234 -019fpm +0.0rot 5.5dB 3e -4.3kHz"; + assert!(convert(line, &mapping).is_none()); + } + + #[test] + fn test_capture_as_f32_works() { + let captures = Regex::new(r"(?[\d.]+)") + .unwrap() + .captures("12.34") + .unwrap(); + + assert!(capture_as_f32(&captures, "value", 1.0).is_some_and(|f| f == 12.34)); + assert!(capture_as_f32(&captures, "value", 2.0).is_some_and(|f| f == 24.68)); + } + + #[test] + fn test_capture_as_u16_works() { + let captures = Regex::new(r"(?\d+)") + .unwrap() + .captures("1234") + .unwrap(); + + assert!(capture_as_u16(&captures, "value", 1.0).is_some_and(|f| f == 1234)); + assert!(capture_as_u16(&captures, "value", 2.0).is_some_and(|f| f == 2468)); + } + + #[test] + fn test_capture_as_u16_fails_on_out_of_range() { + let captures = Regex::new(r"(?\d+)") + .unwrap() + .captures("1234") + .unwrap(); + + assert!(capture_as_u16(&captures, "value", 10.0).is_some()); + assert!(capture_as_u16(&captures, "value", 100.0).is_none()); + assert!(capture_as_u16(&captures, "value", -1.0).is_none()); + } + + #[test] + fn test_capture_as_coordinate_value_works() { + let captures = Regex::new(r"(?.+)") + .unwrap() + .captures("5111.32N") + .unwrap(); + + assert!(capture_as_coordinate_value(&captures, "value").is_some_and(|f| f == 51.188667)); + } + + #[test] + fn test_capture_as_coordinate_value_works_on_negative() { + let captures = Regex::new(r"(?.+)") + .unwrap() + .captures("1029.35S") + .unwrap(); + + assert!(capture_as_coordinate_value(&captures, "value").is_some_and(|f| f == -10.489166)); + } +} diff --git a/backend/src/ogn/aprs/status.rs b/backend/src/ogn/aprs/status.rs new file mode 100644 index 0000000..98040fb --- /dev/null +++ b/backend/src/ogn/aprs/status.rs @@ -0,0 +1,49 @@ +use std::fmt::{Display, Formatter, Result}; + +use crate::{ogn::Aircraft, position::Position}; + +/// Representation of an aircraft status +pub struct Status { + /// Affected aircraft + pub aircraft: Aircraft, + /// Position of aircraft + pub position: Position, + /// Speed in _km/h_ + pub speed: Option, + /// Vertical speed in _m/s_ + pub vertical_speed: Option, + /// Altitude in _m_ + pub altitude: Option, + /// Turn rate in _turns/min_ + pub turn_rate: Option, + /// Course of aircraft + pub course: Option, + /// Timestamp of receiving status + pub time_stamp: u64, +} + +impl Display for Status { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + write!( + f, + "[ + Aircraft: {}, + Position: {}, + Speed: {:?}, + Vertical speed: {:?}, + Altitude: {:?}, + Turn rate: {:?}, + Course: {:?}, + Timestamp: {} +]", + self.aircraft, + self.position, + self.speed, + self.vertical_speed, + self.altitude, + self.turn_rate, + self.course, + self.time_stamp + ) + } +} diff --git a/backend/src/ogn/ddb/client.rs b/backend/src/ogn/ddb/client.rs new file mode 100644 index 0000000..714fc1c --- /dev/null +++ b/backend/src/ogn/ddb/client.rs @@ -0,0 +1,38 @@ +use std::collections::HashMap; + +use reqwest::IntoUrl; + +use super::{conversion::convert, error}; +use crate::ogn::{Aircraft, AircraftId}; + +const LINE_BREAK: char = '\n'; + +/// Fetches aircraft data from DDB +/// +/// # Arguments +/// +/// * `url` - The DDB server url +/// +/// # Examples +/// ``` +/// let url = "https://ddb.example.com/aircraft" +/// let aircraft = fetch_aircraft(url) +/// .await +/// .expect("Could not fetch DDB data"); +/// ``` +pub async fn fetch_aircraft( + url: A, +) -> Result, error::Http> { + let response = reqwest::get(url) + .await + .map_err(|_| error::Http::FetchError)? + .text() + .await + .map_err(|_| error::Http::ResponseError)?; + + Ok(response + .split(LINE_BREAK) + .filter_map(convert) + .map(|a| (a.id.clone(), a)) + .collect::>()) +} diff --git a/backend/src/ogn/ddb/conversion.rs b/backend/src/ogn/ddb/conversion.rs new file mode 100644 index 0000000..e6f46f3 --- /dev/null +++ b/backend/src/ogn/ddb/conversion.rs @@ -0,0 +1,121 @@ +use crate::ogn::Aircraft; + +const VALUE_YES: &str = "Y"; +const FIELD_SEPARATOR: char = ','; +const IDENTIFIER_COMMENT: char = '#'; +const FIELD_ENCLOSURE: char = '\''; +const EMPTY: &str = ""; +const TYPE_UNKNOWN: &str = "Unknown"; + +const INDEX_ID: usize = 1; +const INDEX_TYPE: usize = 2; +const INDEX_REGISTRATION: usize = 3; +const INDEX_CALL_SIGN: usize = 4; +const INDEX_TRACKED: usize = 5; +const INDEX_IDENTIFIED: usize = 6; + +/// Tries converting a line of DDB into an `Aircraft` representation +/// +/// # Arguments +/// +/// * `line` - The line that should be converted +/// +/// # Examples +/// +/// ``` +/// let aircraft = convert("'O','AB1234','ASK-21','D-6507','G1','Y','Y'").unwrap(); +/// assert_eq!(aircraft.registration, "D-6507"); +/// ``` +pub fn convert(line: &str) -> Option { + if line.starts_with(IDENTIFIER_COMMENT) { + return None; + } + + let line = line.replace(FIELD_ENCLOSURE, EMPTY); + + let fields = line + .split(FIELD_SEPARATOR) + .map(str::trim) + .collect::>(); + + if fields.len() < 7 { + return None; + } + + let model = if fields[INDEX_TYPE] == TYPE_UNKNOWN { + None + } else { + get_as_option(fields[INDEX_TYPE]) + }; + + Some(Aircraft { + id: get_as_option(fields[INDEX_ID])?, + call_sign: get_as_option(fields[INDEX_CALL_SIGN]), + registration: get_as_option(fields[INDEX_REGISTRATION]), + model, + visible: fields[INDEX_IDENTIFIED] == VALUE_YES && fields[INDEX_TRACKED] == VALUE_YES, + }) +} + +/// Returns `Some(String)`, if `value` is not empty. +/// Otherwise returns `None` +/// +/// # Arguments +/// +/// * `value` - Value that may be wrapped +/// +/// # Examples +/// ``` +/// assert!(get_as_option("").is_none()); +/// assert!(get_as_option("Value").is_some_and(|v|v == "Value")); +/// ``` +fn get_as_option(value: &str) -> Option { + if value.is_empty() { + None + } else { + Some(String::from(value)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn converts_correctly() { + let line = "'O','AB1234','ASK-21','D-6507','G1','Y','Y'"; + + let result = convert(line); + assert!(result.is_some()); + + let aircraft = result.unwrap(); + assert_eq!(aircraft.id, "AB1234"); + assert!(aircraft.call_sign.is_some_and(|v| v == "G1")); + assert!(aircraft.registration.is_some_and(|v| v == "D-6507")); + assert!(aircraft.model.is_some_and(|v| v == "ASK-21")); + assert!(aircraft.visible); + } + + #[test] + fn handles_empty_values_correctly() { + let line = "'O','AB1234','Unknown','','G1','Y','Y'"; + + let result = convert(line); + assert!(result.is_some()); + + let aircraft = result.unwrap(); + assert_eq!(aircraft.id, "AB1234"); + assert!(aircraft.call_sign.is_some_and(|v| v == "G1")); + assert!(aircraft.registration.is_none()); + assert!(aircraft.model.is_none()); + assert!(aircraft.visible); + } + + #[test] + fn sets_visible_correctly() { + assert!(convert("'O','AB1234','','','','Y','Y'").is_some_and(|a| a.visible)); + assert!(convert("'O','AB1234','','','','Y','N'").is_some_and(|a| !a.visible)); + assert!(convert("'O','AB1234','','','','N','Y'").is_some_and(|a| !a.visible)); + assert!(convert("'O','AB1234','','','','N','N'").is_some_and(|a| !a.visible)); + } +} diff --git a/backend/src/ogn/ddb/error.rs b/backend/src/ogn/ddb/error.rs new file mode 100644 index 0000000..63c4870 --- /dev/null +++ b/backend/src/ogn/ddb/error.rs @@ -0,0 +1,19 @@ +use std::fmt::{Display, Formatter, Result}; + +/// Enum of `Error`s for failing HTTP requests +#[derive(Debug)] +pub enum Http { + /// Could not fetch data + FetchError, + /// The response is not valid + ResponseError, +} + +impl Display for Http { + fn fmt(&self, f: &mut Formatter) -> Result { + match self { + Self::FetchError => write!(f, "Could not fetch data"), + Self::ResponseError => write!(f, "Invalid response"), + } + } +} diff --git a/backend/src/ogn/mod.rs b/backend/src/ogn/mod.rs new file mode 100644 index 0000000..f27e002 --- /dev/null +++ b/backend/src/ogn/mod.rs @@ -0,0 +1,21 @@ +mod aircraft; + +pub mod aprs { + mod client; + mod conversion; + mod status; + + pub use client::{init, Config}; + pub use status::Status; +} +pub mod ddb { + mod client; + mod conversion; + mod error; + + pub use client::fetch_aircraft; +} + +pub use aircraft::Aircraft; +pub use aircraft::Id as AircraftId; +pub use aircraft::Type as AircraftType; diff --git a/backend/src/position.rs b/backend/src/position.rs new file mode 100644 index 0000000..adb1dfb --- /dev/null +++ b/backend/src/position.rs @@ -0,0 +1,90 @@ +use std::fmt::{Display, Formatter, Result}; + +use serde::Serialize; + +const EARTH_MEAN_RADIUS_KM: f32 = 6371.0; + +/// Representation of a position +#[derive(Clone, Serialize)] +pub struct Position { + /// Latitude + pub latitude: f32, + /// Longitude + pub longitude: f32, +} + +/// Calculates the distance of two given positions in km. +/// +/// # Arguments +/// +/// * `pos1` - The first position +/// * `pos2` - The second position +/// +/// # Examples +/// ``` +/// use aprs::Position +/// +/// let pos1 = Position { +/// latitude: 48.858222, +/// longitude: 2.2945, +/// }; +/// +/// let pos2 = Position { +/// latitude: 48.86055, +/// longitude: 2.3376, +/// }; +/// +/// assert_eq!(calculate_distance(&pos1, &pos2), 3.1636212); +/// assert_eq!(calculate_distance(&pos2, &pos1), 3.1636212); +/// ``` +/// +/// # Resources +/// +/// * [www.geeksforgeeks.org](https://www.geeksforgeeks.org/haversine-formula-to-find-distance-between-two-points-on-a-sphere/) +/// * [www.movable-type.co.uk](https://www.movable-type.co.uk/scripts/latlong.html) +pub fn calculate_distance(pos1: &Position, pos2: &Position) -> f32 { + let delta_latitude = (pos1.latitude - pos2.latitude).to_radians(); + let delta_longitude = (pos1.longitude - pos2.longitude).to_radians(); + + let latitude_1 = pos1.latitude.to_radians(); + let latitude_2 = pos2.latitude.to_radians(); + + let a = (delta_latitude / 2.0).sin().powi(2) + + (delta_longitude / 2.0).sin().powi(2) * latitude_1.cos() * latitude_2.cos(); + + let c = 2.0 * a.sqrt().asin(); + + c * EARTH_MEAN_RADIUS_KM +} + +impl Display for Position { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + write!( + f, + "[ Latitude: {}, Longitude: {} ]", + self.latitude, self.longitude + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn calculates_correct_distance() { + let pos1 = Position { + latitude: 48.858222, + longitude: 2.2945, + }; + + let pos2 = Position { + latitude: 48.86055, + longitude: 2.3376, + }; + + /* This value matches online calculators, so I assume it's correct */ + assert_eq!(calculate_distance(&pos1, &pos2), 3.1636212); + assert_eq!(calculate_distance(&pos2, &pos1), 3.1636212); + } +} diff --git a/backend/src/time.rs b/backend/src/time.rs new file mode 100644 index 0000000..d709055 --- /dev/null +++ b/backend/src/time.rs @@ -0,0 +1,27 @@ +use std::time::{SystemTime, UNIX_EPOCH}; + +/// Returns current unix timestamp +/// +/// # Examples +/// +/// ``` +/// assert!(get_current_timestamp() > 0); +/// ``` +pub fn get_current_timestamp() -> u64 { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("Could not get unix timestamp") + .as_secs() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + /// Possibly dump test + /// Ensures that function does not fail and returns some value + fn timestamp_not_empty() { + assert!(get_current_timestamp() > 0); + } +} diff --git a/config.example.json b/config.example.json new file mode 100644 index 0000000..78c3d58 --- /dev/null +++ b/config.example.json @@ -0,0 +1,11 @@ +{ + "aprs": { + "address": "aprs.example.com", + "user_name": "MYC4LLS1GN", + "password": "************", + "filter": "r/12.3/45.6/78", + "client_id": "my-program 0.1" + }, + "ddb_url": "https://example.com/aircraft", + "bind_to": "127.0.0.1:8000" +} \ No newline at end of file diff --git a/docker/.env.example b/docker/.env.example new file mode 100644 index 0000000..e5b672b --- /dev/null +++ b/docker/.env.example @@ -0,0 +1,7 @@ +ABOVE_ME__APRS__ADDRESS=aprs.example.com +ABOVE_ME__APRS__USER_NAME=MYC4LLS1GN +ABOVE_ME__APRS__PASSWORD=************ +ABOVE_ME__APRS__FILTER=r/12.3/45.6/78 +ABOVE_ME__APRS__CLIENT_ID=my-program 0.1 +ABOVE_ME__DDB_URL=https://example.com/aircraft +RUST_LOG=warn \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..6fc05ee --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,23 @@ +services: + backend: + build: + context: ../backend + environment: + - ABOVE_ME__BIND_TO=0.0.0.0:9000 + env_file: + - .env + frontend: + build: + context: ../frontend + restart: unless-stopped + gateway: + image: nginx + depends_on: + - backend + - frontend + restart: unless-stopped + ports: + - "127.0.0.1:9000:8080" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + - ./privacy-policy.html:/usr/share/nginx/html/privacy-policy.html:ro diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..d1e37ca --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,53 @@ +events { + worker_connections 1024; +} + +http { + include mime.types; + + default_type application/octet-stream; + + sendfile on; + + server_tokens off; + + server { + listen 8080; + server_name _; + + add_header Content-Security-Policy "default-src 'self' 'unsafe-inline' data:;"; + add_header Permissions-Policy "geolocation=(), midi=(), camera=(), usb=(), payment=(), vr=(), speaker=(), ambient-light-sensor=(), gyroscope=(), microphone=(), usb=(), interest-cohort=()"; + add_header Referer "no-referrer"; + add_header Referrer-Policy "no-referrer"; + add_header Strict-Transport-Security "max-age=63072000" always; + add_header Surrogate-Control "public"; + add_header X-Content-Type-Options "nosniff"; + add_header X-Frame-Options "DENY"; + + client_max_body_size 1; + + location /r/ { + # Do not log location data + access_log off; + error_log /dev/null emerg; + proxy_pass http://backend:9000/r/; + } + + location /status { + proxy_pass http://backend:9000/status; + } + + gzip on; + gzip_types *; + expires 1d; + + location = /privacy-policy.html { + root /usr/share/nginx/html; + try_files /privacy-policy.html =404; + } + + location / { + proxy_pass http://frontend:80/; + } + } +} \ No newline at end of file diff --git a/docker/privacy-policy.html b/docker/privacy-policy.html new file mode 100644 index 0000000..a379a37 --- /dev/null +++ b/docker/privacy-policy.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..25b8b70 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,32 @@ +FROM node:alpine AS install + +WORKDIR /app + +COPY package-lock.json . +COPY package.json . + +RUN npm i + +FROM install AS compile + +WORKDIR /app + +COPY src src +RUN mkdir dist +RUN npx handlebars src/table.handlebars -f dist/table.handlebars.compiled.js + +COPY --from=install /app/node_modules/handlebars/dist/handlebars.min.js dist +COPY --from=install /app/node_modules/bootstrap/dist/js/bootstrap.min.js dist +COPY --from=install /app/node_modules/bootstrap/dist/js/bootstrap.min.js.map dist +COPY --from=install /app/node_modules/bootstrap/dist/css/bootstrap.min.css dist +COPY --from=install /app/node_modules/bootstrap/dist/css/bootstrap.min.css.map dist +COPY src/index.html dist +COPY src/privacy-policy.html dist +COPY src/main.js dist +COPY src/style.css dist + +FROM nginx:alpine + +COPY --from=compile /app/dist /usr/share/nginx/html + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json new file mode 100644 index 0000000..58a744d --- /dev/null +++ b/frontend/package-lock.json @@ -0,0 +1,111 @@ +{ + "name": "above_me", + "version": "0.1.4", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "above_me", + "version": "0.1.4", + "license": "MIT", + "dependencies": { + "bootstrap": "^5.3.8", + "handlebars": "^4.7.8" + } + }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "license": "MIT", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, + "node_modules/bootstrap": { + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.8.tgz", + "integrity": "sha512-HP1SZDqaLDPwsNiqRqi5NcP0SSXciX2s9E+RyqJIIqGo+vJeN5AJVM98CXmW/Wux0nQ5L7jeWUdplCEf0Ee+tg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ], + "license": "MIT", + "peerDependencies": { + "@popperjs/core": "^2.11.8" + } + }, + "node_modules/handlebars": { + "version": "4.7.8", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", + "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", + "license": "MIT", + "dependencies": { + "minimist": "^1.2.5", + "neo-async": "^2.6.2", + "source-map": "^0.6.1", + "wordwrap": "^1.0.0" + }, + "bin": { + "handlebars": "bin/handlebars" + }, + "engines": { + "node": ">=0.4.7" + }, + "optionalDependencies": { + "uglify-js": "^3.1.4" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", + "license": "MIT" + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/uglify-js": { + "version": "3.19.3", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", + "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==", + "license": "BSD-2-Clause", + "optional": true, + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", + "license": "MIT" + } + } +} diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..0e6b017 --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,25 @@ +{ + "name": "above_me", + "version": "0.1.4", + "description": "This project contains the frontend for above_me, a service that lets you see what aircraft are currently flying above you.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "copy-dependencies": "rm -rf dist && rsync -av --exclude='*.handlebars' src/ dist/ && cp node_modules/handlebars/dist/handlebars.min.js dist/ && cp node_modules/bootstrap/dist/js/bootstrap.min.js dist && cp node_modules/bootstrap/dist/js/bootstrap.min.js.map dist && cp node_modules/bootstrap/dist/css/bootstrap.min.css dist && cp node_modules/bootstrap/dist/css/bootstrap.min.css.map dist", + "compile": "handlebars src/table.handlebars -f dist/table.handlebars.compiled.js", + "dev": "npm run copy-dependencies && npm run compile && cd dist && python3 -m http.server 8080" + }, + "keywords": [ + "ogn", + "openglidernet", + "open-glider-net", + "aircraft", + "glider" + ], + "author": "Laika Schmidt", + "license": "MIT", + "dependencies": { + "bootstrap": "^5.3.8", + "handlebars": "^4.7.8" + } +} \ No newline at end of file diff --git a/frontend/src/index.html b/frontend/src/index.html new file mode 100644 index 0000000..f9a30ff --- /dev/null +++ b/frontend/src/index.html @@ -0,0 +1,103 @@ + + + + + + + + above_me + + + + + + + + + +
+

See what's flying right above you!

+ +
+ +
+ By clicking this button you accept our privacy policy and also + that + your current position is sent to the webserver. +
+
+ + + + + + + +
+ +

+ Either click What's above me? to automatically fetch your location + or enter specific coordinates and range and see whats flying above you right now. +

+

+ This site works with data provided by the + Open Glider Network. + (Thank you for your open data & APIs! 😊) +

+ +
+
+ + +
+
+ + +
+
+ + +
+ Range (in km) around given coordinates that should be filtered for. +
+
+
+ +
+ By clicking this button you accept our privacy policy and also + that the given position is sent to the webserver. +
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/frontend/src/main.js b/frontend/src/main.js new file mode 100644 index 0000000..86243a1 --- /dev/null +++ b/frontend/src/main.js @@ -0,0 +1,109 @@ +function submit(event) { + document.getElementById('http-error').style.display = 'none'; + + if (event) { + event.preventDefault(); + } + + const latitude = document.querySelector('#latitude').value; + const longitude = document.querySelector('#longitude').value; + const range = document.querySelector('#range').value; + + if (!latitude || !longitude || !range) { + return; + } + + const url = window.location.origin + `/r/${latitude}/${longitude}/${range}`; + + const currentTimestamp = Math.round(Date.now() / 1000); + + fetch(url) + .then(response => response.json()) + .then(response => response.states) + .then(states => + states.map(s => ({ + ...s, + speed: s.speed?.toFixed(0), + vertical_speed: s.vertical_speed?.toFixed(1), + altitude: s.altitude?.toFixed(0), + turn_rate: s.turn_rate?.toFixed(1), + course: s.course?.toFixed(0), + position: { + ...s.position, + longitude_text: formatCoordinateValue(s.position.longitude, 'E', 'W'), + latitude_text: formatCoordinateValue(s.position.latitude, 'N', 'S'), + }, + time_diff: formatTimeDiff(s.time_stamp, currentTimestamp), + distance: s.distance.toFixed(0), + }) + )) + .then(states => + Handlebars.templates.table({ states }) + ) + .then(html => { + document.getElementById('table-container').innerHTML = html; + }) + .catch(error => { + document.getElementById('http-error').style.display = 'inherit'; + console.error(error); + }) +} + +function formatCoordinateValue(latitude, directionPositive, directionNegative) { + const degrees = Math.floor(latitude); + const minutes = (latitude - degrees) * 60; + const seconds = (minutes % 1) * 60; + + const direction = latitude > 0 ? directionPositive : directionNegative; + + return `${degrees.toString().padStart(3, '0')}°${minutes.toFixed(0)}'${seconds.toFixed(0)}" ${direction}` +} + +function formatTimeDiff(timestamp1, timestamp2) { + const diff = Math.abs(timestamp1 - timestamp2); + + if (diff === 0) { + return 'now'; + } + + if (diff < 60) { + return `${diff} s`; + } + + return `${Math.round(diff / 60)} min`; +} + +function onClickWhatsAboveMe() { + document.querySelector('#loading-position').style.display = 'inherit'; + + navigator.geolocation.getCurrentPosition( + (position) => { + document.querySelector('#latitude').value = Math.round(position.coords.latitude * 1_000_000_000) / 1_000_000_000; + document.querySelector('#longitude').value = Math.round(position.coords.longitude * 1_000_000_000) / 1_000_000_000; + document.querySelector('#no-position-available').style.display = 'none'; + document.querySelector('#loading-position').style.display = 'none'; + submit(); + }, + () => { + document.querySelector('#no-position-available').style.display = 'inherit'; + document.querySelector('#loading-position').style.display = 'none'; + }); +} + +(function init() { + const urlParams = new URLSearchParams(window.location.search); + for (let param of ['longitude', 'latitude', 'range']) { + if (!urlParams.has(param)) { + continue; + } + + let value = parseFloat(urlParams.get(param)); + if (!value || isNaN(value)) { + continue; + } + + document.querySelector(`#${param}`).value = value; + } +})(); + +document.querySelector('form').addEventListener('submit', submit); \ No newline at end of file diff --git a/frontend/src/privacy-policy.html b/frontend/src/privacy-policy.html new file mode 100644 index 0000000..a379a37 --- /dev/null +++ b/frontend/src/privacy-policy.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/style.css b/frontend/src/style.css new file mode 100644 index 0000000..1685b1f --- /dev/null +++ b/frontend/src/style.css @@ -0,0 +1,73 @@ +nav { + margin-bottom: 3%; +} + +.button-container { + margin: 20% 0; + display: flex; + justify-content: center; + flex-direction: column; +} + +form { + margin-top: 12.5%; +} + +form .button-container { + margin-top: 12.5%; +} + +@media (min-width: 576px) { + .button-container { + margin: 5% 0; + } + + form { + margin-top: 5%; + } + + form .button-container { + margin-top: 5%; + } +} + +#table-container { + margin: 5% 0; + white-space: nowrap; +} + +.status-message { + display: none; +} + +h3 { + text-align: center; +} + +.form-text { + text-align: center; +} + +.links * { + padding-left: 10px; + color: white; + text-decoration: none; +} + +.links *:hover { + text-decoration: underline; +} + +.variable-value { + text-align: right; +} + +.units * { + font-weight: normal; + text-align: right; + font-style: italic; +} + +.units * b { + font-weight: bold; +} \ No newline at end of file diff --git a/frontend/src/table.handlebars b/frontend/src/table.handlebars new file mode 100644 index 0000000..f9ec115 --- /dev/null +++ b/frontend/src/table.handlebars @@ -0,0 +1,91 @@ +{{#if states}} + + + + + + + + + + + + + + + + + + + + + + + + + + + {{#each states}} + + + + + + + + + + + + {{/each}} + +
IdDistanceAltitudeSpeedCourseVertical speedTurn ratePositionLast status
+ Registration (call sign)
+ Model / type +
kmmkm/h°m/sturns/min + Link to map
+ (live.glidernet.org) +
+ {{#if aircraft.registration}} + {{aircraft.registration}} + {{#if aircraft.call_sign}}({{aircraft.call_sign}}){{/if}} +
{{aircraft.model}} + {{/if}} + {{#unless aircraft.registration}} + unknown + {{#if aircraft.model}}
{{/if}} + {{aircraft.model}} + {{/unless}} +
+ {{#if distance}}{{distance}}{{/if}} + {{#unless distance}}-{{/unless}} + + {{#if altitude}}{{altitude}}{{/if}} + {{#unless altitude}}-{{/unless}} + + {{#if speed}}{{speed}}{{/if}} + {{#unless speed}}-{{/unless}} + + {{#if course}}{{course}}{{/if}} + {{#unless course}}-{{/unless}} + + {{#if vertical_speed}}{{vertical_speed}}{{/if}} + {{#unless vertical_speed}}-{{/unless}} + + {{#if turn_rate}}{{turn_rate}}{{/if}} + {{#unless turn_rate}}-{{/unless}} + + + {{position.latitude_text}}
+ {{position.longitude_text}} +
+
+ {{time_diff}} +
+{{/if}} +{{#unless states}} + +{{/unless}} \ No newline at end of file diff --git a/openapi.yml b/openapi.yml new file mode 100644 index 0000000..1c1058b --- /dev/null +++ b/openapi.yml @@ -0,0 +1,231 @@ +openapi: 3.1.0 +info: + title: above_me API + description: |- + The above_me API allows you to fetch information about aircraft for a given position based on the [Open Glider Network](http://wiki.glidernet.org/) data. + contact: + email: laika.schmidt@magenta.de + license: + name: MIT License + url: https://opensource.org/license/mit + version: "0.1.4" +tags: + - name: aircaft + description: Information about aircraft +paths: + /status: + get: + tags: + - status + summary: Gets current API status + description: |- + Returns information about last status update and number of currently + stored states. Can be helpful to check whether the backend still + receives new states. + operationId: getStatus + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: "#/components/schemas/SystemStatus" + /r/{latitude}/{longitude}/{range}: + get: + tags: + - aircaft + summary: Get information about aircraft for a given position + description: |- + Returns information for all aircraft that appeared in the last 5 minutes + in the range of given _latitude_ ± _range_ and _longitude_ ± _range_. + operationId: getAircraftForPosition + parameters: + - name: latitude + in: path + description: Latitude filter + example: 48.858222 + required: true + schema: + type: number + format: float + - name: longitude + in: path + description: Longitude filter + example: 2.2945 + required: true + schema: + type: number + format: float + - name: range + in: path + description: Range around filter position + example: 15.0 + required: true + schema: + type: number + format: float + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: "#/components/schemas/AircraftStatusOverview" + "400": + description: Invalid parameters given + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + schemas: + AircraftStatusOverview: + required: + - latitude + - longitude + - range + - states + type: object + properties: + latitude: + type: number + format: float + examples: [48.858222] + description: Equals given latitude parameter + longitude: + type: number + format: float + examples: [2.2945] + description: Equals given longitude parameter + range: + type: number + format: float + examples: [15.0] + description: Equals given range parameter + states: + type: array + items: + $ref: "#/components/schemas/AircraftStatus" + description: |- + The aircraft states that match the given parameters sorted in ascending oder by distance to given position + AircraftStatus: + type: object + properties: + aircraft: + $ref: "#/components/schemas/Aircraft" + position: + $ref: "#/components/schemas/Position" + speed: + type: + - integer + - "null" + format: int32 + examples: [132] + description: Speed of aircraft in _km/h_ + minimum: 0 + vertical_speed: + type: + - number + - "null" + format: float + examples: [0.32] + description: Vertical speed of aircraft in _m/sec_ + altitude: + type: + - integer + - "null" + format: int32 + examples: [3431] + description: Altitude of aircraft in _m_ + turn_rate: + type: + - number + - "null" + format: float + examples: [3.5] + descripion: Turn rate of aircaft in _turns/min_ + course: + type: + - integer + - "null" + format: int32 + examples: [152] + description: Course of aircraft + minimum: 0 + maximum: 360 + time_stamp: + type: integer + format: int64 + examples: [670932000] + description: Unix timestamp of latest aircraft status + minimum: 0 + distance: + type: + - number + format: float + examples: [13.121989] + description: Distance (in km) of the aircraft to the requested postion + Aircraft: + type: object + properties: + call_sign: + type: + - string + - "null" + examples: ["G1"] + description: Call sign of aircraft + registration: + type: + - string + - "null" + examples: ["D-6507"] + description: Registration of aircraft + model: + type: + - string + - "null" + examples: ["ASK-21"] + description: Airplane model + Position: + type: object + properties: + latitude: + type: number + format: float + examples: [48.858222] + description: Latitude + longitude: + type: number + format: float + examples: [2.2945] + description: Longitude + Error: + type: string + examples: + [ + 'Invalid URL: Cannot parse value at index 2 with value `"-50000"` to a `u32`', + ] + SystemStatus: + type: object + properties: + count: + type: integer + examples: [40] + description: Number of currently stored states + minimum: 0 + last_status_update: + type: + - integer + - "null" + format: int64 + examples: [670932000] + description: Unix timestamp of latest incoming state + minimum: 0 + last_aprs_update: + type: + - integer + - "null" + format: int64 + examples: [670932000] + description: Unix timestamp of latest incoming APRS server message + minimum: 0