From 72d75194d40e5183026914346260a803e8f1a7fa Mon Sep 17 00:00:00 2001 From: Martin Hoffmann Date: Fri, 19 May 2023 13:35:20 +0200 Subject: [PATCH 1/7] Add /json-delta/notify endpoint. --- Cargo.lock | 333 ++++++++++++++++++------------------------- Cargo.toml | 6 +- src/http/listener.rs | 13 +- src/http/mod.rs | 8 ++ src/http/notify.rs | 41 ++++++ src/operation.rs | 8 +- src/rtr.rs | 9 +- 7 files changed, 207 insertions(+), 211 deletions(-) create mode 100644 src/http/notify.rs diff --git a/Cargo.lock b/Cargo.lock index 2de28eae..9ecb81ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ "anstyle", "anstyle-parse", @@ -58,9 +58,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -117,9 +117,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" [[package]] name = "bytes" @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.2" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b802d85aaf3a1cdb02b224ba472ebdea62014fccfcb269b95a4d76443b5ee5a" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ "clap_builder", "clap_derive", @@ -169,9 +169,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.2" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14a1a858f532119338887a4b8e1af9c60de8249cd7bafd68036a489e261e37b6" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" dependencies = [ "anstream", "anstyle", @@ -191,7 +191,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -200,16 +200,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "colorchoice" version = "1.0.0" @@ -260,50 +250,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "cxx" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.15", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.15", -] - [[package]] name = "derive_arbitrary" version = "1.3.0" @@ -412,9 +358,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "miniz_oxide", @@ -506,7 +452,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -552,9 +498,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b91535aa35fea1523ad1b86cb6b53c28e0ae566ba4a460f4457e936cad7c6f" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -667,15 +613,15 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.2" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" dependencies = [ "http", "hyper", - "rustls", + "rustls 0.21.1", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.0", ] [[package]] @@ -707,12 +653,11 @@ dependencies = [ [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -781,9 +726,9 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -796,24 +741,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.141" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" - -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "linux-raw-sys" -version = "0.3.1" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" [[package]] name = "listenfd" @@ -875,9 +811,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] @@ -972,9 +908,9 @@ checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "openssl" -version = "0.10.50" +version = "0.10.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e30d8bc91859781f0a943411186324d580f2bbeb71b452fe91ae344806af3f1" +checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56" dependencies = [ "bitflags", "cfg-if", @@ -993,7 +929,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -1004,9 +940,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.85" +version = "0.9.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d3d193fb1488ad46ffe3aaabc912cc931d02ee8518fe2959aea8ef52718b0c0" +checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" dependencies = [ "cc", "libc", @@ -1034,9 +970,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "ppv-lite86" @@ -1046,9 +982,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" dependencies = [ "unicode-ident", ] @@ -1064,9 +1000,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -1132,9 +1068,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.16" +version = "0.11.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" dependencies = [ "base64 0.21.0", "bytes", @@ -1155,14 +1091,14 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.21.1", "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio", "tokio-native-tls", - "tokio-rustls", + "tokio-rustls 0.24.0", "tokio-socks", "tower-service", "url", @@ -1233,7 +1169,7 @@ dependencies = [ "syslog", "tempfile", "tokio", - "tokio-rustls", + "tokio-rustls 0.23.4", "tokio-stream", "toml", "uuid", @@ -1252,9 +1188,8 @@ dependencies = [ [[package]] name = "rpki" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "207f773b99ae73e14f8e8ab0f789a5892fc46548b1b79caccec8f33e2d303c40" +version = "0.16.2-dev" +source = "git+https://github.com/NLnetLabs/rpki-rs.git#38e364c2770e731a1fa383d7545db5b597bb7282" dependencies = [ "arbitrary", "base64 0.13.1", @@ -1276,9 +1211,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.11" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85597d61f83914ddeba6a47b3b8ffe7365107221c2e557ed94426489fefb5f77" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", "errno", @@ -1300,6 +1235,18 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustls" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + [[package]] name = "rustls-pemfile" version = "1.0.2" @@ -1309,6 +1256,16 @@ dependencies = [ "base64 0.21.0", ] +[[package]] +name = "rustls-webpki" +version = "0.100.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "ryu" version = "1.0.13" @@ -1324,12 +1281,6 @@ dependencies = [ "windows-sys 0.42.0", ] -[[package]] -name = "scratch" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" - [[package]] name = "sct" version = "0.7.0" @@ -1342,9 +1293,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.8.2" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ "bitflags", "core-foundation", @@ -1355,9 +1306,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" dependencies = [ "core-foundation-sys", "libc", @@ -1365,22 +1316,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -1465,9 +1416,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" dependencies = [ "proc-macro2", "quote", @@ -1476,15 +1427,15 @@ dependencies = [ [[package]] name = "syslog" -version = "6.0.1" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978044cc68150ad5e40083c9f6a725e6fd02d7ba1bcf691ec2ff0d66c0b41acc" +checksum = "7434e95bcccce1215d30f4bf84fe8c00e8de1b9be4fb736d747ca53d36e7f96f" dependencies = [ "error-chain", "hostname", "libc", "log", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -1511,15 +1462,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - [[package]] name = "terminal_size" version = "0.2.6" @@ -1547,7 +1489,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -1563,9 +1505,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ "itoa", "libc", @@ -1577,15 +1519,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] @@ -1607,9 +1549,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" dependencies = [ "autocfg", "bytes", @@ -1620,18 +1562,18 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.16", ] [[package]] @@ -1650,11 +1592,21 @@ version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ - "rustls", + "rustls 0.20.8", "tokio", "webpki", ] +[[package]] +name = "tokio-rustls" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5" +dependencies = [ + "rustls 0.21.1", + "tokio", +] + [[package]] name = "tokio-socks" version = "0.5.1" @@ -1669,9 +1621,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", "pin-project-lite", @@ -1680,9 +1632,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -1720,9 +1672,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", ] @@ -1754,12 +1706,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "untrusted" version = "0.7.1" @@ -1785,9 +1731,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b55a3fef2a1e3b3a00ce878640918820d3c51081576ac657d23af9fc7928fdb" +checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" [[package]] name = "vcpkg" @@ -1825,9 +1771,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1835,24 +1781,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.34" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" dependencies = [ "cfg-if", "js-sys", @@ -1862,9 +1808,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1872,28 +1818,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.16", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -1934,15 +1880,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 88b6001c..b84e431a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ rand = "0.8.1" reqwest = { version = "0.11.0", default-features = false, features = ["blocking", "rustls-tls" ] } ring = "0.16.12" routecore = "0.3.1" -rpki = { version = "0.16.1", features = [ "repository", "rrdp", "rtr", "serde", "slurm" ] } +rpki = { git = "https://github.com/NLnetLabs/rpki-rs.git", features = [ "repository", "rrdp", "rtr", "serde", "slurm" ] } rustls-pemfile = "1" serde = { version = "1.0.95", features = [ "derive" ] } serde_json = "1.0.57" @@ -55,9 +55,9 @@ syslog = "6" [features] default = [ "socks", "ui"] arbitrary = [ "dep:arbitrary", "chrono/arbitrary", "rpki/arbitrary" ] -socks = [ "reqwest/socks" ] -rta = [] native-tls = [ "reqwest/native-tls", "tls" ] +rta = [] +socks = [ "reqwest/socks" ] tls = [] ui = [ "routinator-ui" ] diff --git a/src/http/listener.rs b/src/http/listener.rs index 1d1bea55..8b85f88f 100644 --- a/src/http/listener.rs +++ b/src/http/listener.rs @@ -13,6 +13,7 @@ use hyper::Server; use hyper::server::accept::Accept; use hyper::service::{make_service_fn, service_fn}; use log::error; +use rpki::rtr::server::NotifySender; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio::net::TcpListener; use tokio_rustls::TlsAcceptor; @@ -34,6 +35,7 @@ pub fn http_listener( rtr_metrics: SharedRtrServerMetrics, log: Option>, config: &Config, + notify: NotifySender, ) -> Result, ExitError> { let metrics = Arc::new(HttpServerMetrics::default()); @@ -51,7 +53,7 @@ pub fn http_listener( ); } } - Ok(_http_listener(origins, metrics, rtr_metrics, log, listeners)) + Ok(_http_listener(origins, metrics, rtr_metrics, log, notify, listeners)) } fn create_tls_config( @@ -79,6 +81,7 @@ async fn _http_listener( metrics: Arc, rtr_metrics: SharedRtrServerMetrics, log: Option>, + notify: NotifySender, listeners: Vec<(SocketAddr, Option>, StdListener)>, ) { // If there are no listeners, just never return. @@ -93,6 +96,7 @@ async fn _http_listener( addr, tls_config, listener, origins.clone(), metrics.clone(), rtr_metrics.clone(), log.clone(), + notify.clone(), )) }) ).await; @@ -104,6 +108,7 @@ async fn _http_listener( /// listener, in which case it will print an error and resolve the error case. /// It will listen bind a Hyper server onto `addr` and produce any data /// served from `origins`. +#[allow(clippy::too_many_arguments)] async fn single_http_listener( addr: SocketAddr, tls_config: Option>, @@ -112,22 +117,26 @@ async fn single_http_listener( metrics: Arc, rtr_metrics: SharedRtrServerMetrics, log: Option>, + notify: NotifySender, ) { let make_service = make_service_fn(|_conn| { let origins = origins.clone(); let metrics = metrics.clone(); let rtr_metrics = rtr_metrics.clone(); let log = log.clone(); + let notify = notify.clone(); async move { Ok::<_, Infallible>(service_fn(move |req| { let origins = origins.clone(); let metrics = metrics.clone(); let rtr_metrics = rtr_metrics.clone(); let log = log.clone(); + let notify = notify.clone(); async move { Ok::<_, Infallible>(handle_request( req, &origins, &metrics, &rtr_metrics, - log.as_ref().map(|x| x.as_ref()) + log.as_ref().map(|x| x.as_ref()), + ¬ify, ).await.into_hyper()) } })) diff --git a/src/http/mod.rs b/src/http/mod.rs index 23d50713..2ea2e32d 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -14,6 +14,7 @@ mod delta; mod listener; mod log; mod metrics; +mod notify; mod payload; mod response; mod status; @@ -24,6 +25,7 @@ mod validity; //------------ handle_request ------------------------------------------------ use hyper::{Body, Method, Request}; +use rpki::rtr::server::NotifySender; use crate::metrics::{HttpServerMetrics, SharedRtrServerMetrics}; use crate::payload::SharedHistory; use crate::process::LogOutput; @@ -36,6 +38,7 @@ async fn handle_request( metrics: &HttpServerMetrics, rtr_metrics: &SharedRtrServerMetrics, log: Option<&LogOutput>, + notify: &NotifySender, ) -> Response { metrics.inc_requests(); if *req.method() != Method::GET && *req.method() != Method::HEAD { @@ -45,6 +48,11 @@ async fn handle_request( if let Some(response) = payload::handle_get_or_head(&req, origins) { return response } + if let Some(response) = notify::handle_get_or_head( + &req, origins, notify, + ).await { + return response + } if let Some(response) = delta::handle_get_or_head(&req, origins) { return response } diff --git a/src/http/notify.rs b/src/http/notify.rs new file mode 100644 index 00000000..1cd95771 --- /dev/null +++ b/src/http/notify.rs @@ -0,0 +1,41 @@ +//! Handles the notification websocket. + +use hyper::{Body, Method, Request}; +use rpki::rtr::server::{NotifySender, PayloadSource}; +use crate::payload::SharedHistory; +use crate::utils::json::JsonBuilder; +use super::response::{ContentType, Response, ResponseBuilder}; + + +//------------ handle_get_or_head -------------------------------------------- + +pub async fn handle_get_or_head( + req: &Request, + history: &SharedHistory, + notify: &NotifySender, +) -> Option { + if req.uri().path() != "/json-delta/notify" { + return None + } + + notify.subscribe().recv().await; + + let state = history.notify(); + + if *req.method() == Method::HEAD { + Some( + ResponseBuilder::ok().content_type(ContentType::JSON).empty() + ) + } + else { + Some( + ResponseBuilder::ok().content_type(ContentType::JSON).body( + JsonBuilder::build(|json| { + json.member_raw("session", state.session()); + json.member_raw("serial", state.serial()); + }) + ) + ) + } +} + diff --git a/src/operation.rs b/src/operation.rs index e7d06503..b4f8f513 100644 --- a/src/operation.rs +++ b/src/operation.rs @@ -228,12 +228,14 @@ impl Server { ); let history = SharedHistory::from_config(process.config()); - let (mut notify, rtr) = rtr_listener( + let mut notify = NotifySender::new(); + let rtr = rtr_listener( history.clone(), rtr_metrics.clone(), process.config(), - process.get_listen_fd()? + notify.clone(), process.get_listen_fd()? )?; let http = http_listener( - history.clone(), rtr_metrics, log.clone(), process.config() + history.clone(), rtr_metrics, log.clone(), process.config(), + notify.clone(), )?; process.drop_privileges()?; diff --git a/src/rtr.rs b/src/rtr.rs index 7e4d35b4..ab316842 100644 --- a/src/rtr.rs +++ b/src/rtr.rs @@ -31,10 +31,9 @@ pub fn rtr_listener( history: SharedHistory, metrics: SharedRtrServerMetrics, config: &Config, + sender: NotifySender, extra_listener: Option, -) -> Result<(NotifySender, impl Future), ExitError> { - let sender = NotifySender::new(); - +) -> Result, ExitError> { // Binding needs to have happened before dropping privileges // during detach. So we do this here synchronously. let mut listeners = Vec::new(); @@ -54,9 +53,9 @@ pub fn rtr_listener( )); } } - Ok((sender.clone(), _rtr_listener( + Ok(_rtr_listener( history, metrics, sender, listeners, config.rtr_tcp_keepalive, - ))) + )) } fn create_tls_config( From ab890e40dccd04548ab8842d7b802f560a2e6fe4 Mon Sep 17 00:00:00 2001 From: Martin Hoffmann Date: Fri, 19 May 2023 13:38:23 +0200 Subject: [PATCH 2/7] Add new endpoint to manual page. --- doc/manual/source/manual-page.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/manual/source/manual-page.rst b/doc/manual/source/manual-page.rst index ce28ac08..a709b8ed 100644 --- a/doc/manual/source/manual-page.rst +++ b/doc/manual/source/manual-page.rst @@ -1378,6 +1378,11 @@ The service only supports GET requests with the following paths: provided session and serial. If *reset* is *true*, the *withdrawn* member is not present. +/json-delta/notify + Waits with a response until a new update is available and then returns + a JSON object with two members *session* and *serial* which contain the + session ID and serial number of the updated data set. + In addition, the current set of VRPs is available for each output format at a path with the same name as the output format. E.g., the CSV output is available at ``/csv``. From a553d1d561fe3907db9c65142d9e2285246c928f Mon Sep 17 00:00:00 2001 From: Martin Hoffmann Date: Sun, 21 May 2023 17:16:31 +0200 Subject: [PATCH 3/7] Add session and serial query parameters to /json-delta/notify. --- doc/manual/source/manual-page.rst | 7 ++- src/http/delta.rs | 101 +++++++++++++++++++++++------- src/http/mod.rs | 3 +- src/http/notify.rs | 41 ------------ src/payload/history.rs | 5 ++ 5 files changed, 90 insertions(+), 67 deletions(-) delete mode 100644 src/http/notify.rs diff --git a/doc/manual/source/manual-page.rst b/doc/manual/source/manual-page.rst index a709b8ed..dc2ebe65 100644 --- a/doc/manual/source/manual-page.rst +++ b/doc/manual/source/manual-page.rst @@ -1378,11 +1378,16 @@ The service only supports GET requests with the following paths: provided session and serial. If *reset* is *true*, the *withdrawn* member is not present. -/json-delta/notify +/json-delta/notify, /json-delta/notify?session=session&serial=serial Waits with a response until a new update is available and then returns a JSON object with two members *session* and *serial* which contain the session ID and serial number of the updated data set. + If the *session* and *serial* query parameters are provided, the JSON + object is returned immediately if the session ID and serial number of + the current data set differ from the provided values and only waits + for an update if they are identical. + In addition, the current set of VRPs is available for each output format at a path with the same name as the output format. E.g., the CSV output is available at ``/csv``. diff --git a/src/http/delta.rs b/src/http/delta.rs index 91e459a2..328e8dd5 100644 --- a/src/http/delta.rs +++ b/src/http/delta.rs @@ -7,14 +7,15 @@ use futures::stream; use hyper::{Body, Method, Request}; use rpki::rtr::Serial; use rpki::rtr::payload::{Action, PayloadRef}; -use rpki::rtr::server::PayloadDiff; +use rpki::rtr::server::{NotifySender, PayloadDiff}; use crate::payload::{ DeltaArcIter, PayloadDelta, PayloadSnapshot, SharedHistory, SnapshotArcIter }; use crate::utils::fmt::WriteOrPanic; +use crate::utils::json::JsonBuilder; use super::response::{ContentType, Response, ResponseBuilder}; -//------------ handle_get ---------------------------------------------------- +//------------ handle_get_or_head -------------------------------------------- pub fn handle_get_or_head( req: &Request, @@ -57,6 +58,81 @@ pub fn handle_get_or_head( Some(handle_reset(history.session(), history.serial(), snapshot)) } +fn handle_delta( + session: u64, from_serial: Serial, to_serial: Serial, + delta: Arc +) -> Response { + ResponseBuilder::ok().content_type(ContentType::JSON) + .body(Body::wrap_stream(stream::iter( + DeltaStream::new(session, from_serial, to_serial, delta) + .map(Result::<_, Infallible>::Ok) + ))) +} + +fn handle_reset( + session: u64, to_serial: Serial, snapshot: Arc +) -> Response { + ResponseBuilder::ok().content_type(ContentType::JSON) + .body(Body::wrap_stream(stream::iter( + SnapshotStream::new(session, to_serial, snapshot) + .map(Result::<_, Infallible>::Ok) + ))) +} + + +//------------ handle_get_or_head -------------------------------------------- + +pub async fn handle_notify_get_or_head( + req: &Request, + history: &SharedHistory, + notify: &NotifySender, +) -> Option { + if req.uri().path() != "/json-delta/notify" { + return None + } + + let wait = match need_wait(req, history) { + Ok(wait) => wait, + Err(resp) => return Some(resp), + }; + + if wait { + notify.subscribe().recv().await; + } + + if *req.method() == Method::HEAD { + Some( + ResponseBuilder::ok().content_type(ContentType::JSON).empty() + ) + } + else { + let (session, serial) = history.read().session_and_serial(); + Some( + ResponseBuilder::ok().content_type(ContentType::JSON).body( + JsonBuilder::build(|json| { + json.member_raw("session", session); + json.member_raw("serial", serial); + }) + ) + ) + } +} + +fn need_wait( + req: &Request, + history: &SharedHistory, +) -> Result { + let version = match version_from_query(req.uri().query())? { + Some(version) => version, + None => return Ok(true), + }; + + Ok(history.read().session_and_serial() == version) +} + + +//------------ Helpers ------------------------------------------------------- + fn version_from_query( query: Option<&str> ) -> Result, Response> { @@ -95,27 +171,6 @@ fn version_from_query( } } -fn handle_delta( - session: u64, from_serial: Serial, to_serial: Serial, - delta: Arc -) -> Response { - ResponseBuilder::ok().content_type(ContentType::JSON) - .body(Body::wrap_stream(stream::iter( - DeltaStream::new(session, from_serial, to_serial, delta) - .map(Result::<_, Infallible>::Ok) - ))) -} - -fn handle_reset( - session: u64, to_serial: Serial, snapshot: Arc -) -> Response { - ResponseBuilder::ok().content_type(ContentType::JSON) - .body(Body::wrap_stream(stream::iter( - SnapshotStream::new(session, to_serial, snapshot) - .map(Result::<_, Infallible>::Ok) - ))) -} - //------------ DeltaStream --------------------------------------------------- diff --git a/src/http/mod.rs b/src/http/mod.rs index 2ea2e32d..421b7ef2 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -14,7 +14,6 @@ mod delta; mod listener; mod log; mod metrics; -mod notify; mod payload; mod response; mod status; @@ -48,7 +47,7 @@ async fn handle_request( if let Some(response) = payload::handle_get_or_head(&req, origins) { return response } - if let Some(response) = notify::handle_get_or_head( + if let Some(response) = delta::handle_notify_get_or_head( &req, origins, notify, ).await { return response diff --git a/src/http/notify.rs b/src/http/notify.rs deleted file mode 100644 index 1cd95771..00000000 --- a/src/http/notify.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Handles the notification websocket. - -use hyper::{Body, Method, Request}; -use rpki::rtr::server::{NotifySender, PayloadSource}; -use crate::payload::SharedHistory; -use crate::utils::json::JsonBuilder; -use super::response::{ContentType, Response, ResponseBuilder}; - - -//------------ handle_get_or_head -------------------------------------------- - -pub async fn handle_get_or_head( - req: &Request, - history: &SharedHistory, - notify: &NotifySender, -) -> Option { - if req.uri().path() != "/json-delta/notify" { - return None - } - - notify.subscribe().recv().await; - - let state = history.notify(); - - if *req.method() == Method::HEAD { - Some( - ResponseBuilder::ok().content_type(ContentType::JSON).empty() - ) - } - else { - Some( - ResponseBuilder::ok().content_type(ContentType::JSON).body( - JsonBuilder::build(|json| { - json.member_raw("session", state.session()); - json.member_raw("serial", state.serial()); - }) - ) - ) - } -} - diff --git a/src/payload/history.rs b/src/payload/history.rs index 450784ed..6680b7b1 100644 --- a/src/payload/history.rs +++ b/src/payload/history.rs @@ -383,6 +383,11 @@ impl PayloadHistory { self.session } + /// Returns the session and serial number of the current data set. + pub fn session_and_serial(&self) -> (u64, Serial) { + (self.session(), self.serial()) + } + /// Returns the RTR version of the session ID. /// /// This is the last 16 bits of the full session ID. From 484298d0d25132b3dbd83c1c5a61ad8b126bed9f Mon Sep 17 00:00:00 2001 From: Martin Hoffmann Date: Wed, 31 May 2023 09:53:32 +0200 Subject: [PATCH 4/7] Fixes from review. --- doc/manual/source/manual-page.rst | 2 +- src/http/delta.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual/source/manual-page.rst b/doc/manual/source/manual-page.rst index dc2ebe65..62e4d9a3 100644 --- a/doc/manual/source/manual-page.rst +++ b/doc/manual/source/manual-page.rst @@ -1384,7 +1384,7 @@ The service only supports GET requests with the following paths: session ID and serial number of the updated data set. If the *session* and *serial* query parameters are provided, the JSON - object is returned immediately if the session ID and serial number of + object is returned immediately if the session ID or serial number of the current data set differ from the provided values and only waits for an update if they are identical. diff --git a/src/http/delta.rs b/src/http/delta.rs index 328e8dd5..d504fc8e 100644 --- a/src/http/delta.rs +++ b/src/http/delta.rs @@ -80,7 +80,7 @@ fn handle_reset( } -//------------ handle_get_or_head -------------------------------------------- +//------------ handle_notify_get_or_head ------------------------------------- pub async fn handle_notify_get_or_head( req: &Request, From a4386a3aba6d888f0ceb31a60d100a1cf10ca8f5 Mon Sep 17 00:00:00 2001 From: Martin Hoffmann Date: Wed, 31 May 2023 10:29:24 +0200 Subject: [PATCH 5/7] Switch meaning of missing session/serial in HTTP notify. --- doc/manual/source/manual-page.rst | 16 ++++++++-------- src/http/delta.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/manual/source/manual-page.rst b/doc/manual/source/manual-page.rst index 62e4d9a3..10646753 100644 --- a/doc/manual/source/manual-page.rst +++ b/doc/manual/source/manual-page.rst @@ -1379,14 +1379,14 @@ The service only supports GET requests with the following paths: member is not present. /json-delta/notify, /json-delta/notify?session=session&serial=serial - Waits with a response until a new update is available and then returns - a JSON object with two members *session* and *serial* which contain the - session ID and serial number of the updated data set. - - If the *session* and *serial* query parameters are provided, the JSON - object is returned immediately if the session ID or serial number of - the current data set differ from the provided values and only waits - for an update if they are identical. + Returns a JSON object with two members *session* and *serial* which + contain the session ID and serial number of the current data set. + + If the *session* and *serial* query parameters are provided, and the + session ID and serial number of the current data set are identical + to the provided values, the request will not return until a new data + set is available. This can be used as a means to get notified when + the data set has been updated. In addition, the current set of VRPs is available for each output format at a path with the same name as the output format. E.g., the CSV output is diff --git a/src/http/delta.rs b/src/http/delta.rs index d504fc8e..4dc3e4a7 100644 --- a/src/http/delta.rs +++ b/src/http/delta.rs @@ -124,7 +124,7 @@ fn need_wait( ) -> Result { let version = match version_from_query(req.uri().query())? { Some(version) => version, - None => return Ok(true), + None => return Ok(false), }; Ok(history.read().session_and_serial() == version) From 37c17242b51dacb3bd3706e28f407f18df9d7bca Mon Sep 17 00:00:00 2001 From: Alex Band Date: Wed, 31 May 2023 10:35:36 +0200 Subject: [PATCH 6/7] Add the `/json-delta/notify` path to API docs --- doc/manual/source/api-endpoints.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/manual/source/api-endpoints.rst b/doc/manual/source/api-endpoints.rst index a503409e..d739e1cd 100644 --- a/doc/manual/source/api-endpoints.rst +++ b/doc/manual/source/api-endpoints.rst @@ -32,6 +32,16 @@ The HTTP service supports GET requests on the following paths: provided session and serial. If *reset* is *true*, the *withdrawn* member is not present. +``/json-delta/notify, /json-delta/notify?session=session&serial=serial`` + Waits with a response until a new update is available and then returns + a JSON object with two members *session* and *serial* which contain the + session ID and serial number of the updated data set. + + If the *session* and *serial* query parameters are provided, the JSON + object is returned immediately if the session ID or serial number of + the current data set differ from the provided values and only waits + for an update if they are identical. + In addition, the ``/log`` endpoint returns :doc:`logging` information and the ``/metrics``, ``/status`` and ``/version`` endpoints provide :doc:`monitoring` data. @@ -40,3 +50,5 @@ information and the ``/metrics``, ``/status`` and The ``/json-delta`` path .. versionchanged:: 0.9.0 The ``/api/v1/status`` path +.. versionadded:: 0.13.0 + The ``/json-delta/notify`` path From 1326fdeab17d3cf5dc5d24753bcd27255ddede13 Mon Sep 17 00:00:00 2001 From: Alex Band Date: Wed, 31 May 2023 10:39:10 +0200 Subject: [PATCH 7/7] Update `/json-delta/notify` description --- doc/manual/source/api-endpoints.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/manual/source/api-endpoints.rst b/doc/manual/source/api-endpoints.rst index d739e1cd..15526246 100644 --- a/doc/manual/source/api-endpoints.rst +++ b/doc/manual/source/api-endpoints.rst @@ -33,14 +33,14 @@ The HTTP service supports GET requests on the following paths: member is not present. ``/json-delta/notify, /json-delta/notify?session=session&serial=serial`` - Waits with a response until a new update is available and then returns - a JSON object with two members *session* and *serial* which contain the - session ID and serial number of the updated data set. - - If the *session* and *serial* query parameters are provided, the JSON - object is returned immediately if the session ID or serial number of - the current data set differ from the provided values and only waits - for an update if they are identical. + Returns a JSON object with two members *session* and *serial* which + contain the session ID and serial number of the current data set. + + If the *session* and *serial* query parameters are provided, and the + session ID and serial number of the current data set are identical to + the provided values, the request will not return until a new data set is + available. This can be used as a means to get notified when the data set + has been updated. In addition, the ``/log`` endpoint returns :doc:`logging` information and the ``/metrics``, ``/status`` and