1
0
mirror of https://github.com/NLnetLabs/routinator.git synced 2024-05-19 06:50:04 +00:00

Add a notification endpoint to the json-delta protocol. (#863)

The PR adds a new endpoint /json-delta/notify that waits with responding
until new data is available and then returns a JSON object with the session
ID and serial number.

---------

Co-authored-by: Alex Band <alex@nlnetlabs.nl>
This commit is contained in:
Martin Hoffmann
2023-05-31 14:45:21 +02:00
committed by GitHub
parent c7beccd485
commit 4e86a95702
10 changed files with 270 additions and 234 deletions

333
Cargo.lock generated
View File

@ -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",
@ -111,9 +111,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"
@ -152,9 +152,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",
@ -163,9 +163,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",
@ -185,7 +185,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.15",
"syn 2.0.16",
]
[[package]]
@ -194,16 +194,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"
@ -254,50 +244,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"
@ -397,9 +343,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",
@ -491,7 +437,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.15",
"syn 2.0.16",
]
[[package]]
@ -537,9 +483,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",
@ -652,15 +598,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]]
@ -692,12 +638,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]]
@ -766,9 +711,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",
]
@ -781,24 +726,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"
@ -849,9 +785,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",
]
@ -946,9 +882,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",
@ -967,7 +903,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.15",
"syn 2.0.16",
]
[[package]]
@ -978,9 +914,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",
@ -1008,9 +944,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"
@ -1020,9 +956,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",
]
@ -1038,9 +974,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",
]
@ -1106,9 +1042,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",
@ -1129,14 +1065,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",
@ -1206,7 +1142,7 @@ dependencies = [
"syslog",
"tempfile",
"tokio",
"tokio-rustls",
"tokio-rustls 0.23.4",
"tokio-stream",
"toml",
"uuid",
@ -1225,9 +1161,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",
@ -1249,9 +1184,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",
@ -1273,6 +1208,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"
@ -1282,6 +1229,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"
@ -1297,12 +1254,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"
@ -1315,9 +1266,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",
@ -1328,9 +1279,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",
@ -1338,22 +1289,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]]
@ -1438,9 +1389,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",
@ -1449,15 +1400,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]]
@ -1484,15 +1435,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"
@ -1520,7 +1462,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.15",
"syn 2.0.16",
]
[[package]]
@ -1536,9 +1478,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",
@ -1550,15 +1492,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",
]
@ -1580,9 +1522,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",
@ -1593,18 +1535,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]]
@ -1623,11 +1565,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"
@ -1642,9 +1594,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",
@ -1653,9 +1605,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",
@ -1693,9 +1645,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",
]
@ -1727,12 +1679,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"
@ -1758,9 +1704,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"
@ -1798,9 +1744,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",
@ -1808,24 +1754,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",
@ -1835,9 +1781,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",
@ -1845,28 +1791,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",
@ -1907,15 +1853,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"

View File

@ -34,7 +34,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"
@ -54,9 +54,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" ]

View File

@ -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``
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<logging>`
information and the ``/metrics``, ``/status`` and
``/version`` endpoints provide :doc:`monitoring<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

View File

@ -1378,6 +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?session=session&serial=serial
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
available at ``/csv``.

View File

@ -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<Body>,
@ -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<PayloadDelta>
) -> 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<PayloadSnapshot>
) -> Response {
ResponseBuilder::ok().content_type(ContentType::JSON)
.body(Body::wrap_stream(stream::iter(
SnapshotStream::new(session, to_serial, snapshot)
.map(Result::<_, Infallible>::Ok)
)))
}
//------------ handle_notify_get_or_head -------------------------------------
pub async fn handle_notify_get_or_head(
req: &Request<Body>,
history: &SharedHistory,
notify: &NotifySender,
) -> Option<Response> {
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<Body>,
history: &SharedHistory,
) -> Result<bool, Response> {
let version = match version_from_query(req.uri().query())? {
Some(version) => version,
None => return Ok(false),
};
Ok(history.read().session_and_serial() == version)
}
//------------ Helpers -------------------------------------------------------
fn version_from_query(
query: Option<&str>
) -> Result<Option<(u64, Serial)>, Response> {
@ -95,27 +171,6 @@ fn version_from_query(
}
}
fn handle_delta(
session: u64, from_serial: Serial, to_serial: Serial,
delta: Arc<PayloadDelta>
) -> 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<PayloadSnapshot>
) -> Response {
ResponseBuilder::ok().content_type(ContentType::JSON)
.body(Body::wrap_stream(stream::iter(
SnapshotStream::new(session, to_serial, snapshot)
.map(Result::<_, Infallible>::Ok)
)))
}
//------------ DeltaStream ---------------------------------------------------

View File

@ -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<Arc<LogOutput>>,
config: &Config,
notify: NotifySender,
) -> Result<impl Future<Output = ()>, 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<HttpServerMetrics>,
rtr_metrics: SharedRtrServerMetrics,
log: Option<Arc<LogOutput>>,
notify: NotifySender,
listeners: Vec<(SocketAddr, Option<Arc<tls::ServerConfig>>, 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<Arc<tls::ServerConfig>>,
@ -112,22 +117,26 @@ async fn single_http_listener(
metrics: Arc<HttpServerMetrics>,
rtr_metrics: SharedRtrServerMetrics,
log: Option<Arc<LogOutput>>,
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()),
&notify,
).await.into_hyper())
}
}))

View File

@ -24,6 +24,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 +37,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 +47,11 @@ async fn handle_request(
if let Some(response) = payload::handle_get_or_head(&req, origins) {
return response
}
if let Some(response) = delta::handle_notify_get_or_head(
&req, origins, notify,
).await {
return response
}
if let Some(response) = delta::handle_get_or_head(&req, origins) {
return response
}

View File

@ -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()?;

View File

@ -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.

View File

@ -31,10 +31,9 @@ pub fn rtr_listener(
history: SharedHistory,
metrics: SharedRtrServerMetrics,
config: &Config,
sender: NotifySender,
extra_listener: Option<StdListener>,
) -> Result<(NotifySender, impl Future<Output = ()>), ExitError> {
let sender = NotifySender::new();
) -> Result<impl Future<Output = ()>, 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(