diff --git a/Cargo.lock b/Cargo.lock index c41d012..2bf2c5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rand", + "rand 0.9.1", "sha1", "smallvec", "tokio", @@ -316,6 +316,28 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "aws-lc-rs" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88aab2464f1f25453baa7a07c84c5b7684e274054ba06817f382357f77a288" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45afffdee1e7c9126814751f88dddc747f41d91da16c9551a0f1e8a11e788a1" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + [[package]] name = "backtrace" version = "0.3.75" @@ -402,21 +424,34 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.23" +version = "1.2.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766" +checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" dependencies = [ + "find-msvc-tools", "jobserver", "libc", "shlex", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chrono" version = "0.4.41" @@ -432,12 +467,31 @@ dependencies = [ "windows-link", ] +[[package]] +name = "cmake" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d" +dependencies = [ + "cc", +] + [[package]] name = "colorchoice" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "cookie" version = "0.16.2" @@ -459,6 +513,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -520,7 +584,7 @@ dependencies = [ [[package]] name = "datafeed-cache-client" -version = "1.3.2" +version = "1.3.3" dependencies = [ "datafeed-cache-shared", "dotenv", @@ -532,7 +596,7 @@ dependencies = [ [[package]] name = "datafeed-cache-server" -version = "1.3.2" +version = "1.3.3" dependencies = [ "actix-web", "chrono", @@ -540,7 +604,8 @@ dependencies = [ "env_logger", "geo", "log", - "rand", + "once_cell", + "rand 0.9.1", "reqwest", "serde", "tokio", @@ -548,7 +613,7 @@ dependencies = [ [[package]] name = "datafeed-cache-shared" -version = "1.3.2" +version = "1.3.3" dependencies = [ "chrono", "serde", @@ -611,6 +676,12 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "earcutr" version = "0.4.3" @@ -666,20 +737,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] -name = "errno" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" -dependencies = [ - "libc", - "windows-sys 0.59.0", -] - -[[package]] -name = "fastrand" -version = "2.3.0" +name = "find-msvc-tools" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" [[package]] name = "flate2" @@ -709,21 +770,6 @@ 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.1" @@ -733,6 +779,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures-channel" version = "0.3.31" @@ -740,6 +792,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -748,6 +801,12 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + [[package]] name = "futures-sink" version = "0.3.31" @@ -767,9 +826,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", + "futures-io", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -784,9 +847,9 @@ dependencies = [ [[package]] name = "geo" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fc1a1678e54befc9b4bcab6cd43b8e7f834ae8ea121118b0fd8c42747675b4a" +checksum = "3f3901269ec6d4f6068d3f09e5f02f995bd076398dcd1dfec407cd230b02d11b" dependencies = [ "earcutr", "float_next_after", @@ -795,16 +858,18 @@ dependencies = [ "i_overlay", "log", "num-traits", + "rand 0.8.5", "robust", "rstar", + "sif-itree", "spade", ] [[package]] name = "geo-types" -version = "0.7.17" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75a4dcd69d35b2c87a7c83bce9af69fd65c9d68d3833a0ded568983928f3fc99" +checksum = "24f8647af4005fa11da47cd56252c6ef030be8fa97bdbf355e7dfb6348f0a82c" dependencies = [ "approx", "num-traits", @@ -829,8 +894,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -840,9 +907,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", "wasi 0.14.2+wasi-0.2.4", + "wasm-bindgen", ] [[package]] @@ -978,19 +1047,21 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.6.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ + "atomic-waker", "bytes", "futures-channel", - "futures-util", + "futures-core", "h2 0.4.10", "http 1.3.1", "http-body", "httparse", "itoa", "pin-project-lite", + "pin-utils", "smallvec", "tokio", "want", @@ -1013,40 +1084,30 @@ dependencies = [ "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.11" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" +checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" dependencies = [ + "base64", "bytes", "futures-channel", + "futures-core", "futures-util", "http 1.3.1", "http-body", "hyper", + "ipnet", "libc", + "percent-encoding", "pin-project-lite", "socket2", + "system-configuration", "tokio", "tower-service", "tracing", + "windows-registry", ] [[package]] @@ -1245,6 +1306,16 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +[[package]] +name = "iri-string" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -1290,6 +1361,28 @@ dependencies = [ "syn", ] +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "jobserver" version = "0.1.33" @@ -1328,12 +1421,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" -[[package]] -name = "linux-raw-sys" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" - [[package]] name = "litemap" version = "0.8.0" @@ -1373,6 +1460,12 @@ version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + [[package]] name = "memchr" version = "2.7.4" @@ -1406,23 +1499,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[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 = "num-conv" version = "0.1.0" @@ -1454,49 +1530,11 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" -[[package]] -name = "openssl" -version = "0.10.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" -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.108" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] +checksum = "9f50d9b3dabb09ecd771ad0aa242ca6894994c130308ca3d7684634df8037391" [[package]] name = "parking_lot" @@ -1593,6 +1631,62 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.17", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.3.3", + "lru-slab", + "rand 0.9.1", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.17", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "quote" version = "1.0.40" @@ -1608,14 +1702,35 @@ version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + [[package]] name = "rand" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ - "rand_chacha", - "rand_core", + "rand_chacha 0.9.0", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", ] [[package]] @@ -1625,7 +1740,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.16", ] [[package]] @@ -1703,13 +1827,14 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.15" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" +checksum = "04e9018c9d814e5f30cc16a0f03271aeab3571e609612d9fe78c1aa8d11c2f62" dependencies = [ "base64", "bytes", "encoding_rs", + "futures-channel", "futures-core", "futures-util", "h2 0.4.10", @@ -1718,31 +1843,28 @@ dependencies = [ "http-body-util", "hyper", "hyper-rustls", - "hyper-tls", "hyper-util", - "ipnet", "js-sys", "log", "mime", - "native-tls", - "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", + "quinn", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", "serde", "serde_json", - "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", - "tokio-native-tls", + "tokio-rustls", "tower", + "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "windows-registry", ] [[package]] @@ -1783,17 +1905,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] -name = "rustix" -version = "1.0.7" +name = "rustc-hash" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.59.0", -] +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustls" @@ -1801,6 +1916,7 @@ version = "0.23.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321" dependencies = [ + "aws-lc-rs", "once_cell", "rustls-pki-types", "rustls-webpki", @@ -1809,12 +1925,15 @@ dependencies = [ ] [[package]] -name = "rustls-pemfile" -version = "2.2.0" +name = "rustls-native-certs" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" dependencies = [ + "openssl-probe", "rustls-pki-types", + "schannel", + "security-framework", ] [[package]] @@ -1823,15 +1942,44 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" dependencies = [ + "web-time", "zeroize", ] +[[package]] +name = "rustls-platform-verifier" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d99feebc72bae7ab76ba994bb5e121b8d83d910ca40b36e0921f53becc41784" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + [[package]] name = "rustls-webpki" version = "0.103.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -1849,6 +1997,15 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.27" @@ -1866,12 +2023,12 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "security-framework" -version = "2.11.1" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -1879,9 +2036,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" dependencies = [ "core-foundation-sys", "libc", @@ -1948,6 +2105,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "sif-itree" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "142099cd6db3c4fab61e5133c62ff80b26674391e195860791fda0b1be3e5080" + [[package]] name = "signal-hook-registry" version = "1.4.5" @@ -2044,7 +2207,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -2059,16 +2222,43 @@ dependencies = [ ] [[package]] -name = "tempfile" -version = "3.20.0" +name = "thiserror" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "fastrand", - "getrandom 0.3.3", - "once_cell", - "rustix", - "windows-sys 0.59.0", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +dependencies = [ + "thiserror-impl 2.0.17", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -2112,6 +2302,21 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.45.0" @@ -2141,16 +2346,6 @@ dependencies = [ "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.2" @@ -2189,6 +2384,24 @@ dependencies = [ "tower-service", ] +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http 1.3.1", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -2286,18 +2499,22 @@ 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 = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -2403,6 +2620,34 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-root-certs" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36a29fc0408b113f68cf32637857ab740edfafdf460c326cd2afaa2d84cc05dc" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "windows-core" version = "0.61.1" @@ -2482,6 +2727,15 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -2500,6 +2754,21 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.52.6" @@ -2532,6 +2801,12 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -2544,6 +2819,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -2556,6 +2837,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -2580,6 +2867,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -2592,6 +2885,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -2604,6 +2903,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -2616,6 +2921,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" diff --git a/Cargo.toml b/Cargo.toml index 0eba122..7cd67a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "3" members = [ "datafeed-cache-client", "datafeed-cache-server", diff --git a/datafeed-cache-client/Cargo.toml b/datafeed-cache-client/Cargo.toml index 1410e7f..c9af62d 100644 --- a/datafeed-cache-client/Cargo.toml +++ b/datafeed-cache-client/Cargo.toml @@ -1,16 +1,19 @@ [package] name = "datafeed-cache-client" edition = "2024" -version = "1.3.2" +version = "1.3.3" [dependencies] -reqwest = { version = "0.12.15", features = ["json"] } +reqwest = { version = "0.13.1", features = ["json"] } serde = { version = "1.0.219", features = ["derive"] } dotenv = { version = "0.15.0" } datafeed-cache-shared = { path = "../datafeed-cache-shared" } env_logger = "0.11.7" log = "0.4.27" +[features] +blocking = ["reqwest/blocking"] + [lib] name = "datafeed_cache_client" path = "src/lib.rs" \ No newline at end of file diff --git a/datafeed-cache-client/src/client.rs b/datafeed-cache-client/src/client.rs index d58fd68..41a6191 100644 --- a/datafeed-cache-client/src/client.rs +++ b/datafeed-cache-client/src/client.rs @@ -2,93 +2,74 @@ use datafeed_cache_shared::datafeed::{ DatafeedAtis, DatafeedController, DatafeedMilitaryRating, DatafeedPilot, DatafeedPilotRating, DatafeedServer, }; -use datafeed_cache_shared::response::{ - DatafeedGeneralResponse, DatafeedListResponse, DatafeedResponse, -}; -use log::info; -use reqwest::Client; +use datafeed_cache_shared::response::{DatafeedGeneralResponse, DatafeedGerStatsResponse, DatafeedListResponse, DatafeedResponse}; use serde::de::DeserializeOwned; - -pub struct DatafeedClient { - client: Client, - base_url: String, -} - -const BASE_DEFAULT: &'static str = "https://df.vatsim-germany.org"; +use crate::DatafeedClient; type Error = reqwest::Error; -#[allow(dead_code)] impl DatafeedClient { - pub fn new() -> Self { - let _ = env_logger::try_init(); - let _ = dotenv::dotenv(); - - let base_url: String = dotenv::var("BASE_URL").unwrap_or(BASE_DEFAULT.to_string()); - info!("Selected BASE_URL: {}", base_url); - DatafeedClient { - client: Client::default(), - base_url, - } - } - - async fn make_request(&self, path: &str) -> Result + fn make_request(&self, path: &str) -> Result where T: DeserializeOwned, { let req = self.client.get(self.base_url.to_owned() + path).build()?; - let response = self.client.execute(req).await?; - response.json::().await + let response = self.client.execute(req)?; + response.json::() } - pub async fn get(&self) -> Result { - self.make_request("/datafeed").await + pub fn get(&self) -> Result, Error> { + self.make_request("/datafeed") } - pub async fn get_general(&self) -> Result { - self.make_request("/datafeed/general").await + pub fn get_general(&self) -> Result, Error> { + self.make_request("/datafeed/general") } - pub async fn get_controllers(&self) -> Result, Error> { - self.make_request("/datafeed/controllers").await + pub fn get_controllers(&self) -> Result, Error> { + self.make_request("/datafeed/controllers") } - pub async fn get_pilots(&self) -> Result, Error> { - self.make_request("/datafeed/pilots").await + pub fn get_pilots(&self) -> Result, Error> { + self.make_request("/datafeed/pilots") } - pub async fn get_atis(&self) -> Result, Error> { - self.make_request("/datafeed/atis").await + pub fn get_atis(&self) -> Result, Error> { + self.make_request("/datafeed/atis") } - pub async fn get_servers(&self) -> Result, Error> { - self.make_request("/datafeed/servers").await + pub fn get_servers(&self) -> Result, Error> { + self.make_request("/datafeed/servers") } - pub async fn get_pilot_ratings( + pub fn get_pilot_ratings( &self, - ) -> Result, Error> { - self.make_request("/datafeed/pilot_ratings").await + ) -> Result, Error> { + self.make_request("/datafeed/pilot_ratings") } - pub async fn get_military_ratings( + pub fn get_military_ratings( &self, - ) -> Result, Error> { - self.make_request("/datafeed/military_ratings").await + ) -> Result, Error> { + self.make_request("/datafeed/military_ratings") } - pub async fn get_ger_controllers( + pub fn get_ger_controllers( &self, - ) -> Result, Error> { - self.make_request("/datafeed/controllers/ger").await + ) -> Result, Error> { + self.make_request("/datafeed/controllers/ger") + } + + pub fn get_ger_pilots(&self) -> Result, Error> { + self.make_request("/datafeed/pilots/ger") } - pub async fn get_ger_pilots(&self) -> Result, Error> { - self.make_request("/datafeed/pilots/ger").await + pub fn get_ger_atis(&self) -> Result, Error> { + self.make_request("/datafeed/atis/ger") } - pub async fn get_ger_atis(&self) -> Result, Error> { - self.make_request("/datafeed/atis/ger").await + pub fn get_ger_stats(&self) -> Result { + self.make_request("/datafeed/stats") } } diff --git a/datafeed-cache-client/src/client_async.rs b/datafeed-cache-client/src/client_async.rs new file mode 100644 index 0000000..9b819d2 --- /dev/null +++ b/datafeed-cache-client/src/client_async.rs @@ -0,0 +1,74 @@ +use datafeed_cache_shared::datafeed::{ + DatafeedAtis, DatafeedController, DatafeedMilitaryRating, DatafeedPilot, DatafeedPilotRating, + DatafeedServer, +}; +use datafeed_cache_shared::response::{DatafeedGeneralResponse, DatafeedGerStatsResponse, DatafeedListResponse, DatafeedResponse}; +use serde::de::DeserializeOwned; +use crate::DatafeedClient; + +type Error = reqwest::Error; + +impl DatafeedClient { + async fn make_request(&self, path: &str) -> Result + where + T: DeserializeOwned, + { + let req = self.client.get(self.base_url.to_owned() + path).build()?; + let response = self.client.execute(req).await?; + response.json::().await + } + + pub async fn get(&self) -> Result, Error> { + self.make_request("/datafeed").await + } + + pub async fn get_general(&self) -> Result, Error> { + self.make_request("/datafeed/general").await + } + + pub async fn get_controllers(&self) -> Result, Error> { + self.make_request("/datafeed/controllers").await + } + + pub async fn get_pilots(&self) -> Result, Error> { + self.make_request("/datafeed/pilots").await + } + + pub async fn get_atis(&self) -> Result, Error> { + self.make_request("/datafeed/atis").await + } + + pub async fn get_servers(&self) -> Result, Error> { + self.make_request("/datafeed/servers").await + } + + pub async fn get_pilot_ratings( + &self, + ) -> Result, Error> { + self.make_request("/datafeed/pilot_ratings").await + } + + pub async fn get_military_ratings( + &self, + ) -> Result, Error> { + self.make_request("/datafeed/military_ratings").await + } + + pub async fn get_ger_controllers( + &self, + ) -> Result, Error> { + self.make_request("/datafeed/controllers/ger").await + } + + pub async fn get_ger_pilots(&self) -> Result, Error> { + self.make_request("/datafeed/pilots/ger").await + } + + pub async fn get_ger_atis(&self) -> Result, Error> { + self.make_request("/datafeed/atis/ger").await + } + + pub async fn get_ger_stats(&self) -> Result { + self.make_request("/datafeed/stats").await + } +} diff --git a/datafeed-cache-client/src/lib.rs b/datafeed-cache-client/src/lib.rs index 841f477..ea4bbfc 100644 --- a/datafeed-cache-client/src/lib.rs +++ b/datafeed-cache-client/src/lib.rs @@ -1,8 +1,39 @@ +use log::info; + +#[cfg(feature = "blocking")] pub mod client; +#[cfg(feature = "blocking")] +use reqwest::blocking::Client; + +#[cfg(not(feature = "blocking"))] +pub mod client_async; + +#[cfg(not(feature = "blocking"))] +use reqwest::Client; + pub mod shared { pub use datafeed_cache_shared::*; } -// TODO: Add Tests here which force the functions to work, even if the datafeed-cache has been -// TODO: modified +pub struct DatafeedClient { + client: Client, + base_url: String, +} + +const BASE_DEFAULT: &'static str = "https://df.vatsim-germany.org"; + +impl DatafeedClient { + pub fn new() -> Self { + let _ = env_logger::try_init(); + let _ = dotenv::dotenv(); + + let base_url: String = dotenv::var("BASE_URL").unwrap_or(BASE_DEFAULT.to_string()); + info!("Selected BASE_URL: {}", base_url); + + DatafeedClient { + client: Client::default(), + base_url, + } + } +} \ No newline at end of file diff --git a/datafeed-cache-server/Cargo.toml b/datafeed-cache-server/Cargo.toml index a93fe90..e4704be 100644 --- a/datafeed-cache-server/Cargo.toml +++ b/datafeed-cache-server/Cargo.toml @@ -1,19 +1,20 @@ [package] name = "datafeed-cache-server" edition = "2024" -version = "1.3.2" +version = "1.3.3" [dependencies] tokio = { version = "1.44.1", features = ["macros", "rt-multi-thread", "time"] } actix-web = { version = "4.10.2" } -reqwest = { version = "0.12.15", features = ["json"] } +reqwest = { version = "0.13.1", features = ["json"] } serde = { version = "1.0.219", features = ["derive"] } rand = "0.9.0" env_logger = "0.11.7" log = "0.4.27" -geo = { version = "0.31.0" } +geo = { version = "0.32.0" } chrono = { version = "0.4.40", features = ["serde"] } datafeed-cache-shared = { path = "../datafeed-cache-shared" } +once_cell = "1.21.3" [[bin]] name = "datafeed_cache_server" diff --git a/datafeed-cache-server/src/api/handlers.rs b/datafeed-cache-server/src/api/handlers.rs index 85d32ba..2fc813f 100644 --- a/datafeed-cache-server/src/api/handlers.rs +++ b/datafeed-cache-server/src/api/handlers.rs @@ -8,10 +8,10 @@ use datafeed_cache_shared::datafeed::{ use datafeed_cache_shared::response::{ DatafeedGeneralResponse, DatafeedGerListResponse, DatafeedListResponse, DatafeedResponse, }; -use geo::{Contains, Coord}; use serde::Serialize; use std::borrow::Cow; use std::ops::Deref; +use crate::api::helper; #[actix_web::get("")] async fn get_datafeed(data: ApiStateData) -> HttpResponse { @@ -144,20 +144,12 @@ async fn get_ger_controllers_datafeed(data: ApiStateData) -> HttpResponse { let read_lock = data.shared_state.read().await; let status = read_lock.deref(); - let controllers = status.data.as_ref().map_or(Vec::new(), |df| { - df.controllers - .iter() - .filter(|controller| { - (controller.callsign.starts_with("ED") || controller.callsign.starts_with("ET")) - && controller.frequency != "199.998" - }) - .cloned() - .collect() - }); + let controllers = helper::get_ger_controllers(&status.data); + let length = controllers.len(); HttpResponse::Ok().json(DatafeedGerListResponse { - data: Cow::Borrowed(&controllers), - length: controllers.len(), + data: Cow::Owned(controllers), + length, failed: status.failed, }) } @@ -167,21 +159,12 @@ async fn get_ger_pilots_datafeed(data: ApiStateData) -> HttpResponse { let read_lock = data.shared_state.read().await; let status = read_lock.deref(); - let pilots = status.data.as_ref().map_or(Vec::new(), |df| { - df.pilots - .iter() - .filter(|pilot| { - let coord: Coord = - Coord::from((pilot.latitude.into(), pilot.longitude.into())); - data.ger_poly.contains(&coord) - }) - .cloned() - .collect() - }); + let pilots = helper::get_ger_pilots(&status.data); + let length = pilots.len(); HttpResponse::Ok().json(DatafeedGerListResponse { - data: Cow::Borrowed(&pilots), - length: pilots.len(), + data: Cow::Owned(pilots), + length, failed: status.failed, }) } @@ -202,9 +185,43 @@ async fn get_ger_atis_datafeed(data: ApiStateData) -> HttpResponse { .collect() }); + let length = atis.len(); HttpResponse::Ok().json(DatafeedGerListResponse { - data: Cow::Borrowed(&atis), - length: atis.len(), + data: Cow::Owned(atis), + length, + failed: status.failed, + }) +} + +#[actix_web::get("/stats")] +async fn get_stats(data: ApiStateData) -> HttpResponse { + #[derive(Serialize)] + struct StatsResponse { + len_pilots: usize, + len_controllers: usize, + len_pilots_ger: usize, + len_controllers_ger: usize, + failed: bool, + } + + let read_lock = data.shared_state.read().await; + let status = read_lock.deref(); + + let ger_pilots = helper::get_ger_pilots(&status.data); + let ger_controllers = helper::get_ger_controllers(&status.data); + + let (len_pilots, len_controllers) = match &status.data { + Some(df) => { + (df.pilots.len(), df.controllers.len()) + }, + None => (0, 0), + }; + + HttpResponse::Ok().json(StatsResponse { + len_pilots, + len_controllers, + len_pilots_ger: ger_pilots.len(), + len_controllers_ger: ger_controllers.len(), failed: status.failed, }) } diff --git a/datafeed-cache-server/src/api/helper.rs b/datafeed-cache-server/src/api/helper.rs new file mode 100644 index 0000000..4eb1c9a --- /dev/null +++ b/datafeed-cache-server/src/api/helper.rs @@ -0,0 +1,51 @@ +use geo::{Contains, Coord, LineString, Polygon}; +use once_cell::sync::Lazy; +use datafeed_cache_shared::datafeed::{Datafeed, DatafeedController, DatafeedPilot}; + +const GERMANY_POLY_DEF: &[(f64, f64)] = &[ + (47.610078, 7.476857), + (48.97135, 8.189489), + (49.466566, 6.380295), + (51.028373, 5.932113), + (54.84348, 7.145719), + (54.642252, 14.133224), + (50.843505, 14.750028), + (50.249433, 12.140394), + (48.675772, 13.854829), + (47.475928, 12.926649), +]; + +pub(crate) static GERMANY_POLY: Lazy = Lazy::new(|| { + Polygon::new(LineString::from(GERMANY_POLY_DEF.to_vec()), vec![]) +}); + +pub(crate) fn get_ger_pilots(df: &Option) -> Vec { + match df { + Some(df) => { + df.pilots.iter() + .filter(|pilot| { + let coord: Coord = + Coord::from((pilot.latitude.into(), pilot.longitude.into())); + GERMANY_POLY.contains(&coord) + }) + .cloned() + .collect() + } + None => {vec![]} + } +} + +pub(crate) fn get_ger_controllers(df: &Option) -> Vec { + match df { + Some(df) => { + df.controllers.iter() + .filter(|controller| { + (controller.callsign.starts_with("ED") || controller.callsign.starts_with("ET")) + && controller.frequency != "199.998" + }) + .cloned() + .collect() + } + None => {vec![]} + } +} \ No newline at end of file diff --git a/datafeed-cache-server/src/api/mod.rs b/datafeed-cache-server/src/api/mod.rs index 15d5046..d6bad84 100644 --- a/datafeed-cache-server/src/api/mod.rs +++ b/datafeed-cache-server/src/api/mod.rs @@ -5,6 +5,7 @@ use actix_web::{App, HttpServer, middleware, web}; mod handlers; mod state; +mod helper; pub(crate) async fn init_api(shared_datafeed: DatafeedSharedState) -> std::io::Result<()> { let api_state = web::Data::new(ApiState::new(shared_datafeed)); @@ -28,7 +29,8 @@ pub(crate) async fn init_api(shared_datafeed: DatafeedSharedState) -> std::io::R .service(handlers::get_mil_pilot_ratings_datafeed) .service(handlers::get_ger_controllers_datafeed) .service(handlers::get_ger_pilots_datafeed) - .service(handlers::get_ger_atis_datafeed), + .service(handlers::get_ger_atis_datafeed) + .service(handlers::get_stats), ) .service(handlers::get_health_check) }) diff --git a/datafeed-cache-server/src/api/state.rs b/datafeed-cache-server/src/api/state.rs index ed95b04..a0084ef 100644 --- a/datafeed-cache-server/src/api/state.rs +++ b/datafeed-cache-server/src/api/state.rs @@ -1,31 +1,15 @@ use crate::vatsim::DatafeedSharedState; -use geo::{LineString, Polygon}; - -const GERMANY_POLY: &[(f64, f64)] = &[ - (47.610078, 7.476857), - (48.97135, 8.189489), - (49.466566, 6.380295), - (51.028373, 5.932113), - (54.84348, 7.145719), - (54.642252, 14.133224), - (50.843505, 14.750028), - (50.249433, 12.140394), - (48.675772, 13.854829), - (47.475928, 12.926649), -]; pub(crate) type ApiStateData = actix_web::web::Data; pub(crate) struct ApiState { pub(crate) shared_state: DatafeedSharedState, - pub(crate) ger_poly: Polygon, } impl ApiState { pub(crate) fn new(shared_state: DatafeedSharedState) -> Self { Self { shared_state, - ger_poly: Polygon::new(LineString::from(GERMANY_POLY.to_vec()), vec![]), } } } diff --git a/datafeed-cache-shared/Cargo.toml b/datafeed-cache-shared/Cargo.toml index 0019353..cbda73d 100644 --- a/datafeed-cache-shared/Cargo.toml +++ b/datafeed-cache-shared/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "datafeed-cache-shared" edition = "2024" -version = "1.3.2" +version = "1.3.3" [dependencies] serde = { version = "1.0.219", features = ["derive"] } diff --git a/datafeed-cache-shared/src/datafeed.rs b/datafeed-cache-shared/src/datafeed.rs index c8cd2f4..13cfcba 100644 --- a/datafeed-cache-shared/src/datafeed.rs +++ b/datafeed-cache-shared/src/datafeed.rs @@ -133,3 +133,14 @@ pub struct Datafeed { pub type DatafeedRating = DatafeedFacility; pub type DatafeedMilitaryRating = DatafeedPilotRating; + + +impl PartialEq for DatafeedController { + fn eq(&self, other: &Self) -> bool { + self.callsign == other.callsign && + self.frequency == other.frequency && + self.cid == other.cid + } +} + +impl Eq for DatafeedController {} \ No newline at end of file diff --git a/datafeed-cache-shared/src/response.rs b/datafeed-cache-shared/src/response.rs index 0b73e92..41fe30c 100644 --- a/datafeed-cache-shared/src/response.rs +++ b/datafeed-cache-shared/src/response.rs @@ -36,3 +36,13 @@ where pub length: usize, pub failed: bool, } + +#[derive(Serialize, Deserialize, Debug)] +pub struct DatafeedGerStatsResponse +{ + pub len_pilots: usize, + pub len_controllers: usize, + pub len_pilots_ger: usize, + pub len_controllers_ger: usize, + pub failed: bool, +} \ No newline at end of file