From b4897b7c1cbe5b448b6bb55f7b27fce1824bf0e0 Mon Sep 17 00:00:00 2001 From: Martin Hoffmann Date: Tue, 11 Jul 2023 10:28:07 +0200 Subject: [PATCH] Update dependencies. (#879) This PR updates the dependencies: o since toml has changed too much, switches to toml_edit, o with scoped threads and once writable cells now available in std, it also drops the crossbeam-utils and once_cell crates. The PR also increases the minimum supported Rust version to 1.70. This makes it a breaking change. --- .github/workflows/ci.yml | 2 +- Cargo.lock | 437 +++++++++++++++++--------------- Cargo.toml | 12 +- src/config.rs | 528 ++++++++++++++++++--------------------- src/engine.rs | 16 +- src/process.rs | 7 +- 6 files changed, 491 insertions(+), 511 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5479fb..0a2b51d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - rust: [1.65.0, stable, beta] + rust: [1.70.0, stable, beta] steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/Cargo.lock b/Cargo.lock index 4079b60..acfa5f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -59,7 +68,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -69,7 +78,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -87,6 +96,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.21.2" @@ -109,6 +133,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "bumpalo" version = "3.13.0" @@ -152,9 +182,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.8" +version = "4.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9394150f5b4273a1763355bd1c2ec54cc5a2593f790587bcd6b2c947cfa9211" +checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" dependencies = [ "clap_builder", "clap_derive", @@ -163,13 +193,12 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.8" +version = "4.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a78fbdd3cc2914ddf37ba444114bc7765bbdcb55ec9cbe6fa054f0137400717" +checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" dependencies = [ "anstream", "anstyle", - "bitflags", "clap_lex", "once_cell", "strsim", @@ -257,22 +286,23 @@ dependencies = [ [[package]] name = "dirs" -version = "4.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "winapi", + "windows-sys", ] [[package]] @@ -290,6 +320,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "equivalent" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" + [[package]] name = "errno" version = "0.3.1" @@ -298,7 +334,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -338,7 +374,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall 0.2.16", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -482,10 +518,16 @@ dependencies = [ ] [[package]] -name = "h2" -version = "0.3.19" +name = "gimli" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + +[[package]] +name = "h2" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" dependencies = [ "bytes", "fnv", @@ -493,7 +535,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -506,6 +548,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heck" version = "0.4.1" @@ -514,18 +562,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.2.6" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hostname" @@ -574,9 +613,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.26" +version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ "bytes", "futures-channel", @@ -598,15 +637,16 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ + "futures-util", "http", "hyper", - "rustls 0.21.2", + "rustls", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", ] [[package]] @@ -662,7 +702,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", ] [[package]] @@ -680,34 +730,33 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "ipnet" -version = "2.7.2" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix", - "windows-sys 0.48.0", + "hermit-abi", + "rustix 0.38.3", + "windows-sys", ] [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" [[package]] name = "js-sys" @@ -736,6 +785,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" + [[package]] name = "listenfd" version = "1.0.1" @@ -767,9 +822,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" -version = "0.6.5" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ "autocfg", ] @@ -797,7 +852,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -820,16 +875,16 @@ dependencies = [ [[package]] name = "nix" -version = "0.25.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset", "pin-utils", + "static_assertions", ] [[package]] @@ -843,11 +898,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi", "libc", ] @@ -860,6 +915,15 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.18.0" @@ -872,7 +936,7 @@ version = "0.10.55" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -910,6 +974,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "percent-encoding" version = "2.3.0" @@ -918,9 +988,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -960,9 +1030,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -1003,7 +1073,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1012,7 +1082,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1051,14 +1121,14 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.2", + "rustls", "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio", "tokio-native-tls", - "tokio-rustls 0.24.1", + "tokio-rustls", "tokio-socks", "tower-service", "url", @@ -1093,7 +1163,6 @@ dependencies = [ "chrono", "clap", "crossbeam-queue", - "crossbeam-utils", "dirs", "form_urlencoded", "futures", @@ -1102,7 +1171,6 @@ dependencies = [ "log", "nix", "num_cpus", - "once_cell", "pin-project-lite", "rand", "reqwest", @@ -1115,9 +1183,9 @@ dependencies = [ "syslog", "tempfile", "tokio", - "tokio-rustls 0.23.4", + "tokio-rustls", "tokio-stream", - "toml", + "toml_edit", "uuid", ] @@ -1156,36 +1224,43 @@ dependencies = [ ] [[package]] -name = "rustix" -version = "0.37.20" +name = "rustc-demangle" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.37.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", - "linux-raw-sys", - "windows-sys 0.48.0", + "linux-raw-sys 0.3.8", + "windows-sys", ] [[package]] -name = "rustls" -version = "0.20.8" +name = "rustix" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4" dependencies = [ - "log", - "ring", - "sct", - "webpki", + "bitflags 2.3.3", + "errno", + "libc", + "linux-raw-sys 0.4.3", + "windows-sys", ] [[package]] name = "rustls" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e32ca28af694bc1bbf399c33a516dbdf1c90090b8ab23c2bc24f834aa2247f5f" +checksum = "b19faa85ecb5197342b54f987b142fb3e30d0c90da40f80ef4fa9a726e6676ed" dependencies = [ "log", "ring", @@ -1195,18 +1270,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ "base64", ] [[package]] name = "rustls-webpki" -version = "0.100.1" +version = "0.101.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +checksum = "15f36a6828982f422756984e47912a7a51dcbc2a197aa791158f8ca61cd8204e" dependencies = [ "ring", "untrusted", @@ -1214,17 +1289,17 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" [[package]] name = "schannel" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -1243,7 +1318,7 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -1262,18 +1337,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.164" +version = "1.0.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "7daf513456463b42aa1d94cff7e0c24d682b429f020b9afa4f5ba5c40a22b237" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "b69b106b68bc8054f0e974e70d19984040f8a5cf9215ca82626ea4853f82c4b9" dependencies = [ "proc-macro2", "quote", @@ -1282,9 +1357,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" +checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" dependencies = [ "itoa", "ryu", @@ -1323,9 +1398,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "socket2" @@ -1343,6 +1418,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.10.0" @@ -1351,9 +1432,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.22" +version = "2.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" +checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" dependencies = [ "proc-macro2", "quote", @@ -1394,8 +1475,8 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix", - "windows-sys 0.48.0", + "rustix 0.37.23", + "windows-sys", ] [[package]] @@ -1404,24 +1485,24 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" dependencies = [ - "rustix", - "windows-sys 0.48.0", + "rustix 0.37.23", + "windows-sys", ] [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", @@ -1485,11 +1566,12 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.2" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" dependencies = [ "autocfg", + "backtrace", "bytes", "libc", "mio", @@ -1498,7 +1580,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1522,24 +1604,13 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" -dependencies = [ - "rustls 0.20.8", - "tokio", - "webpki", -] - [[package]] name = "tokio-rustls" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.2", + "rustls", "tokio", ] @@ -1581,12 +1652,20 @@ dependencies = [ ] [[package]] -name = "toml" -version = "0.5.11" +name = "toml_datetime" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" dependencies = [ - "serde", + "indexmap 2.0.0", + "toml_datetime", + "winnow", ] [[package]] @@ -1629,9 +1708,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "unicode-normalization" @@ -1667,9 +1746,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.4" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa2982af2eec27de306107c027578ff7f423d65f7250e40ce0fea8f45248b81" +checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" [[package]] name = "vcpkg" @@ -1830,21 +1909,6 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -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-sys" version = "0.48.0" @@ -1856,103 +1920,70 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[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.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[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.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[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.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[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.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[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.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[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.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[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.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "winnow" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.10.1" diff --git a/Cargo.toml b/Cargo.toml index 6149915..0d42f8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "routinator" version = "0.13.0-dev" edition = "2021" -rust-version = "1.65" +rust-version = "1.70" authors = ["The NLnet Labs RPKI Team "] description = "An RPKI relying party software." repository = "https://github.com/NLnetLabs/routinator" @@ -19,15 +19,13 @@ bytes = "1.0.0" chrono = "0.4.23" clap = { version = "4", features = [ "wrap_help", "cargo", "derive" ] } crossbeam-queue = "0.3.1" -crossbeam-utils = "0.8.1" -dirs = "4.0.0" +dirs = "5" form_urlencoded = "1.0" futures = "0.3.4" hyper = { version = "0.14", features = [ "server", "stream" ] } listenfd = "1" log = "0.4.8" num_cpus = "1.12.0" -once_cell = "1" pin-project-lite = "0.2.4" rand = "0.8.1" reqwest = { version = "0.11.0", default-features = false, features = ["blocking", "rustls-tls" ] } @@ -38,15 +36,15 @@ serde = { version = "1.0.95", features = [ "derive" ] } serde_json = "1.0.57" tempfile = "3.1.0" tokio = { version = "1.24", features = [ "io-util", "macros", "process", "rt", "rt-multi-thread", "signal", "sync" ] } -tokio-rustls = "0.23.2" +tokio-rustls = "0.24.1" tokio-stream = { version = "0.1", features = ["net"] } -toml = "0.5.6" +toml_edit = "0.19.12" uuid = "1.1" routinator-ui = { version = "0.3.4", optional = true } [target.'cfg(unix)'.dependencies] -nix = "0.25" +nix = "0.26.2" syslog = "6" [features] diff --git a/src/config.rs b/src/config.rs index c6e29a7..3850e63 100644 --- a/src/config.rs +++ b/src/config.rs @@ -21,6 +21,7 @@ use clap::{ use dirs::home_dir; use log::{LevelFilter, error, warn}; #[cfg(unix)] use syslog::Facility; +use toml_edit as toml; use crate::tals; use crate::error::Failed; @@ -1250,264 +1251,240 @@ impl Config { } /// Returns a TOML representation of the config. - pub fn to_toml(&self) -> toml::Value { - let mut res = toml::value::Table::new(); - res.insert( - "repository-dir".into(), - self.cache_dir.display().to_string().into() + pub fn to_toml(&self) -> toml::Table { + fn insert( + table: &mut toml::Table, + key: &str, + value: impl Into, + ) { + table.insert(key, toml::Item::Value(value.into())); + } + + fn insert_int( + table: &mut toml::Table, + key: &str, + value: impl TryInto, + ) { + insert(table, key, value.try_into().unwrap_or(i64::MAX)) + } + + let mut res = toml::Table::new(); + insert( + &mut res, "repository-dir", self.cache_dir.display().to_string() ); if let Some(extra_tals_dir) = self.extra_tals_dir.as_ref() { - res.insert( - "extra-tals-dir".into(), - extra_tals_dir.display().to_string().into() + insert( + &mut res, "extra-tals-dir", + extra_tals_dir.display().to_string(), ); } - res.insert( - "exceptions".into(), + insert( + &mut res, "exceptions", toml::Value::Array( self.exceptions.iter() - .map(|p| p.display().to_string().into()) + .map(|p| toml::Value::from(p.display().to_string())) .collect() ) ); - res.insert("strict".into(), self.strict.into()); - res.insert("stale".into(), format!("{}", self.stale).into()); - res.insert( - "unsafe-vrps".into(), format!("{}", self.unsafe_vrps).into() - ); - res.insert( - "unknown-objects".into(), - format!("{}", self.unknown_objects).into(), + insert(&mut res, "strict", self.strict); + insert(&mut res, "stale", format!("{}", self.stale)); + insert(&mut res, "unsafe-vrps", format!("{}", self.unsafe_vrps)); + insert( + &mut res, "unknown-objects", format!("{}", self.unknown_objects) ); if let Some(value) = self.limit_v4_len { - res.insert("limit-v4-len".into(), value.into()); + insert(&mut res, "limit-v4-len", i64::from(value)); } if let Some(value) = self.limit_v6_len { - res.insert("limit-v6-len".into(), value.into()); + insert(&mut res, "limit-v6-len", i64::from(value)); } - res.insert( - "allow-dubious-hosts".into(), self.allow_dubious_hosts.into() - ); - res.insert("disable-rsync".into(), self.disable_rsync.into()); - res.insert("rsync-command".into(), self.rsync_command.clone().into()); + insert(&mut res, "allow-dubious-hosts", self.allow_dubious_hosts); + insert(&mut res, "disable-rsync", self.disable_rsync); + insert(&mut res, "rsync-command", self.rsync_command.clone()); if let Some(ref args) = self.rsync_args { - res.insert( - "rsync-args".into(), + insert( + &mut res, "rsync-args", toml::Value::Array( - args.iter().map(|a| a.clone().into()).collect() + args.iter().map(|a| toml::Value::from(a.clone())).collect() ) ); } - res.insert( - "rsync-timeout".into(), + insert_int( + &mut res, "rsync-timeout", match self.rsync_timeout { - None => 0.into(), - Some(value) => { - value.as_secs().try_into().unwrap_or(i64::MAX).into() - } + None => 0, + Some(value) => value.as_secs(), } ); - res.insert("disable-rrdp".into(), self.disable_rrdp.into()); - res.insert( - "rrdp-fallback".into(), - self.rrdp_fallback.to_string().into(), + insert(&mut res, "disable-rrdp", self.disable_rrdp); + insert(&mut res, "rrdp-fallback", self.rrdp_fallback.to_string()); + insert_int( + &mut res, "rrdp-fallback-time", self.rrdp_fallback_time.as_secs(), ); - res.insert( - "rrdp-fallback-time".into(), - (self.rrdp_fallback_time.as_secs() as i64).into() + insert_int( + &mut res, "rrdp-max-delta-count", self.rrdp_max_delta_count ); - res.insert( - "rrdp-max-delta-count".into(), - i64::try_from(self.rrdp_max_delta_count).unwrap_or(i64::MAX).into() - ); - res.insert( - "rrdp-timeout".into(), + insert_int( + &mut res, "rrdp-timeout", match self.rrdp_timeout { - None => 0.into(), - Some(value) => { - value.as_secs().try_into().unwrap_or(i64::MAX).into() - } + None => 0, + Some(value) => value.as_secs(), } ); if let Some(timeout) = self.rrdp_connect_timeout { - res.insert( - "rrdp-connect-timeout".into(), - (timeout.as_secs() as i64).into() - ); + insert_int(&mut res, "rrdp-connect-timeout", timeout.as_secs()); } - res.insert( - "rrdp-tcp-keepalive".into(), + insert_int( + &mut res, "rrdp-tcp-keepalive", match self.rrdp_tcp_keepalive { - None => 0.into(), - Some(value) => { - value.as_secs().try_into().unwrap_or(i64::MAX).into() - } + None => 0, + Some(value) => value.as_secs(), } ); if let Some(addr) = self.rrdp_local_addr { - res.insert("rrdp-local-addr".into(), addr.to_string().into()); + insert(&mut res, "rrdp-local-addr", addr.to_string()); } - res.insert( - "rrdp-root-certs".into(), + insert( + &mut res, "rrdp-root-certs", toml::Value::Array( self.rrdp_root_certs.iter() - .map(|p| p.display().to_string().into()) + .map(|p| toml::Value::from(p.display().to_string())) .collect() ) ); - res.insert( - "rrdp-proxies".into(), + insert( + &mut res, "rrdp-proxies", toml::Value::Array( - self.rrdp_proxies.iter().map(|s| s.clone().into()).collect() + self.rrdp_proxies.iter().map(|s| { + toml::Value::from(s.clone()) + }).collect() ) ); if let Some(path) = self.rrdp_keep_responses.as_ref() { - res.insert( - "rrdp-keep-responses".into(), - format!("{}", path.display()).into() + insert( + &mut res,"rrdp-keep-responses", format!("{}", path.display()) ); } - res.insert("max-object-size".into(), - match self.max_object_size { - Some(value) => value as i64, - None => 0, - }.into() + insert_int( + &mut res, "max-object-size", + self.max_object_size.unwrap_or(0), ); - res.insert("max-ca-depth".into(), - (self.max_ca_depth as i64).into() - ); - res.insert("enable-bgpsec".into(), self.enable_bgpsec.into()); + insert_int(&mut res, "max-ca-depth", self.max_ca_depth); + insert(&mut res, "enable-bgpsec", self.enable_bgpsec); #[cfg(feature = "aspa")] - res.insert("enable-aspa".into(), self.enable_aspa.into()); - res.insert("dirty".into(), self.dirty_repository.into()); - res.insert( - "validation-threads".into(), - (self.validation_threads as i64).into() - ); - res.insert("refresh".into(), (self.refresh.as_secs() as i64).into()); - res.insert("retry".into(), (self.retry.as_secs() as i64).into()); - res.insert("expire".into(), (self.expire.as_secs() as i64).into()); - res.insert("history-size".into(), (self.history_size as i64).into()); - res.insert( - "rtr-listen".into(), + insert(&mut res, "enable-aspa", self.enable_aspa); + insert(&mut res, "dirty", self.dirty_repository); + insert_int(&mut res, "validation-threads", self.validation_threads); + insert_int(&mut res, "refresh", self.refresh.as_secs()); + insert_int(&mut res, "retry", self.retry.as_secs()); + insert_int(&mut res, "expire", self.expire.as_secs()); + insert_int(&mut res, "history-size", self.history_size); + insert( + &mut res, "rtr-listen", toml::Value::Array( - self.rtr_listen.iter().map(|a| a.to_string().into()).collect() + self.rtr_listen.iter().map(|a| { + toml::Value::from(a.to_string()) + }).collect() ) ); - res.insert( - "rtr-tls-listen".into(), + insert( + &mut res, "rtr-tls-listen", toml::Value::Array( self.rtr_tls_listen.iter().map(|a| { - a.to_string().into() + toml::Value::from(a.to_string()) }).collect() ) ); - res.insert( - "http-listen".into(), + insert( + &mut res, "http-listen", toml::Value::Array( - self.http_listen.iter().map(|a| a.to_string().into()).collect() + self.http_listen.iter().map(|a| { + toml::Value::from(a.to_string()) + }).collect() ) ); - res.insert( - "http-tls-listen".into(), + insert( + &mut res, "http-tls-listen", toml::Value::Array( self.http_tls_listen.iter().map(|a| { - a.to_string().into() + toml::Value::from(a.to_string()) }).collect() ) ); - res.insert("systemd-listen".into(), self.systemd_listen.into()); - res.insert("rtr-tcp-keepalive".into(), + insert(&mut res, "systemd-listen", self.systemd_listen); + insert_int( + &mut res, "rtr-tcp-keepalive", match self.rtr_tcp_keepalive { - Some(keep) => (keep.as_secs() as i64).into(), - None => 0.into(), + Some(value) => value.as_secs(), + None => 0, } ); - res.insert( - "rtr-client-metrics".into(), - self.rtr_client_metrics.into() - ); + insert( &mut res, "rtr-client-metrics", self.rtr_client_metrics); if let Some(ref path) = self.rtr_tls_key { - res.insert( - "rtr-tls-key".into(), - path.display().to_string().into() - ); + insert(&mut res, "rtr-tls-key", path.display().to_string()); } if let Some(ref path) = self.rtr_tls_cert { - res.insert( - "rtr-tls-cert".into(), - path.display().to_string().into() - ); + insert(&mut res, "rtr-tls-cert", path.display().to_string()); } if let Some(ref path) = self.http_tls_key { - res.insert( - "http-tls-key".into(), - path.display().to_string().into() - ); + insert(&mut res, "http-tls-key", path.display().to_string()); } if let Some(ref path) = self.http_tls_cert { - res.insert( - "http-tls-cert".into(), - path.display().to_string().into() - ); + insert(&mut res, "http-tls-cert", path.display().to_string()); } - res.insert("log-level".into(), self.log_level.to_string().into()); + insert(&mut res, "log-level", self.log_level.to_string()); match self.log_target { #[cfg(unix)] LogTarget::Default(facility) => { - res.insert("log".into(), "default".into()); - res.insert( - "syslog-facility".into(), - facility_to_string(facility).into() + insert(&mut res, "log", "default"); + insert( + &mut res, "syslog-facility", facility_to_string(facility) ); } #[cfg(unix)] LogTarget::Syslog(facility) => { - res.insert("log".into(), "syslog".into()); - res.insert( - "syslog-facility".into(), - facility_to_string(facility).into() + insert(&mut res, "log", "syslog"); + insert( + &mut res, "syslog-facility", facility_to_string(facility) ); } LogTarget::Stderr => { - res.insert("log".into(), "stderr".into()); + insert(&mut res, "log", "stderr"); } LogTarget::File(ref file) => { - res.insert("log".into(), "file".into()); - res.insert( - "log-file".into(), - file.display().to_string().into() - ); + insert(&mut res, "log", "file"); + insert(&mut res, "log-file", file.display().to_string()); } } if let Some(ref file) = self.pid_file { - res.insert("pid-file".into(), file.display().to_string().into()); + insert(&mut res, "pid-file", file.display().to_string()); } if let Some(ref dir) = self.working_dir { - res.insert("working-dir".into(), dir.display().to_string().into()); + insert(&mut res, "working-dir", dir.display().to_string()); } if let Some(ref dir) = self.chroot { - res.insert("chroot".into(), dir.display().to_string().into()); + insert(&mut res, "chroot", dir.display().to_string()); } if let Some(ref user) = self.user { - res.insert("user".into(), user.clone().into()); + insert(&mut res, "user", user.clone()); } if let Some(ref group) = self.group { - res.insert("group".into(), group.clone().into()); + insert(&mut res, "group", group.clone()); } if !self.tal_labels.is_empty() { - res.insert( - "tal-labels".into(), + insert( + &mut res, "tal-labels", toml::Value::Array( self.tal_labels.iter().map(|(left, right)| { - toml::Value::Array(vec![ - left.clone().into(), right.clone().into() - ]) + toml::Value::Array([ + toml::Value::from(left.clone()), + toml::Value::from(right.clone()), + ].into_iter().collect()) }).collect() ) ); } - res.into() + res } } @@ -1978,7 +1955,7 @@ struct ServerArgs { #[derive(Clone, Debug)] struct ConfigFile { /// The content of the file. - content: toml::value::Table, + content: toml::Document, /// The path to the config file. path: PathBuf, @@ -2013,17 +1990,10 @@ impl ConfigFile { /// Parses the content of the file from a string. fn parse(content: &str, path: &Path) -> Result { - let content = match toml::from_str(content) { - Ok(toml::Value::Table(content)) => content, - Ok(_) => { - error!( - "Failed to parse config file {}: Not a mapping.", - path.display() - ); - return Err(Failed); - } + let content = match toml::Document::from_str(content) { + Ok(content) => content, Err(err) => { - error!( + eprintln!( "Failed to parse config file {}: {}", path.display(), err ); @@ -2052,26 +2022,73 @@ impl ConfigFile { }) } + /// Takes a value from the from the config file if present. + fn take_value( + &mut self, key: &str + ) -> Result, Failed> { + match self.content.remove(key) { + Some(toml::Item::Value(value)) => Ok(Some(value)), + Some(_) => { + error!( + "Failed in config file {}: \ + '{}' expected to be a value.", + self.path.display(), key + ); + Err(Failed) + } + None => Ok(None) + } + } + + /// Takes a boolean value from the config file. /// /// The value is taken from the given `key`. Returns `Ok(None)` if there /// is no such key. Returns an error if the key exists but the value /// isn’t a booelan. fn take_bool(&mut self, key: &str) -> Result, Failed> { - match self.content.remove(key) { - Some(value) => { - if let toml::Value::Boolean(res) = value { - Ok(Some(res)) - } - else { - error!( - "Failed in config file {}: \ - '{}' expected to be a boolean.", - self.path.display(), key - ); - Err(Failed) + match self.take_value(key)? { + Some(toml::Value::Boolean(res)) => Ok(Some(res.into_value())), + Some(_) => { + error!( + "Failed in config file {}: \ + '{}' expected to be a boolean.", + self.path.display(), key + ); + Err(Failed) + } + None => Ok(None) + } + } + + /// Takes an unsigned integer value from the config file. + /// + /// The value is taken from the given `key`. Returns `Ok(None)` if there + /// is no such key. Returns an error if the key exists but the value + /// isn’t an integer or if it is negative. + fn take_u64(&mut self, key: &str) -> Result, Failed> { + match self.take_value(key)? { + Some(toml::Value::Integer(value)) => { + match u64::try_from(value.into_value()) { + Ok(value) => Ok(Some(value)), + Err(_) => { + error!( + "Failed in config file {}: \ + '{}' expected to be a positive integer.", + self.path.display(), key + ); + Err(Failed) + } } } + Some(_) => { + error!( + "Failed in config file {}: \ + '{}' expected to be an integer.", + self.path.display(), key + ); + Err(Failed) + } None => Ok(None) } } @@ -2084,60 +2101,30 @@ impl ConfigFile { fn take_limited_u8( &mut self, key: &str, limit: u8, ) -> Result, Failed> { - match self.content.remove(key) { + match self.take_u64(key)? { Some(value) => { - if let toml::Value::Integer(res) = value { - if res < 0 || res > limit as i64 { + match u8::try_from(value) { + Ok(value) => { + if value > limit { + error!( + "Failed in config file {}: \ + '{}' expected integer between 0 and {}.", + self.path.display(), key, limit, + ); + Err(Failed) + } + else { + Ok(Some(value)) + } + } + Err(_) => { error!( "Failed in config file {}: \ '{}' expected integer between 0 and {}.", self.path.display(), key, limit, ); - return Err(Failed) - } - Ok(Some(res as u8)) - } - else { - error!( - "Failed in config file {}: \ - '{}' expected to be an integer.", - self.path.display(), key - ); - Err(Failed) - } - } - None => Ok(None) - } - } - - /// Takes an unsigned integer value from the config file. - /// - /// The value is taken from the given `key`. Returns `Ok(None)` if there - /// is no such key. Returns an error if the key exists but the value - /// isn’t an integer or if it is negative. - fn take_u64(&mut self, key: &str) -> Result, Failed> { - match self.content.remove(key) { - Some(value) => { - if let toml::Value::Integer(res) = value { - if res < 0 { - error!( - "Failed in config file {}: \ - '{}' expected to be a positive integer.", - self.path.display(), key - ); Err(Failed) } - else { - Ok(Some(res as u64)) - } - } - else { - error!( - "Failed in config file {}: \ - '{}' expected to be an integer.", - self.path.display(), key - ); - Err(Failed) } } None => Ok(None) @@ -2150,25 +2137,18 @@ impl ConfigFile { /// is no such key. Returns an error if the key exists but the value /// isn’t an integer or if it is negative. fn take_usize(&mut self, key: &str) -> Result, Failed> { - match self.content.remove(key) { + match self.take_u64(key)? { Some(value) => { - if let toml::Value::Integer(res) = value { - usize::try_from(res).map(Some).map_err(|_| { + match usize::try_from(value) { + Ok(value) => Ok(Some(value)), + Err(_) => { error!( "Failed in config file {}: \ '{}' expected to be a positive integer.", self.path.display(), key ); - Failed - }) - } - else { - error!( - "Failed in config file {}: \ - '{}' expected to be an integer.", - self.path.display(), key - ); - Err(Failed) + Err(Failed) + } } } None => Ok(None) @@ -2184,37 +2164,19 @@ impl ConfigFile { /// is no such key. Returns an error if the key exists but the value /// isn’t an integer or if it is out of bounds. fn take_small_usize(&mut self, key: &str) -> Result, Failed> { - match self.content.remove(key) { + match self.take_usize(key)? { Some(value) => { - if let toml::Value::Integer(res) = value { - if res < 0 { - error!( - "Failed in config file {}: \ - '{}' expected to be a positive integer.", - self.path.display(), key - ); - Err(Failed) - } - else if res > ::std::u16::MAX.into() { - error!( - "Failed in config file {}: \ - value for '{}' is too large.", - self.path.display(), key - ); - Err(Failed) - } - else { - Ok(Some(res as usize)) - } - } - else { + if value > u16::MAX.into() { error!( "Failed in config file {}: \ - '{}' expected to be a integer.", + value for '{}' is too large.", self.path.display(), key ); Err(Failed) } + else { + Ok(Some(value)) + } } None => Ok(None) } @@ -2226,19 +2188,17 @@ impl ConfigFile { /// is no such key. Returns an error if the key exists but the value /// isn’t a string. fn take_string(&mut self, key: &str) -> Result, Failed> { - match self.content.remove(key) { - Some(value) => { - if let toml::Value::String(res) = value { - Ok(Some(res)) - } - else { - error!( - "Failed in config file {}: \ - '{}' expected to be a string.", - self.path.display(), key - ); - Err(Failed) - } + match self.take_value(key)? { + Some(toml::Value::String(value)) => { + Ok(Some(value.into_value())) + } + Some(_) => { + error!( + "Failed in config file {}: \ + '{}' expected to be a string.", + self.path.display(), key + ); + Err(Failed) } None => Ok(None) } @@ -2313,12 +2273,12 @@ impl ConfigFile { &mut self, key: &str ) -> Result>, Failed> { - match self.content.remove(key) { + match self.take_value(key)? { Some(toml::Value::Array(vec)) => { let mut res = Vec::new(); for value in vec.into_iter() { if let toml::Value::String(value) = value { - res.push(value) + res.push(value.into_value()) } else { error!( @@ -2358,12 +2318,12 @@ impl ConfigFile { key: &str ) -> Result>, Failed> where T: FromStr, T::Err: fmt::Display { - match self.content.remove(key) { + match self.take_value(key)? { Some(toml::Value::Array(vec)) => { let mut res = Vec::new(); for value in vec.into_iter() { if let toml::Value::String(value) = value { - match T::from_str(&value) { + match T::from_str(value.value()) { Ok(value) => res.push(value), Err(err) => { error!( @@ -2412,15 +2372,15 @@ impl ConfigFile { &mut self, key: &str ) -> Result>, Failed> { - match self.content.remove(key) { + match self.take_value(key)? { Some(toml::Value::String(value)) => { - Ok(Some(vec![self.dir.join(value)])) + Ok(Some(vec![self.dir.join(value.into_value())])) } Some(toml::Value::Array(vec)) => { let mut res = Vec::new(); for value in vec.into_iter() { if let toml::Value::String(value) = value { - res.push(self.dir.join(value)) + res.push(self.dir.join(value.into_value())) } else { error!( @@ -2451,7 +2411,7 @@ impl ConfigFile { &mut self, key: &str ) -> Result>, Failed> { - match self.content.remove(key) { + match self.take_value(key)? { Some(toml::Value::Array(vec)) => { let mut res = HashMap::new(); for value in vec.into_iter() { @@ -2500,7 +2460,9 @@ impl ConfigFile { ); return Err(Failed); } - if res.insert(left, right).is_some() { + if res.insert( + left.into_value(), right.into_value() + ).is_some() { error!( "Failed in config file {}: \ 'duplicate item in '{}'.", @@ -2534,7 +2496,7 @@ impl ConfigFile { self.path.display() ); let mut first = true; - for key in self.content.keys() { + for (key, _) in self.content.iter() { if !first { print!(","); } @@ -2730,7 +2692,7 @@ mod test { #[test] fn read_your_own_config() { let out_config = get_default_config(); - let out_file = format!("{}", out_config.to_toml()); + let out_file = out_config.to_string(); let in_file = ConfigFile::parse( &out_file, Path::new("/test/routinator.conf") ).unwrap(); diff --git a/src/engine.rs b/src/engine.rs index 9736415..23f1a7c 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -18,7 +18,7 @@ /// the accompanying trait [`ProcessPubPoint`] dealing with individual /// publication points. -use std::{fmt, fs}; +use std::{fmt, fs, thread}; use std::borrow::Cow; use std::collections::HashMap; use std::fs::File; @@ -27,7 +27,6 @@ use std::sync::{Arc, Mutex}; use std::sync::atomic::{AtomicBool, Ordering}; use bytes::Bytes; use crossbeam_queue::{ArrayQueue, SegQueue}; -use crossbeam_utils::thread; use log::{debug, error, info, warn}; use rpki::crypto::keys::KeyIdentifier; #[allow(unused_imports)] @@ -400,9 +399,9 @@ impl<'a, P: ProcessRun> Run<'a, P> { let thread_metrics = ArrayQueue::new( self.validation.validation_threads ); - let res = thread::scope(|scope| { + thread::scope(|scope| { for _ in 0 .. self.validation.validation_threads { - scope.spawn(|_| { + scope.spawn(|| { let mut metrics = metrics.fork(); while let Some(task) = tasks.pop() { if self.process_task( @@ -416,15 +415,6 @@ impl<'a, P: ProcessRun> Run<'a, P> { } }); - if res.is_err() { - // One of the workers has panicked. Well gosh darn. - error!( - "Engine failed after a worker thread has panicked. \ - This is most assuredly a bug." - ); - return Err(Failed); - } - if had_err.load(Ordering::Relaxed) { return Err(Failed); } diff --git a/src/process.rs b/src/process.rs index 1dd1809..e43b0b9 100644 --- a/src/process.rs +++ b/src/process.rs @@ -6,11 +6,10 @@ use std::io::Write; use std::net::TcpListener; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; -use std::sync::Arc; +use std::sync::{Arc, OnceLock}; use bytes::Bytes; use chrono::Utc; use log::{error, LevelFilter}; -use once_cell::sync::OnceCell; use tokio::runtime::Runtime; use crate::config::{Config, LogTarget}; use crate::error::Failed; @@ -521,7 +520,7 @@ impl SyslogLogger { /// installed, it just writes all log output to stderr. struct GlobalLogger { /// The real logger. Can only be set once. - inner: OnceCell, + inner: OnceLock, } /// The static for the log crate. @@ -530,7 +529,7 @@ static GLOBAL_LOGGER: GlobalLogger = GlobalLogger::new(); impl GlobalLogger { /// Creates a new provisional logger. const fn new() -> Self { - GlobalLogger { inner: OnceCell::new() } + GlobalLogger { inner: OnceLock::new() } } /// Switches to the proper logger.