From d742171aa7edc3481b261b134877f9d72424ea2d Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Wed, 4 Jun 2025 16:52:24 -0400 Subject: [PATCH] add private route example --- CHANGELOG.md | 4 + Cargo.lock | 275 ++++++++++++------ Cargo.toml | 1 + Earthfile | 3 +- veilid-core/examples/basic/.gitignore | 1 - veilid-core/examples/basic/Cargo.toml | 10 +- veilid-core/examples/basic/README.md | 11 + veilid-core/examples/basic/src/main.rs | 21 +- veilid-core/examples/private_route/Cargo.toml | 30 ++ veilid-core/examples/private_route/README.md | 45 +++ .../examples/private_route/src/main.rs | 271 +++++++++++++++++ veilid-core/src/rpc_processor/rpc_app_call.rs | 2 +- .../src/rpc_processor/rpc_app_message.rs | 2 +- .../src/rpc_processor/rpc_cancel_tunnel.rs | 2 +- .../src/rpc_processor/rpc_complete_tunnel.rs | 2 +- .../src/rpc_processor/rpc_find_block.rs | 2 +- .../src/rpc_processor/rpc_find_node.rs | 2 +- .../src/rpc_processor/rpc_get_value.rs | 2 +- .../src/rpc_processor/rpc_inspect_value.rs | 2 +- .../src/rpc_processor/rpc_return_receipt.rs | 2 +- .../src/rpc_processor/rpc_set_value.rs | 2 +- veilid-core/src/rpc_processor/rpc_signal.rs | 2 +- .../src/rpc_processor/rpc_start_tunnel.rs | 2 +- veilid-core/src/rpc_processor/rpc_status.rs | 2 +- .../src/rpc_processor/rpc_supply_block.rs | 2 +- .../rpc_processor/rpc_validate_dial_info.rs | 2 +- .../src/rpc_processor/rpc_value_changed.rs | 2 +- .../src/rpc_processor/rpc_watch_value.rs | 2 +- .../veilid_test/lib/src/veilid_fixture.dart | 4 +- 29 files changed, 588 insertions(+), 122 deletions(-) delete mode 100644 veilid-core/examples/basic/.gitignore create mode 100644 veilid-core/examples/basic/README.md create mode 100644 veilid-core/examples/private_route/Cargo.toml create mode 100644 veilid-core/examples/private_route/README.md create mode 100644 veilid-core/examples/private_route/src/main.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index d21a4277..f6ae0ab7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +**UNRELEASED** + +- Add private route example + **Changed in Veilid 0.4.7** - _BREAKING API CHANGES_: diff --git a/Cargo.lock b/Cargo.lock index 7e7249f0..83d81d3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -186,12 +186,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.7" +version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa" dependencies = [ "anstyle", - "once_cell", + "once_cell_polyfill", "windows-sys 0.59.0", ] @@ -212,7 +212,7 @@ dependencies = [ "objc2", "objc2-app-kit", "objc2-foundation", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "percent-encoding", "x11rb", ] @@ -302,7 +302,7 @@ checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ "async-channel 2.3.1", "async-executor", - "async-io 2.4.0", + "async-io 2.4.1", "async-lock 3.4.0", "blocking", "futures-lite 2.6.0", @@ -331,9 +331,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" +checksum = "1237c0ae75a0f3765f58910ff9cdd0a12eeb39ab2f4c7de23262f337f0aacbb3" dependencies = [ "async-lock 3.4.0", "cfg-if 1.0.0", @@ -341,8 +341,8 @@ dependencies = [ "futures-io", "futures-lite 2.6.0", "parking", - "polling 3.7.4", - "rustix 0.38.44", + "polling 3.8.0", + "rustix 1.0.7", "slab", "tracing", "windows-sys 0.59.0", @@ -370,12 +370,12 @@ dependencies = [ [[package]] name = "async-process" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb" +checksum = "cde3f4e40e6021d7acffc90095cbd6dc54cb593903d1de5832f435eb274b85dc" dependencies = [ "async-channel 2.3.1", - "async-io 2.4.0", + "async-io 2.4.1", "async-lock 3.4.0", "async-signal", "async-task", @@ -383,23 +383,23 @@ dependencies = [ "cfg-if 1.0.0", "event-listener 5.4.0", "futures-lite 2.6.0", - "rustix 0.38.44", + "rustix 1.0.7", "tracing", ] [[package]] name = "async-signal" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" +checksum = "d7605a4e50d4b06df3898d5a70bf5fde51ed9059b0434b73105193bc27acce0d" dependencies = [ - "async-io 2.4.0", + "async-io 2.4.1", "async-lock 3.4.0", "atomic-waker", "cfg-if 1.0.0", "futures-core", "futures-io", - "rustix 0.38.44", + "rustix 1.0.7", "signal-hook-registry", "slab", "windows-sys 0.59.0", @@ -414,7 +414,7 @@ dependencies = [ "async-attributes", "async-channel 1.9.0", "async-global-executor", - "async-io 2.4.0", + "async-io 2.4.1", "async-lock 3.4.0", "async-process", "crossbeam-utils", @@ -445,7 +445,16 @@ dependencies = [ "futures-util", "hickory-resolver", "pin-utils", - "socket2 0.5.9", + "socket2 0.5.10", +] + +[[package]] +name = "async-stdin" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1ff8b5d9b5ec29e0f49583ba71847b8c8888b67a8510133048a380903aa6822" +dependencies = [ + "tokio", ] [[package]] @@ -695,9 +704,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" -version = "1.7.3" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e25b6adfb930f02d1981565a6e5d9c547ac15a96606256d3b59040e5cd4ca3" +checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" [[package]] name = "bindgen" @@ -864,9 +873,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "capnp" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1b4a00e80b7c4b1a49e845365f25c9d8fd0a19c9cd8d66f68afea47b1f020" +checksum = "64b3560604b407fe0ab6f89b81ac11887b4ae07f8d31486581dee5b353e48f06" dependencies = [ "embedded-io 0.6.1", ] @@ -882,9 +891,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.23" +version = "1.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766" +checksum = "d0fc897dc1e865cc67c0e05a836d9d3f1df3cbe442aa4a9473b18e12624a4951" dependencies = [ "shlex", ] @@ -1009,9 +1018,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.38" +version = "4.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" +checksum = "fd60e63e9be68e5fb56422e397cf9baddded06dae1d2e523401542383bc72a9f" dependencies = [ "clap_builder", "clap_derive", @@ -1019,9 +1028,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.38" +version = "4.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" +checksum = "89cc6392a1f72bbeb820d71f32108f61fdaf18bc526e1d23954168a67759ef51" dependencies = [ "anstream", "anstyle", @@ -1074,9 +1083,9 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "color-eyre" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e1761c0e16f8883bbbb8ce5990867f4f06bf11a0253da6495a04ce4b6ef0ec" +checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d" dependencies = [ "backtrace", "eyre", @@ -1134,7 +1143,19 @@ dependencies = [ "nom 7.1.3", "pathdiff", "serde", - "yaml-rust2", + "yaml-rust2 0.8.1", +] + +[[package]] +name = "config" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595aae20e65c3be792d05818e8c63025294ac3cb7e200f11459063a352a6ef80" +dependencies = [ + "pathdiff", + "serde", + "winnow 0.7.10", + "yaml-rust2 0.10.2", ] [[package]] @@ -1284,7 +1305,7 @@ dependencies = [ "crossterm_winapi", "libc", "mio 0.8.11", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "signal-hook", "signal-hook-mio", "winapi", @@ -1301,8 +1322,8 @@ dependencies = [ "derive_more", "document-features", "futures-core", - "mio 1.0.3", - "parking_lot 0.12.3", + "mio 1.0.4", + "parking_lot 0.12.4", "rustix 1.0.7", "signal-hook", "signal-hook-mio", @@ -1416,7 +1437,7 @@ dependencies = [ "log", "num", "owning_ref", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "serde_json", "serde_yaml", "time", @@ -1551,7 +1572,7 @@ dependencies = [ "hashbrown 0.14.5", "lock_api", "once_cell", - "parking_lot_core 0.9.10", + "parking_lot_core 0.9.11", ] [[package]] @@ -2014,6 +2035,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foreign-types" version = "0.3.2" @@ -2298,7 +2325,7 @@ dependencies = [ "grpcio-sys", "libc", "log", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "protobuf", ] @@ -2391,6 +2418,9 @@ name = "hashbrown" version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" +dependencies = [ + "foldhash", +] [[package]] name = "hashlink" @@ -2401,6 +2431,15 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.3", +] + [[package]] name = "hdrhistogram" version = "7.5.4" @@ -2461,9 +2500,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hermit-abi" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" +checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08" [[package]] name = "hex" @@ -2507,7 +2546,7 @@ dependencies = [ "ipconfig", "lru-cache", "once_cell", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "rand", "resolv-conf", "smallvec", @@ -2556,6 +2595,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "hostname" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56f203cd1c76362b69e3863fd987520ac36cf70a8c92627449b2f64a8cf7d65" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "windows-link", +] + [[package]] name = "http" version = "0.2.12" @@ -2624,7 +2674,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.10", "tokio", "tower-service", "tracing", @@ -2895,7 +2945,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.9", + "socket2 0.5.10", "widestring", "windows-sys 0.48.0", "winreg", @@ -3029,7 +3079,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "462f214495626d3245889a431c608f6791a10623735593cccfc9cbf4c72a73f1" dependencies = [ "keyvaluedb", - "parking_lot 0.12.3", + "parking_lot 0.12.4", ] [[package]] @@ -3041,7 +3091,7 @@ dependencies = [ "hex", "keyvaluedb", "log", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "rusqlite", ] @@ -3100,9 +3150,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a793df0d7afeac54f95b471d3af7f0d4fb975699f972341a4b76988d49cdf0c" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if 1.0.0", "windows-targets 0.53.0", @@ -3180,9 +3230,9 @@ checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" dependencies = [ "autocfg", "scopeguard", @@ -3314,14 +3364,14 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3394,7 +3444,7 @@ dependencies = [ "ndk-macro", "ndk-sys 0.4.1+23.1.7779620", "once_cell", - "parking_lot 0.12.3", + "parking_lot 0.12.4", ] [[package]] @@ -3787,6 +3837,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + [[package]] name = "opaque-debug" version = "0.3.1" @@ -3795,9 +3851,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.72" +version = "0.10.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" +checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" dependencies = [ "bitflags 2.9.1", "cfg-if 1.0.0", @@ -3827,9 +3883,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.108" +version = "0.9.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847" +checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" dependencies = [ "cc", "libc", @@ -4094,12 +4150,12 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" dependencies = [ "lock_api", - "parking_lot_core 0.9.10", + "parking_lot_core 0.9.11", ] [[package]] @@ -4118,9 +4174,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.10" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "cfg-if 1.0.0", "libc", @@ -4271,15 +4327,15 @@ dependencies = [ [[package]] name = "polling" -version = "3.7.4" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" +checksum = "b53a684391ad002dd6a596ceb6c74fd004fdce75f4be2e3f615068abbea5fd50" dependencies = [ "cfg-if 1.0.0", "concurrent-queue", - "hermit-abi 0.4.0", + "hermit-abi 0.5.1", "pin-project-lite", - "rustix 0.38.44", + "rustix 1.0.7", "tracing", "windows-sys 0.59.0", ] @@ -4712,7 +4768,7 @@ dependencies = [ "bitflags 2.9.1", "fallible-iterator", "fallible-streaming-iterator", - "hashlink", + "hashlink 0.8.4", "libsqlite3-sys", "smallvec", ] @@ -4811,9 +4867,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" [[package]] name = "rustyline-async" @@ -5169,7 +5225,7 @@ dependencies = [ "futures", "lazy_static", "log", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "serial_test_derive 2.0.0", ] @@ -5182,7 +5238,7 @@ dependencies = [ "futures", "log", "once_cell", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "scc", "serial_test_derive 3.2.0", ] @@ -5295,7 +5351,7 @@ checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", "mio 0.8.11", - "mio 1.0.3", + "mio 1.0.4", "signal-hook", ] @@ -5365,9 +5421,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" dependencies = [ "libc", "windows-sys 0.52.0", @@ -5561,7 +5617,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "662b54ef6f7b4e71f683dadc787bbb2d8e8ef2f91b682ebed3164a5a7abca905" dependencies = [ - "parking_lot 0.12.3", + "parking_lot 0.12.4", "pin-project 1.1.10", ] @@ -5685,18 +5741,18 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.45.0" +version = "1.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" +checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779" dependencies = [ "backtrace", "bytes 1.10.1", "libc", - "mio 1.0.3", - "parking_lot 0.12.3", + "mio 1.0.4", + "parking_lot 0.12.4", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.9", + "socket2 0.5.10", "tokio-macros", "tracing", "windows-sys 0.52.0", @@ -6352,8 +6408,8 @@ dependencies = [ "async-tungstenite 0.23.0", "cfg-if 1.0.0", "chrono", - "clap 4.5.38", - "config 0.13.4", + "clap 4.5.39", + "config 0.15.11", "console", "crossbeam-channel", "cursive", @@ -6370,7 +6426,7 @@ dependencies = [ "log", "lru", "owning_ref", - "parking_lot 0.11.2", + "parking_lot 0.12.4", "rustyline-async", "serde", "serde_derive", @@ -6438,7 +6494,7 @@ dependencies = [ "num-traits", "once_cell", "paranoid-android", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "paste", "range-set-blaze", "reqwest", @@ -6497,6 +6553,20 @@ dependencies = [ "veilid-core", ] +[[package]] +name = "veilid-core-examples-private-route" +version = "0.1.0" +dependencies = [ + "async-stdin", + "clap 4.5.39", + "ctrlc", + "data-encoding", + "tokio", + "tracing", + "tracing-subscriber", + "veilid-core", +] + [[package]] name = "veilid-flutter" version = "0.4.7" @@ -6510,7 +6580,7 @@ dependencies = [ "data-encoding", "ffi-support", "futures-util", - "hostname", + "hostname 0.3.1", "jni", "lazy_static", "libc-print", @@ -6519,7 +6589,7 @@ dependencies = [ "opentelemetry-semantic-conventions 0.12.0", "oslog", "paranoid-android", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "serde", "serde_json", "tokio", @@ -6559,7 +6629,7 @@ dependencies = [ name = "veilid-remote-api" version = "0.4.7" dependencies = [ - "parking_lot 0.12.3", + "parking_lot 0.12.4", "schemars", "serde", "serde_json", @@ -6577,7 +6647,7 @@ dependencies = [ "backtrace", "cfg-if 1.0.0", "chrono", - "clap 4.5.38", + "clap 4.5.39", "color-eyre", "config 0.14.1", "console-subscriber", @@ -6586,7 +6656,7 @@ dependencies = [ "directories", "flume", "futures-util", - "hostname", + "hostname 0.4.1", "json", "lazy_static", "nix 0.29.0", @@ -6594,7 +6664,7 @@ dependencies = [ "opentelemetry-otlp 0.16.0", "opentelemetry-semantic-conventions 0.16.0", "opentelemetry_sdk 0.23.0", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "rpassword", "serde", "serde_derive", @@ -6636,7 +6706,7 @@ dependencies = [ "backtrace", "cfg-if 1.0.0", "chrono", - "clap 4.5.38", + "clap 4.5.39", "console_error_panic_hook", "ctrlc", "eyre", @@ -6663,7 +6733,7 @@ dependencies = [ "once_cell", "oslog", "paranoid-android", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "postcard", "rand", "rand_chacha", @@ -6675,7 +6745,7 @@ dependencies = [ "serde_yaml_ng", "serial_test 2.0.0", "simplelog", - "socket2 0.5.9", + "socket2 0.5.10", "static_assertions", "stop-token", "thiserror 1.0.69", @@ -6720,8 +6790,8 @@ dependencies = [ "gloo-utils", "js-sys", "lazy_static", - "parking_lot 0.12.3", - "send_wrapper 0.4.0", + "parking_lot 0.12.4", + "send_wrapper 0.6.0", "serde", "serde-wasm-bindgen", "serde_bytes", @@ -6949,7 +7019,7 @@ checksum = "7aafc5e81e847f05d6770e074faf7b1cd4a5dec9a0e88eac5d55e20fdfebee9a" dependencies = [ "event-listener 5.4.0", "futures-core", - "parking_lot 0.12.3", + "parking_lot 0.12.4", "pin-project-lite", "triomphe", ] @@ -7547,7 +7617,18 @@ checksum = "8902160c4e6f2fb145dbe9d6760a75e3c9522d8bf796ed7047c85919ac7115f8" dependencies = [ "arraydeque", "encoding_rs", - "hashlink", + "hashlink 0.8.4", +] + +[[package]] +name = "yaml-rust2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18b783b2c2789414f8bb84ca3318fc9c2d7e7be1c22907d37839a58dedb369d3" +dependencies = [ + "arraydeque", + "encoding_rs", + "hashlink 0.10.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 183cd7b0..a80b1dba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ members = [ "veilid-tools", "veilid-core", "veilid-core/examples/basic", + "veilid-core/examples/private_route", "veilid-server", "veilid-cli", "veilid-flutter/rust", diff --git a/Earthfile b/Earthfile index 83f23131..df61450a 100644 --- a/Earthfile +++ b/Earthfile @@ -138,11 +138,12 @@ deps-linux: # Make a cache image with downloaded and built dependencies build-linux-cache: FROM +deps-linux - RUN mkdir -p veilid-cli veilid-core veilid-core/examples/basic veilid-server veilid-tools veilid-wasm veilid-flutter veilid-flutter/rust veilid-remote-api + RUN mkdir -p veilid-cli veilid-core veilid-core/examples/basic veilid-core/examples/private_route veilid-server veilid-tools veilid-wasm veilid-flutter veilid-flutter/rust veilid-remote-api COPY --keep-ts --dir .cargo scripts Cargo.lock Cargo.toml . COPY --keep-ts veilid-cli/Cargo.toml veilid-cli COPY --keep-ts veilid-core/Cargo.toml veilid-core COPY --keep-ts veilid-core/examples/basic/Cargo.toml veilid-core/examples/basic + COPY --keep-ts veilid-core/examples/private_route/Cargo.toml veilid-core/examples/private_route COPY --keep-ts veilid-server/Cargo.toml veilid-server COPY --keep-ts veilid-tools/Cargo.toml veilid-tools COPY --keep-ts veilid-remote-api/Cargo.toml veilid-remote-api diff --git a/veilid-core/examples/basic/.gitignore b/veilid-core/examples/basic/.gitignore deleted file mode 100644 index d9ba8aed..00000000 --- a/veilid-core/examples/basic/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.veilid \ No newline at end of file diff --git a/veilid-core/examples/basic/Cargo.toml b/veilid-core/examples/basic/Cargo.toml index 24372bc3..7dcaab66 100644 --- a/veilid-core/examples/basic/Cargo.toml +++ b/veilid-core/examples/basic/Cargo.toml @@ -1,20 +1,24 @@ [package] name = "veilid-core-examples-basic" version = "0.1.0" +# --- +description = "Example demonstrating a basic Veilid application" +resolver = "2" repository.workspace = true authors.workspace = true license.workspace = true edition.workspace = true rust-version.workspace = true +autobins = false publish = false -[[bin]] -name = "basic" +[[example]] +name = "basic-example" path = "./src/main.rs" [dependencies] tokio = { version = "^1.43.0" } -veilid-core = { version = "0.4.7", path = "../../../veilid-core" } +veilid-core = { path = "../../../veilid-core" } [lints] workspace = true diff --git a/veilid-core/examples/basic/README.md b/veilid-core/examples/basic/README.md new file mode 100644 index 00000000..9a4c07fa --- /dev/null +++ b/veilid-core/examples/basic/README.md @@ -0,0 +1,11 @@ +# Basic Example + +Demonstration of simple Veilid application that just starts a node + +## Running this example + +Run this: + +``` +# cargo run --example basic-example +``` diff --git a/veilid-core/examples/basic/src/main.rs b/veilid-core/examples/basic/src/main.rs index 5b5033a4..36651f19 100644 --- a/veilid-core/examples/basic/src/main.rs +++ b/veilid-core/examples/basic/src/main.rs @@ -4,6 +4,7 @@ use veilid_core::{VeilidConfig, VeilidConfigProtectedStore, VeilidConfigTableSto #[tokio::main] async fn main() { + // Create a basic update callback to display Veilid's update events let update_callback = Arc::new(move |update: VeilidUpdate| { match update { AppMessage(msg) => { @@ -23,6 +24,12 @@ async fn main() { }; }); + // Set up a config for this application + let exe_dir = std::env::current_exe() + .map(|x| x.parent().map(|p| p.to_owned())) + .ok() + .flatten() + .unwrap_or(".".into()); let config = VeilidConfig { program_name: "Example Veilid".into(), namespace: "veilid-example".into(), @@ -31,16 +38,23 @@ async fn main() { // IMPORTANT: don't do this in production // This avoids prompting for a password and is insecure always_use_insecure_storage: true, - directory: "./.veilid/protected_store".into(), + directory: exe_dir + .join(".veilid/protected_store") + .to_string_lossy() + .to_string(), ..Default::default() }, table_store: VeilidConfigTableStore { - directory: "./.veilid/table_store".into(), + directory: exe_dir + .join(".veilid/table_store") + .to_string_lossy() + .to_string(), ..Default::default() }, ..Default::default() }; + // Startup Veilid node let veilid = veilid_core::api_startup_config(update_callback, config) .await .unwrap(); @@ -48,7 +62,10 @@ async fn main() { "Node ID: {}", veilid.config().unwrap().get().network.routing_table.node_id ); + + // Attach to the network veilid.attach().await.unwrap(); + // Until CTRL+C is pressed, keep running tokio::signal::ctrl_c().await.unwrap(); veilid.shutdown().await; diff --git a/veilid-core/examples/private_route/Cargo.toml b/veilid-core/examples/private_route/Cargo.toml new file mode 100644 index 00000000..20acb213 --- /dev/null +++ b/veilid-core/examples/private_route/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "veilid-core-examples-private-route" +version = "0.1.0" +# --- +description = "Example demonstrating Veilid private routes" +resolver = "2" +repository.workspace = true +authors.workspace = true +license.workspace = true +edition.workspace = true +rust-version.workspace = true +autobins = false +publish = false + +[[example]] +name = "private-route-example" +path = "src/main.rs" + +[dependencies] +async-stdin = "0.3.1" +clap = { version = "4.5.39", features = ["derive"] } +ctrlc = "3.4.7" +data-encoding = "2.9.0" +tokio = "1.45.1" +tracing = "0.1.41" +tracing-subscriber = "0.3.19" +veilid-core = { path = "../../../veilid-core" } + +[lints] +workspace = true diff --git a/veilid-core/examples/private_route/README.md b/veilid-core/examples/private_route/README.md new file mode 100644 index 00000000..5b531f1b --- /dev/null +++ b/veilid-core/examples/private_route/README.md @@ -0,0 +1,45 @@ +# Private Route Example + +Demonstration of the creation of private routes in a basic client/server style pattern. + +## Running this example + +To use, start a *server* that creates a private route: + +``` +# cargo run --example private-route-example +``` +which will produce output like this: +``` +Veilid Private Routing Example +Waiting................. +Route id created: lRETsplk7wWg2QiF7OodCOSC9SbhFx9tyWtk2KVHs70 +Connect with this private route blob: +cargo run --example private-route-example -- --connect ARAeUAECAQJRBAEBURgBAg8wRExWEAT/NZxHC0sOm9oDPYts06hETjdBFhQ7akbgwU9cR/+HIODlAAARBARBEAL/XwgITBMjGe8DIS8kAw0VyKcu6d65YES+lapmgYaJmK8SEQQDMQ3yAf9mmhQquLvXsgm1h/MEQma0jQEJmg6dajJdNqQ7EZjyViM9Vp+zA/e2/QG8xyRiMmDKJuJ6ixQ+CW8HQcSSKdgp0wC0ATUrZTTCQmZ8m/BWlJ8/0qySnSFj +Press ctrl-c when you are finished. +``` + +Then, in a second terminal, or on another machine, run a *client* that connects to this private route: + +``` +# cargo run --example private-route-example -- --connect ARAeUAECAQJRBAEBURgBAg8wRExWEAT/NZxHC0sOm9oDPYts06hETjdBFhQ7akbgwU9cR/+HIODlAAARBARBEAL/XwgITBMjGe8DIS8kAw0VyKcu6d65YES+lapmgYaJmK8SEQQDMQ3yAf9mmhQquLvXsgm1h/MEQma0jQEJmg6dajJdNqQ7EZjyViM9Vp+zA/e2/QG8xyRiMmDKJuJ6ixQ+CW8HQcSSKdgp0wC0ATUrZTTCQmZ8m/BWlJ8/0qySnSFj +``` + +Now, you can send lines from the *client* to the *server* and the will show up in the *server*'s terminal: + +``` +AppMessage received: testing 1 2 3 +AppMessage received: yay it works +``` + +## Note + +You may notice spurious route failures and errors in the console of this test program. + +For example: + +``` +VeilidRouteChange { dead_routes: [RouteId(Osifkt3Q3j6O5x03o85iBtpw8sBe5gUhLQW1n6bd7Ws)], dead_remote_routes: [] } +``` + +This example is a work in progress and is being used as a testbed to improve the quality of Veilid's private routing API. While there exist ways to stabilize the existing private routing mechanism, they are beyond the scope of this example code. Rather, we are working on putting all of the required logic into veilid-core itself. Once this is done, this example will be updated, and this note will be removed. diff --git a/veilid-core/examples/private_route/src/main.rs b/veilid-core/examples/private_route/src/main.rs new file mode 100644 index 00000000..6c6cafb2 --- /dev/null +++ b/veilid-core/examples/private_route/src/main.rs @@ -0,0 +1,271 @@ +use clap::Parser; +use std::{future::Future, io::Write as _, sync::Arc}; +use tracing_subscriber::{layer::SubscriberExt as _, util::SubscriberInitExt as _, Layer}; +use veilid_core::*; + +#[derive(Parser)] +#[command(version, about, long_about = None)] +struct Cli { + /// Route blob to connect to + #[arg(long)] + connect: Option, + + /// Turn debugging information on + #[arg(short, long, action = clap::ArgAction::Count)] + debug: u8, +} + +#[tokio::main] +async fn main() -> Result<(), Box> { + println!("Veilid Private Routing Example"); + + // Parse the command line + let cli = Cli::parse(); + + // Set up exit handler + let (done_send, done_recv) = tokio::sync::mpsc::channel(1); + ctrlc::set_handler(move || { + let _ = done_send.try_send(()); + }) + .expect("Error setting Ctrl-C handler"); + + // Set up some basic Veilid terminal logging + setup_veilid_terminal_logging(cli.debug); + + // Set up a config for this application + let exe_dir = std::env::current_exe() + .map(|x| x.parent().map(|p| p.to_owned())) + .ok() + .flatten() + .unwrap_or(".".into()); + + let config = VeilidConfig { + program_name: "Veilid Private Routing Example".into(), + protected_store: VeilidConfigProtectedStore { + // IMPORTANT: don't do this in production + // This avoids prompting for a password and is insecure + always_use_insecure_storage: true, + directory: exe_dir + .join(".veilid/protected_store") + .to_string_lossy() + .to_string(), + ..Default::default() + }, + table_store: VeilidConfigTableStore { + directory: exe_dir + .join(".veilid/table_store") + .to_string_lossy() + .to_string(), + ..Default::default() + }, + ..Default::default() + }; + + // Handle 'connect' option + if let Some(connect) = cli.connect { + // Parse the blob from base64 + let blob: Vec = data_encoding::BASE64.decode(connect.as_bytes())?; + + // Open the route + return open_route(blob, done_recv, config).await; + } + + // Create a new route and listen on it + create_route(done_recv, config).await +} + +async fn try_again_loop>>( + f: impl Fn() -> F, +) -> VeilidAPIResult { + let mut waiting = false; + loop { + let res = f().await; + match res { + Ok(v) => { + if waiting { + println!("ready."); + } + return Ok(v); + } + Err(VeilidAPIError::TryAgain { message: _ }) => { + if !waiting { + print!("Waiting for network..."); + waiting = true; + } else { + print!("."); + } + let _ = std::io::stdout().flush(); + tools::sleep(1000).await; + } + // XXX: This should not be necessary, and VeilidAPIError::TryAgain should + // be used in the case of 'allocated route failed to test'. + Err(VeilidAPIError::Generic { message }) => { + if waiting { + println!(); + waiting = false; + } + println!("Error: {message}"); + tools::sleep(1000).await; + } + Err(e) => { + if waiting { + println!(); + } + return Err(e); + } + } + } +} + +fn setup_veilid_terminal_logging(debug: u8) { + // Set up logging + let subscriber = tracing_subscriber::Registry::default(); + let mut layers = Vec::new(); + let mut fields_to_strip = std::collections::HashSet::<&'static str>::new(); + fields_to_strip.insert(veilid_core::VEILID_LOG_KEY_FIELD); + + let filter = VeilidLayerFilter::new( + if debug == 1 { + VeilidConfigLogLevel::Info + } else if debug == 2 { + VeilidConfigLogLevel::Debug + } else if debug >= 3 { + VeilidConfigLogLevel::Trace + } else { + VeilidConfigLogLevel::Warn + }, + &[], + None, + ); + let layer = tracing_subscriber::fmt::Layer::new() + .compact() + .map_fmt_fields(|f| veilid_core::FmtStripFields::new(f, fields_to_strip.clone())) + .with_writer(std::io::stdout) + .with_filter(filter.clone()); + layers.push(layer.boxed()); + let subscriber = subscriber.with(layers); + + subscriber + .try_init() + .map_err(|e| e.to_string()) + .expect("failed to initialize logging"); +} + +async fn veilid_api_scope<'a, F: Future>>, T>( + update_callback: impl Fn(VeilidUpdate) + Send + Sync + 'static, + veilid_config: VeilidConfig, + scope: impl FnOnce(VeilidAPI) -> F + Send + Sync + 'a, +) -> Result> { + // Startup Veilid node + // Note: future is boxed due to its size and our aggressive clippy lints + let veilid_api = Box::pin(api_startup_config(Arc::new(update_callback), veilid_config)).await?; + + // Attach to the network + veilid_api.attach().await?; + + // Operate the Veilid node inside a scope + let res = scope(veilid_api.clone()).await; + + // Clean shutdown + veilid_api.shutdown().await; + + // Return result + res +} + +async fn create_route( + mut done_recv: tokio::sync::mpsc::Receiver<()>, + mut config: VeilidConfig, +) -> Result<(), Box> { + // Use a namespace for the receiving side of the private route + config.namespace = "recv".to_owned(); + + // Run veilid node + veilid_api_scope(update_callback, config, |veilid_api| async move { + + // Create a new private route endpoint + let (route_id, route_blob) = + try_again_loop(|| async { veilid_api.new_private_route().await }).await?; + + // Print the blob + println!( + "Route id created: {route_id}\nConnect with this private route blob:\ncargo run --example private-route-example -- --connect {}", + data_encoding::BASE64.encode(&route_blob) + ); + + // Wait for enter key to exit the application + // The VeilidUpdate for AppMessages will print received messages in the background + println!("Press ctrl-c when you are finished."); + let _ = done_recv.recv().await; + + Ok(()) + + }).await +} + +async fn open_route( + route_blob: Vec, + mut done_recv: tokio::sync::mpsc::Receiver<()>, + mut config: VeilidConfig, +) -> Result<(), Box> { + // Use a namespace for the sending side of the private route + config.namespace = "send".to_owned(); + + // Run veilid node + veilid_api_scope(update_callback, config, |veilid_api| async move { + // Import the private route blob + let route_id = + try_again_loop(|| async { veilid_api.import_remote_private_route(route_blob.clone()) }) + .await?; + + // Create a routing context to send with + let rc = veilid_api.routing_context()?; + + // Get some strings from stdin to send + println!("Enter some lines to send. Send an empty line when you're finished."); + + let mut rx = async_stdin::recv_from_stdin(1); + + loop { + tokio::select! { + val = rx.recv() => { + if let Some(val) = val { + if val.is_empty() { + break; + } + try_again_loop(|| async { rc.app_message(Target::PrivateRoute(route_id), val.as_bytes().to_vec()).await }) + .await?; + } else { + break; + } + } + _ = done_recv.recv() => { + break; + } + } + } + + Ok(()) + }).await +} + +fn update_callback(update: VeilidUpdate) { + match update { + VeilidUpdate::Log(_veilid_log) => {} + VeilidUpdate::AppMessage(veilid_app_message) => { + let msg = String::from_utf8_lossy(veilid_app_message.message()); + println!("AppMessage received: {msg}"); + } + VeilidUpdate::AppCall(_veilid_app_call) => {} + VeilidUpdate::Attachment(_veilid_state_attachment) => {} + VeilidUpdate::Network(_veilid_state_network) => {} + VeilidUpdate::Config(_veilid_state_config) => {} + VeilidUpdate::RouteChange(veilid_route_change) => { + // XXX: If this happens, the route is dead, and a new one should be generated and + // exchanged. This will no longer be necessary after DHT Route Autopublish is implemented + println!("{veilid_route_change:?}"); + } + VeilidUpdate::ValueChange(_veilid_value_change) => {} + VeilidUpdate::Shutdown => {} + } +} diff --git a/veilid-core/src/rpc_processor/rpc_app_call.rs b/veilid-core/src/rpc_processor/rpc_app_call.rs index f66cd2cf..1ea49b43 100644 --- a/veilid-core/src/rpc_processor/rpc_app_call.rs +++ b/veilid-core/src/rpc_processor/rpc_app_call.rs @@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc"); impl RPCProcessor { // Sends a high level app request and wait for response // Can be sent via all methods including relays and routes - #[instrument(level = "trace", target = "rpc", skip(self, message), fields(message.len = message.len(), ret.latency, ret.len), err)] + #[instrument(level = "trace", target = "rpc", skip(self, message), fields(message.len = message.len(), ret.latency, ret.len), err(level=Level::DEBUG))] pub async fn rpc_call_app_call( &self, dest: Destination, diff --git a/veilid-core/src/rpc_processor/rpc_app_message.rs b/veilid-core/src/rpc_processor/rpc_app_message.rs index bbd99f27..3c9fca24 100644 --- a/veilid-core/src/rpc_processor/rpc_app_message.rs +++ b/veilid-core/src/rpc_processor/rpc_app_message.rs @@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc"); impl RPCProcessor { // Sends a high level app message // Can be sent via all methods including relays and routes - #[instrument(level = "trace", target = "rpc", skip(self, message), fields(message.len = message.len()), err)] + #[instrument(level = "trace", target = "rpc", skip(self, message), fields(message.len = message.len()), err(level=Level::DEBUG))] pub async fn rpc_call_app_message( &self, dest: Destination, diff --git a/veilid-core/src/rpc_processor/rpc_cancel_tunnel.rs b/veilid-core/src/rpc_processor/rpc_cancel_tunnel.rs index 2a9f2cd6..2235fe8e 100644 --- a/veilid-core/src/rpc_processor/rpc_cancel_tunnel.rs +++ b/veilid-core/src/rpc_processor/rpc_cancel_tunnel.rs @@ -3,7 +3,7 @@ use super::*; impl_veilid_log_facility!("rpc"); impl RPCProcessor { - #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err)] + #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err(level=Level::DEBUG))] pub(super) async fn process_cancel_tunnel_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> { // Ignore if disabled #[cfg(feature = "unstable-tunnels")] diff --git a/veilid-core/src/rpc_processor/rpc_complete_tunnel.rs b/veilid-core/src/rpc_processor/rpc_complete_tunnel.rs index a36704e3..b5e5ce83 100644 --- a/veilid-core/src/rpc_processor/rpc_complete_tunnel.rs +++ b/veilid-core/src/rpc_processor/rpc_complete_tunnel.rs @@ -3,7 +3,7 @@ use super::*; impl_veilid_log_facility!("rpc"); impl RPCProcessor { - #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err)] + #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err(level=Level::DEBUG))] pub(super) async fn process_complete_tunnel_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> { // Ignore if disabled #[cfg(feature = "unstable-tunnels")] diff --git a/veilid-core/src/rpc_processor/rpc_find_block.rs b/veilid-core/src/rpc_processor/rpc_find_block.rs index f08f74f7..869f8642 100644 --- a/veilid-core/src/rpc_processor/rpc_find_block.rs +++ b/veilid-core/src/rpc_processor/rpc_find_block.rs @@ -3,7 +3,7 @@ use super::*; impl_veilid_log_facility!("rpc"); impl RPCProcessor { - #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err)] + #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err(level=Level::DEBUG))] pub(super) async fn process_find_block_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> { // Ignore if disabled #[cfg(feature = "unstable-blockstore")] diff --git a/veilid-core/src/rpc_processor/rpc_find_node.rs b/veilid-core/src/rpc_processor/rpc_find_node.rs index 05052377..220c0ce7 100644 --- a/veilid-core/src/rpc_processor/rpc_find_node.rs +++ b/veilid-core/src/rpc_processor/rpc_find_node.rs @@ -9,7 +9,7 @@ impl RPCProcessor { /// Because this leaks information about the identity of the node itself, /// replying to this request received over a private route will leak /// the identity of the node and defeat the private route. - #[instrument(level = "trace", target = "rpc", skip(self), err)] + #[instrument(level = "trace", target = "rpc", skip(self), err(level=Level::DEBUG))] pub async fn rpc_call_find_node( &self, dest: Destination, diff --git a/veilid-core/src/rpc_processor/rpc_get_value.rs b/veilid-core/src/rpc_processor/rpc_get_value.rs index 9feba0bb..23e9bf74 100644 --- a/veilid-core/src/rpc_processor/rpc_get_value.rs +++ b/veilid-core/src/rpc_processor/rpc_get_value.rs @@ -24,7 +24,7 @@ impl RPCProcessor { ret.value.data.writer, ret.peers.len, ret.latency - ),err)] + ),err(level=Level::DEBUG))] pub async fn rpc_call_get_value( &self, dest: Destination, diff --git a/veilid-core/src/rpc_processor/rpc_inspect_value.rs b/veilid-core/src/rpc_processor/rpc_inspect_value.rs index 6ce5df31..64d13405 100644 --- a/veilid-core/src/rpc_processor/rpc_inspect_value.rs +++ b/veilid-core/src/rpc_processor/rpc_inspect_value.rs @@ -25,7 +25,7 @@ impl RPCProcessor { instrument(level = "trace", target = "rpc", skip(self, last_descriptor), fields(ret.peers.len, ret.latency - ),err) + ),err(level=Level::DEBUG)) ] pub async fn rpc_call_inspect_value( &self, diff --git a/veilid-core/src/rpc_processor/rpc_return_receipt.rs b/veilid-core/src/rpc_processor/rpc_return_receipt.rs index 5bf4ffe8..4cfcbc7b 100644 --- a/veilid-core/src/rpc_processor/rpc_return_receipt.rs +++ b/veilid-core/src/rpc_processor/rpc_return_receipt.rs @@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc"); impl RPCProcessor { // Sends a unidirectional in-band return receipt // Can be sent via all methods including relays and routes - #[instrument(level = "trace", target = "rpc", skip(self, receipt), ret, err)] + #[instrument(level = "trace", target = "rpc", skip(self, receipt), ret, err(level=Level::DEBUG))] pub async fn rpc_call_return_receipt>( &self, dest: Destination, diff --git a/veilid-core/src/rpc_processor/rpc_set_value.rs b/veilid-core/src/rpc_processor/rpc_set_value.rs index 506d15af..c7fa891a 100644 --- a/veilid-core/src/rpc_processor/rpc_set_value.rs +++ b/veilid-core/src/rpc_processor/rpc_set_value.rs @@ -26,7 +26,7 @@ impl RPCProcessor { ret.value.data.writer, ret.peers.len, ret.latency - ), err)] + ), err(level=Level::DEBUG))] pub async fn rpc_call_set_value( &self, dest: Destination, diff --git a/veilid-core/src/rpc_processor/rpc_signal.rs b/veilid-core/src/rpc_processor/rpc_signal.rs index a14b74d2..bee1e4e2 100644 --- a/veilid-core/src/rpc_processor/rpc_signal.rs +++ b/veilid-core/src/rpc_processor/rpc_signal.rs @@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc"); impl RPCProcessor { // Sends a unidirectional signal to a node // Can be sent via relays but not routes. For routed 'signal' like capabilities, use AppMessage. - #[instrument(level = "trace", target = "rpc", skip(self), ret, err)] + #[instrument(level = "trace", target = "rpc", skip(self), ret, err(level=Level::DEBUG))] pub async fn rpc_call_signal( &self, dest: Destination, diff --git a/veilid-core/src/rpc_processor/rpc_start_tunnel.rs b/veilid-core/src/rpc_processor/rpc_start_tunnel.rs index 2e4a6db0..1ae91c22 100644 --- a/veilid-core/src/rpc_processor/rpc_start_tunnel.rs +++ b/veilid-core/src/rpc_processor/rpc_start_tunnel.rs @@ -3,7 +3,7 @@ use super::*; impl_veilid_log_facility!("rpc"); impl RPCProcessor { - #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err)] + #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err(level=Level::DEBUG))] pub(super) async fn process_start_tunnel_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> { // Ignore if disabled #[cfg(feature = "unstable-tunnels")] diff --git a/veilid-core/src/rpc_processor/rpc_status.rs b/veilid-core/src/rpc_processor/rpc_status.rs index 52e5c5a1..d52e2ecc 100644 --- a/veilid-core/src/rpc_processor/rpc_status.rs +++ b/veilid-core/src/rpc_processor/rpc_status.rs @@ -18,7 +18,7 @@ impl RPCProcessor { // direct -> node status + sender info // safety -> node status // private -> nothing - #[instrument(level = "trace", target = "rpc", skip(self), ret, err)] + #[instrument(level = "trace", target = "rpc", skip(self), ret, err(level=Level::DEBUG))] pub async fn rpc_call_status( &self, dest: Destination, diff --git a/veilid-core/src/rpc_processor/rpc_supply_block.rs b/veilid-core/src/rpc_processor/rpc_supply_block.rs index ea2332e2..2b86ebb3 100644 --- a/veilid-core/src/rpc_processor/rpc_supply_block.rs +++ b/veilid-core/src/rpc_processor/rpc_supply_block.rs @@ -3,7 +3,7 @@ use super::*; impl_veilid_log_facility!("rpc"); impl RPCProcessor { - #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err)] + #[instrument(level = "trace", target = "rpc", skip(self, msg), fields(msg.operation.op_id), ret, err(level=Level::DEBUG))] pub(super) async fn process_supply_block_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> { // Ignore if disabled #[cfg(feature = "unstable-blockstore")] diff --git a/veilid-core/src/rpc_processor/rpc_validate_dial_info.rs b/veilid-core/src/rpc_processor/rpc_validate_dial_info.rs index 8c1bd73f..dfee59aa 100644 --- a/veilid-core/src/rpc_processor/rpc_validate_dial_info.rs +++ b/veilid-core/src/rpc_processor/rpc_validate_dial_info.rs @@ -4,7 +4,7 @@ impl_veilid_log_facility!("rpc"); impl RPCProcessor { // Can only be sent directly, not via relays or routes - #[instrument(level = "trace", target = "rpc", skip(self), ret, err)] + #[instrument(level = "trace", target = "rpc", skip(self), ret, err(level=Level::DEBUG))] pub async fn rpc_call_validate_dial_info( &self, peer: NodeRef, diff --git a/veilid-core/src/rpc_processor/rpc_value_changed.rs b/veilid-core/src/rpc_processor/rpc_value_changed.rs index 6e624497..ea4c8202 100644 --- a/veilid-core/src/rpc_processor/rpc_value_changed.rs +++ b/veilid-core/src/rpc_processor/rpc_value_changed.rs @@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc"); impl RPCProcessor { // Sends a dht value change notification // Can be sent via all methods including relays and routes but never over a safety route - #[instrument(level = "trace", target = "rpc", skip(self, value), err)] + #[instrument(level = "trace", target = "rpc", skip(self, value), err(level=Level::DEBUG))] pub async fn rpc_call_value_changed( &self, dest: Destination, diff --git a/veilid-core/src/rpc_processor/rpc_watch_value.rs b/veilid-core/src/rpc_processor/rpc_watch_value.rs index d548a2d0..3479195d 100644 --- a/veilid-core/src/rpc_processor/rpc_watch_value.rs +++ b/veilid-core/src/rpc_processor/rpc_watch_value.rs @@ -22,7 +22,7 @@ impl RPCProcessor { fields(ret.expiration, ret.latency, ret.peers.len - ),err)] + ),err(level=Level::DEBUG))] #[allow(clippy::too_many_arguments)] pub async fn rpc_call_watch_value( &self, diff --git a/veilid-flutter/packages/veilid_test/lib/src/veilid_fixture.dart b/veilid-flutter/packages/veilid_test/lib/src/veilid_fixture.dart index 8700ae84..b8397e66 100644 --- a/veilid-flutter/packages/veilid_test/lib/src/veilid_fixture.dart +++ b/veilid-flutter/packages/veilid_test/lib/src/veilid_fixture.dart @@ -6,7 +6,7 @@ import 'dart:async'; import 'package:async_tools/async_tools.dart'; import 'package:veilid/veilid.dart'; -bool kIsWeb = const bool.fromEnvironment('dart.library.js_util'); +const kIsWeb = bool.fromEnvironment('dart.library.js_util'); abstract class VeilidFixture { Future setUp(); @@ -111,6 +111,8 @@ class DefaultVeilidFixture implements VeilidFixture { _veilidUpdateSubscription = us.listen((update) { if (update is VeilidLog) { + // Tests should print logs + // ignore: avoid_print print(update.message); } else if (update is VeilidUpdateAttachment) { } else if (update is VeilidUpdateConfig) {