add private route example

This commit is contained in:
Christien Rioux 2025-06-04 16:52:24 -04:00
parent e5e3fd03c1
commit d742171aa7
29 changed files with 588 additions and 122 deletions

View file

@ -1,3 +1,7 @@
**UNRELEASED**
- Add private route example
**Changed in Veilid 0.4.7** **Changed in Veilid 0.4.7**
- _BREAKING API CHANGES_: - _BREAKING API CHANGES_:

275
Cargo.lock generated
View file

@ -186,12 +186,12 @@ dependencies = [
[[package]] [[package]]
name = "anstyle-wincon" name = "anstyle-wincon"
version = "3.0.7" version = "3.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"once_cell", "once_cell_polyfill",
"windows-sys 0.59.0", "windows-sys 0.59.0",
] ]
@ -212,7 +212,7 @@ dependencies = [
"objc2", "objc2",
"objc2-app-kit", "objc2-app-kit",
"objc2-foundation", "objc2-foundation",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"percent-encoding", "percent-encoding",
"x11rb", "x11rb",
] ]
@ -302,7 +302,7 @@ checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c"
dependencies = [ dependencies = [
"async-channel 2.3.1", "async-channel 2.3.1",
"async-executor", "async-executor",
"async-io 2.4.0", "async-io 2.4.1",
"async-lock 3.4.0", "async-lock 3.4.0",
"blocking", "blocking",
"futures-lite 2.6.0", "futures-lite 2.6.0",
@ -331,9 +331,9 @@ dependencies = [
[[package]] [[package]]
name = "async-io" name = "async-io"
version = "2.4.0" version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" checksum = "1237c0ae75a0f3765f58910ff9cdd0a12eeb39ab2f4c7de23262f337f0aacbb3"
dependencies = [ dependencies = [
"async-lock 3.4.0", "async-lock 3.4.0",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -341,8 +341,8 @@ dependencies = [
"futures-io", "futures-io",
"futures-lite 2.6.0", "futures-lite 2.6.0",
"parking", "parking",
"polling 3.7.4", "polling 3.8.0",
"rustix 0.38.44", "rustix 1.0.7",
"slab", "slab",
"tracing", "tracing",
"windows-sys 0.59.0", "windows-sys 0.59.0",
@ -370,12 +370,12 @@ dependencies = [
[[package]] [[package]]
name = "async-process" name = "async-process"
version = "2.3.0" version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb" checksum = "cde3f4e40e6021d7acffc90095cbd6dc54cb593903d1de5832f435eb274b85dc"
dependencies = [ dependencies = [
"async-channel 2.3.1", "async-channel 2.3.1",
"async-io 2.4.0", "async-io 2.4.1",
"async-lock 3.4.0", "async-lock 3.4.0",
"async-signal", "async-signal",
"async-task", "async-task",
@ -383,23 +383,23 @@ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"event-listener 5.4.0", "event-listener 5.4.0",
"futures-lite 2.6.0", "futures-lite 2.6.0",
"rustix 0.38.44", "rustix 1.0.7",
"tracing", "tracing",
] ]
[[package]] [[package]]
name = "async-signal" name = "async-signal"
version = "0.2.10" version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" checksum = "d7605a4e50d4b06df3898d5a70bf5fde51ed9059b0434b73105193bc27acce0d"
dependencies = [ dependencies = [
"async-io 2.4.0", "async-io 2.4.1",
"async-lock 3.4.0", "async-lock 3.4.0",
"atomic-waker", "atomic-waker",
"cfg-if 1.0.0", "cfg-if 1.0.0",
"futures-core", "futures-core",
"futures-io", "futures-io",
"rustix 0.38.44", "rustix 1.0.7",
"signal-hook-registry", "signal-hook-registry",
"slab", "slab",
"windows-sys 0.59.0", "windows-sys 0.59.0",
@ -414,7 +414,7 @@ dependencies = [
"async-attributes", "async-attributes",
"async-channel 1.9.0", "async-channel 1.9.0",
"async-global-executor", "async-global-executor",
"async-io 2.4.0", "async-io 2.4.1",
"async-lock 3.4.0", "async-lock 3.4.0",
"async-process", "async-process",
"crossbeam-utils", "crossbeam-utils",
@ -445,7 +445,16 @@ dependencies = [
"futures-util", "futures-util",
"hickory-resolver", "hickory-resolver",
"pin-utils", "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]] [[package]]
@ -695,9 +704,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]] [[package]]
name = "base64ct" name = "base64ct"
version = "1.7.3" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89e25b6adfb930f02d1981565a6e5d9c547ac15a96606256d3b59040e5cd4ca3" checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba"
[[package]] [[package]]
name = "bindgen" name = "bindgen"
@ -864,9 +873,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
[[package]] [[package]]
name = "capnp" name = "capnp"
version = "0.21.0" version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d1b4a00e80b7c4b1a49e845365f25c9d8fd0a19c9cd8d66f68afea47b1f020" checksum = "64b3560604b407fe0ab6f89b81ac11887b4ae07f8d31486581dee5b353e48f06"
dependencies = [ dependencies = [
"embedded-io 0.6.1", "embedded-io 0.6.1",
] ]
@ -882,9 +891,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.23" version = "1.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766" checksum = "d0fc897dc1e865cc67c0e05a836d9d3f1df3cbe442aa4a9473b18e12624a4951"
dependencies = [ dependencies = [
"shlex", "shlex",
] ]
@ -1009,9 +1018,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.38" version = "4.5.39"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" checksum = "fd60e63e9be68e5fb56422e397cf9baddded06dae1d2e523401542383bc72a9f"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -1019,9 +1028,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.5.38" version = "4.5.39"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" checksum = "89cc6392a1f72bbeb820d71f32108f61fdaf18bc526e1d23954168a67759ef51"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -1074,9 +1083,9 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
[[package]] [[package]]
name = "color-eyre" name = "color-eyre"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e1761c0e16f8883bbbb8ce5990867f4f06bf11a0253da6495a04ce4b6ef0ec" checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"eyre", "eyre",
@ -1134,7 +1143,19 @@ dependencies = [
"nom 7.1.3", "nom 7.1.3",
"pathdiff", "pathdiff",
"serde", "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]] [[package]]
@ -1284,7 +1305,7 @@ dependencies = [
"crossterm_winapi", "crossterm_winapi",
"libc", "libc",
"mio 0.8.11", "mio 0.8.11",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"signal-hook", "signal-hook",
"signal-hook-mio", "signal-hook-mio",
"winapi", "winapi",
@ -1301,8 +1322,8 @@ dependencies = [
"derive_more", "derive_more",
"document-features", "document-features",
"futures-core", "futures-core",
"mio 1.0.3", "mio 1.0.4",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"rustix 1.0.7", "rustix 1.0.7",
"signal-hook", "signal-hook",
"signal-hook-mio", "signal-hook-mio",
@ -1416,7 +1437,7 @@ dependencies = [
"log", "log",
"num", "num",
"owning_ref", "owning_ref",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"serde_json", "serde_json",
"serde_yaml", "serde_yaml",
"time", "time",
@ -1551,7 +1572,7 @@ dependencies = [
"hashbrown 0.14.5", "hashbrown 0.14.5",
"lock_api", "lock_api",
"once_cell", "once_cell",
"parking_lot_core 0.9.10", "parking_lot_core 0.9.11",
] ]
[[package]] [[package]]
@ -2014,6 +2035,12 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]] [[package]]
name = "foreign-types" name = "foreign-types"
version = "0.3.2" version = "0.3.2"
@ -2298,7 +2325,7 @@ dependencies = [
"grpcio-sys", "grpcio-sys",
"libc", "libc",
"log", "log",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"protobuf", "protobuf",
] ]
@ -2391,6 +2418,9 @@ name = "hashbrown"
version = "0.15.3" version = "0.15.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3"
dependencies = [
"foldhash",
]
[[package]] [[package]]
name = "hashlink" name = "hashlink"
@ -2401,6 +2431,15 @@ dependencies = [
"hashbrown 0.14.5", "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]] [[package]]
name = "hdrhistogram" name = "hdrhistogram"
version = "7.5.4" version = "7.5.4"
@ -2461,9 +2500,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.4.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08"
[[package]] [[package]]
name = "hex" name = "hex"
@ -2507,7 +2546,7 @@ dependencies = [
"ipconfig", "ipconfig",
"lru-cache", "lru-cache",
"once_cell", "once_cell",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"rand", "rand",
"resolv-conf", "resolv-conf",
"smallvec", "smallvec",
@ -2556,6 +2595,17 @@ dependencies = [
"winapi", "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]] [[package]]
name = "http" name = "http"
version = "0.2.12" version = "0.2.12"
@ -2624,7 +2674,7 @@ dependencies = [
"httpdate", "httpdate",
"itoa", "itoa",
"pin-project-lite", "pin-project-lite",
"socket2 0.4.10", "socket2 0.5.10",
"tokio", "tokio",
"tower-service", "tower-service",
"tracing", "tracing",
@ -2895,7 +2945,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f"
dependencies = [ dependencies = [
"socket2 0.5.9", "socket2 0.5.10",
"widestring", "widestring",
"windows-sys 0.48.0", "windows-sys 0.48.0",
"winreg", "winreg",
@ -3029,7 +3079,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "462f214495626d3245889a431c608f6791a10623735593cccfc9cbf4c72a73f1" checksum = "462f214495626d3245889a431c608f6791a10623735593cccfc9cbf4c72a73f1"
dependencies = [ dependencies = [
"keyvaluedb", "keyvaluedb",
"parking_lot 0.12.3", "parking_lot 0.12.4",
] ]
[[package]] [[package]]
@ -3041,7 +3091,7 @@ dependencies = [
"hex", "hex",
"keyvaluedb", "keyvaluedb",
"log", "log",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"rusqlite", "rusqlite",
] ]
@ -3100,9 +3150,9 @@ dependencies = [
[[package]] [[package]]
name = "libloading" name = "libloading"
version = "0.8.7" version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a793df0d7afeac54f95b471d3af7f0d4fb975699f972341a4b76988d49cdf0c" checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"windows-targets 0.53.0", "windows-targets 0.53.0",
@ -3180,9 +3230,9 @@ checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.12" version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"scopeguard", "scopeguard",
@ -3314,14 +3364,14 @@ dependencies = [
[[package]] [[package]]
name = "mio" name = "mio"
version = "1.0.3" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
"wasi 0.11.0+wasi-snapshot-preview1", "wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -3394,7 +3444,7 @@ dependencies = [
"ndk-macro", "ndk-macro",
"ndk-sys 0.4.1+23.1.7779620", "ndk-sys 0.4.1+23.1.7779620",
"once_cell", "once_cell",
"parking_lot 0.12.3", "parking_lot 0.12.4",
] ]
[[package]] [[package]]
@ -3787,6 +3837,12 @@ version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "once_cell_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
[[package]] [[package]]
name = "opaque-debug" name = "opaque-debug"
version = "0.3.1" version = "0.3.1"
@ -3795,9 +3851,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.72" version = "0.10.73"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
dependencies = [ dependencies = [
"bitflags 2.9.1", "bitflags 2.9.1",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -3827,9 +3883,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.108" version = "0.9.109"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847" checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -4094,12 +4150,12 @@ dependencies = [
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.12.3" version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13"
dependencies = [ dependencies = [
"lock_api", "lock_api",
"parking_lot_core 0.9.10", "parking_lot_core 0.9.11",
] ]
[[package]] [[package]]
@ -4118,9 +4174,9 @@ dependencies = [
[[package]] [[package]]
name = "parking_lot_core" name = "parking_lot_core"
version = "0.9.10" version = "0.9.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"libc", "libc",
@ -4271,15 +4327,15 @@ dependencies = [
[[package]] [[package]]
name = "polling" name = "polling"
version = "3.7.4" version = "3.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" checksum = "b53a684391ad002dd6a596ceb6c74fd004fdce75f4be2e3f615068abbea5fd50"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"concurrent-queue", "concurrent-queue",
"hermit-abi 0.4.0", "hermit-abi 0.5.1",
"pin-project-lite", "pin-project-lite",
"rustix 0.38.44", "rustix 1.0.7",
"tracing", "tracing",
"windows-sys 0.59.0", "windows-sys 0.59.0",
] ]
@ -4712,7 +4768,7 @@ dependencies = [
"bitflags 2.9.1", "bitflags 2.9.1",
"fallible-iterator", "fallible-iterator",
"fallible-streaming-iterator", "fallible-streaming-iterator",
"hashlink", "hashlink 0.8.4",
"libsqlite3-sys", "libsqlite3-sys",
"smallvec", "smallvec",
] ]
@ -4811,9 +4867,9 @@ dependencies = [
[[package]] [[package]]
name = "rustversion" name = "rustversion"
version = "1.0.20" version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
[[package]] [[package]]
name = "rustyline-async" name = "rustyline-async"
@ -5169,7 +5225,7 @@ dependencies = [
"futures", "futures",
"lazy_static", "lazy_static",
"log", "log",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"serial_test_derive 2.0.0", "serial_test_derive 2.0.0",
] ]
@ -5182,7 +5238,7 @@ dependencies = [
"futures", "futures",
"log", "log",
"once_cell", "once_cell",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"scc", "scc",
"serial_test_derive 3.2.0", "serial_test_derive 3.2.0",
] ]
@ -5295,7 +5351,7 @@ checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd"
dependencies = [ dependencies = [
"libc", "libc",
"mio 0.8.11", "mio 0.8.11",
"mio 1.0.3", "mio 1.0.4",
"signal-hook", "signal-hook",
] ]
@ -5365,9 +5421,9 @@ dependencies = [
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.5.9" version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.52.0", "windows-sys 0.52.0",
@ -5561,7 +5617,7 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "662b54ef6f7b4e71f683dadc787bbb2d8e8ef2f91b682ebed3164a5a7abca905" checksum = "662b54ef6f7b4e71f683dadc787bbb2d8e8ef2f91b682ebed3164a5a7abca905"
dependencies = [ dependencies = [
"parking_lot 0.12.3", "parking_lot 0.12.4",
"pin-project 1.1.10", "pin-project 1.1.10",
] ]
@ -5685,18 +5741,18 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.45.0" version = "1.45.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes 1.10.1", "bytes 1.10.1",
"libc", "libc",
"mio 1.0.3", "mio 1.0.4",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
"socket2 0.5.9", "socket2 0.5.10",
"tokio-macros", "tokio-macros",
"tracing", "tracing",
"windows-sys 0.52.0", "windows-sys 0.52.0",
@ -6352,8 +6408,8 @@ dependencies = [
"async-tungstenite 0.23.0", "async-tungstenite 0.23.0",
"cfg-if 1.0.0", "cfg-if 1.0.0",
"chrono", "chrono",
"clap 4.5.38", "clap 4.5.39",
"config 0.13.4", "config 0.15.11",
"console", "console",
"crossbeam-channel", "crossbeam-channel",
"cursive", "cursive",
@ -6370,7 +6426,7 @@ dependencies = [
"log", "log",
"lru", "lru",
"owning_ref", "owning_ref",
"parking_lot 0.11.2", "parking_lot 0.12.4",
"rustyline-async", "rustyline-async",
"serde", "serde",
"serde_derive", "serde_derive",
@ -6438,7 +6494,7 @@ dependencies = [
"num-traits", "num-traits",
"once_cell", "once_cell",
"paranoid-android", "paranoid-android",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"paste", "paste",
"range-set-blaze", "range-set-blaze",
"reqwest", "reqwest",
@ -6497,6 +6553,20 @@ dependencies = [
"veilid-core", "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]] [[package]]
name = "veilid-flutter" name = "veilid-flutter"
version = "0.4.7" version = "0.4.7"
@ -6510,7 +6580,7 @@ dependencies = [
"data-encoding", "data-encoding",
"ffi-support", "ffi-support",
"futures-util", "futures-util",
"hostname", "hostname 0.3.1",
"jni", "jni",
"lazy_static", "lazy_static",
"libc-print", "libc-print",
@ -6519,7 +6589,7 @@ dependencies = [
"opentelemetry-semantic-conventions 0.12.0", "opentelemetry-semantic-conventions 0.12.0",
"oslog", "oslog",
"paranoid-android", "paranoid-android",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"serde", "serde",
"serde_json", "serde_json",
"tokio", "tokio",
@ -6559,7 +6629,7 @@ dependencies = [
name = "veilid-remote-api" name = "veilid-remote-api"
version = "0.4.7" version = "0.4.7"
dependencies = [ dependencies = [
"parking_lot 0.12.3", "parking_lot 0.12.4",
"schemars", "schemars",
"serde", "serde",
"serde_json", "serde_json",
@ -6577,7 +6647,7 @@ dependencies = [
"backtrace", "backtrace",
"cfg-if 1.0.0", "cfg-if 1.0.0",
"chrono", "chrono",
"clap 4.5.38", "clap 4.5.39",
"color-eyre", "color-eyre",
"config 0.14.1", "config 0.14.1",
"console-subscriber", "console-subscriber",
@ -6586,7 +6656,7 @@ dependencies = [
"directories", "directories",
"flume", "flume",
"futures-util", "futures-util",
"hostname", "hostname 0.4.1",
"json", "json",
"lazy_static", "lazy_static",
"nix 0.29.0", "nix 0.29.0",
@ -6594,7 +6664,7 @@ dependencies = [
"opentelemetry-otlp 0.16.0", "opentelemetry-otlp 0.16.0",
"opentelemetry-semantic-conventions 0.16.0", "opentelemetry-semantic-conventions 0.16.0",
"opentelemetry_sdk 0.23.0", "opentelemetry_sdk 0.23.0",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"rpassword", "rpassword",
"serde", "serde",
"serde_derive", "serde_derive",
@ -6636,7 +6706,7 @@ dependencies = [
"backtrace", "backtrace",
"cfg-if 1.0.0", "cfg-if 1.0.0",
"chrono", "chrono",
"clap 4.5.38", "clap 4.5.39",
"console_error_panic_hook", "console_error_panic_hook",
"ctrlc", "ctrlc",
"eyre", "eyre",
@ -6663,7 +6733,7 @@ dependencies = [
"once_cell", "once_cell",
"oslog", "oslog",
"paranoid-android", "paranoid-android",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"postcard", "postcard",
"rand", "rand",
"rand_chacha", "rand_chacha",
@ -6675,7 +6745,7 @@ dependencies = [
"serde_yaml_ng", "serde_yaml_ng",
"serial_test 2.0.0", "serial_test 2.0.0",
"simplelog", "simplelog",
"socket2 0.5.9", "socket2 0.5.10",
"static_assertions", "static_assertions",
"stop-token", "stop-token",
"thiserror 1.0.69", "thiserror 1.0.69",
@ -6720,8 +6790,8 @@ dependencies = [
"gloo-utils", "gloo-utils",
"js-sys", "js-sys",
"lazy_static", "lazy_static",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"send_wrapper 0.4.0", "send_wrapper 0.6.0",
"serde", "serde",
"serde-wasm-bindgen", "serde-wasm-bindgen",
"serde_bytes", "serde_bytes",
@ -6949,7 +7019,7 @@ checksum = "7aafc5e81e847f05d6770e074faf7b1cd4a5dec9a0e88eac5d55e20fdfebee9a"
dependencies = [ dependencies = [
"event-listener 5.4.0", "event-listener 5.4.0",
"futures-core", "futures-core",
"parking_lot 0.12.3", "parking_lot 0.12.4",
"pin-project-lite", "pin-project-lite",
"triomphe", "triomphe",
] ]
@ -7547,7 +7617,18 @@ checksum = "8902160c4e6f2fb145dbe9d6760a75e3c9522d8bf796ed7047c85919ac7115f8"
dependencies = [ dependencies = [
"arraydeque", "arraydeque",
"encoding_rs", "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]] [[package]]

View file

@ -3,6 +3,7 @@ members = [
"veilid-tools", "veilid-tools",
"veilid-core", "veilid-core",
"veilid-core/examples/basic", "veilid-core/examples/basic",
"veilid-core/examples/private_route",
"veilid-server", "veilid-server",
"veilid-cli", "veilid-cli",
"veilid-flutter/rust", "veilid-flutter/rust",

View file

@ -138,11 +138,12 @@ deps-linux:
# Make a cache image with downloaded and built dependencies # Make a cache image with downloaded and built dependencies
build-linux-cache: build-linux-cache:
FROM +deps-linux 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 --dir .cargo scripts Cargo.lock Cargo.toml .
COPY --keep-ts veilid-cli/Cargo.toml veilid-cli COPY --keep-ts veilid-cli/Cargo.toml veilid-cli
COPY --keep-ts veilid-core/Cargo.toml veilid-core 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/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-server/Cargo.toml veilid-server
COPY --keep-ts veilid-tools/Cargo.toml veilid-tools COPY --keep-ts veilid-tools/Cargo.toml veilid-tools
COPY --keep-ts veilid-remote-api/Cargo.toml veilid-remote-api COPY --keep-ts veilid-remote-api/Cargo.toml veilid-remote-api

View file

@ -1 +0,0 @@
.veilid

View file

@ -1,20 +1,24 @@
[package] [package]
name = "veilid-core-examples-basic" name = "veilid-core-examples-basic"
version = "0.1.0" version = "0.1.0"
# ---
description = "Example demonstrating a basic Veilid application"
resolver = "2"
repository.workspace = true repository.workspace = true
authors.workspace = true authors.workspace = true
license.workspace = true license.workspace = true
edition.workspace = true edition.workspace = true
rust-version.workspace = true rust-version.workspace = true
autobins = false
publish = false publish = false
[[bin]] [[example]]
name = "basic" name = "basic-example"
path = "./src/main.rs" path = "./src/main.rs"
[dependencies] [dependencies]
tokio = { version = "^1.43.0" } tokio = { version = "^1.43.0" }
veilid-core = { version = "0.4.7", path = "../../../veilid-core" } veilid-core = { path = "../../../veilid-core" }
[lints] [lints]
workspace = true workspace = true

View file

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

View file

@ -4,6 +4,7 @@ use veilid_core::{VeilidConfig, VeilidConfigProtectedStore, VeilidConfigTableSto
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
// Create a basic update callback to display Veilid's update events
let update_callback = Arc::new(move |update: VeilidUpdate| { let update_callback = Arc::new(move |update: VeilidUpdate| {
match update { match update {
AppMessage(msg) => { 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 { let config = VeilidConfig {
program_name: "Example Veilid".into(), program_name: "Example Veilid".into(),
namespace: "veilid-example".into(), namespace: "veilid-example".into(),
@ -31,16 +38,23 @@ async fn main() {
// IMPORTANT: don't do this in production // IMPORTANT: don't do this in production
// This avoids prompting for a password and is insecure // This avoids prompting for a password and is insecure
always_use_insecure_storage: true, always_use_insecure_storage: true,
directory: "./.veilid/protected_store".into(), directory: exe_dir
.join(".veilid/protected_store")
.to_string_lossy()
.to_string(),
..Default::default() ..Default::default()
}, },
table_store: VeilidConfigTableStore { table_store: VeilidConfigTableStore {
directory: "./.veilid/table_store".into(), directory: exe_dir
.join(".veilid/table_store")
.to_string_lossy()
.to_string(),
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()
}; };
// Startup Veilid node
let veilid = veilid_core::api_startup_config(update_callback, config) let veilid = veilid_core::api_startup_config(update_callback, config)
.await .await
.unwrap(); .unwrap();
@ -48,7 +62,10 @@ async fn main() {
"Node ID: {}", "Node ID: {}",
veilid.config().unwrap().get().network.routing_table.node_id veilid.config().unwrap().get().network.routing_table.node_id
); );
// Attach to the network
veilid.attach().await.unwrap(); veilid.attach().await.unwrap();
// Until CTRL+C is pressed, keep running // Until CTRL+C is pressed, keep running
tokio::signal::ctrl_c().await.unwrap(); tokio::signal::ctrl_c().await.unwrap();
veilid.shutdown().await; veilid.shutdown().await;

View file

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

View file

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

View file

@ -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<String>,
/// Turn debugging information on
#[arg(short, long, action = clap::ArgAction::Count)]
debug: u8,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
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<u8> = 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<R, F: Future<Output = VeilidAPIResult<R>>>(
f: impl Fn() -> F,
) -> VeilidAPIResult<R> {
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<Output = Result<T, Box<dyn std::error::Error>>>, T>(
update_callback: impl Fn(VeilidUpdate) + Send + Sync + 'static,
veilid_config: VeilidConfig,
scope: impl FnOnce(VeilidAPI) -> F + Send + Sync + 'a,
) -> Result<T, Box<dyn std::error::Error>> {
// 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<dyn std::error::Error>> {
// 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<u8>,
mut done_recv: tokio::sync::mpsc::Receiver<()>,
mut config: VeilidConfig,
) -> Result<(), Box<dyn std::error::Error>> {
// 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 => {}
}
}

View file

@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc");
impl RPCProcessor { impl RPCProcessor {
// Sends a high level app request and wait for response // Sends a high level app request and wait for response
// Can be sent via all methods including relays and routes // 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( pub async fn rpc_call_app_call(
&self, &self,
dest: Destination, dest: Destination,

View file

@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc");
impl RPCProcessor { impl RPCProcessor {
// Sends a high level app message // Sends a high level app message
// Can be sent via all methods including relays and routes // 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( pub async fn rpc_call_app_message(
&self, &self,
dest: Destination, dest: Destination,

View file

@ -3,7 +3,7 @@ use super::*;
impl_veilid_log_facility!("rpc"); impl_veilid_log_facility!("rpc");
impl RPCProcessor { 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<()> { pub(super) async fn process_cancel_tunnel_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> {
// Ignore if disabled // Ignore if disabled
#[cfg(feature = "unstable-tunnels")] #[cfg(feature = "unstable-tunnels")]

View file

@ -3,7 +3,7 @@ use super::*;
impl_veilid_log_facility!("rpc"); impl_veilid_log_facility!("rpc");
impl RPCProcessor { 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<()> { pub(super) async fn process_complete_tunnel_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> {
// Ignore if disabled // Ignore if disabled
#[cfg(feature = "unstable-tunnels")] #[cfg(feature = "unstable-tunnels")]

View file

@ -3,7 +3,7 @@ use super::*;
impl_veilid_log_facility!("rpc"); impl_veilid_log_facility!("rpc");
impl RPCProcessor { 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<()> { pub(super) async fn process_find_block_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> {
// Ignore if disabled // Ignore if disabled
#[cfg(feature = "unstable-blockstore")] #[cfg(feature = "unstable-blockstore")]

View file

@ -9,7 +9,7 @@ impl RPCProcessor {
/// Because this leaks information about the identity of the node itself, /// Because this leaks information about the identity of the node itself,
/// replying to this request received over a private route will leak /// replying to this request received over a private route will leak
/// the identity of the node and defeat the private route. /// 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( pub async fn rpc_call_find_node(
&self, &self,
dest: Destination, dest: Destination,

View file

@ -24,7 +24,7 @@ impl RPCProcessor {
ret.value.data.writer, ret.value.data.writer,
ret.peers.len, ret.peers.len,
ret.latency ret.latency
),err)] ),err(level=Level::DEBUG))]
pub async fn rpc_call_get_value( pub async fn rpc_call_get_value(
&self, &self,
dest: Destination, dest: Destination,

View file

@ -25,7 +25,7 @@ impl RPCProcessor {
instrument(level = "trace", target = "rpc", skip(self, last_descriptor), instrument(level = "trace", target = "rpc", skip(self, last_descriptor),
fields(ret.peers.len, fields(ret.peers.len,
ret.latency ret.latency
),err) ),err(level=Level::DEBUG))
] ]
pub async fn rpc_call_inspect_value( pub async fn rpc_call_inspect_value(
&self, &self,

View file

@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc");
impl RPCProcessor { impl RPCProcessor {
// Sends a unidirectional in-band return receipt // Sends a unidirectional in-band return receipt
// Can be sent via all methods including relays and routes // 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<D: AsRef<[u8]>>( pub async fn rpc_call_return_receipt<D: AsRef<[u8]>>(
&self, &self,
dest: Destination, dest: Destination,

View file

@ -26,7 +26,7 @@ impl RPCProcessor {
ret.value.data.writer, ret.value.data.writer,
ret.peers.len, ret.peers.len,
ret.latency ret.latency
), err)] ), err(level=Level::DEBUG))]
pub async fn rpc_call_set_value( pub async fn rpc_call_set_value(
&self, &self,
dest: Destination, dest: Destination,

View file

@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc");
impl RPCProcessor { impl RPCProcessor {
// Sends a unidirectional signal to a node // Sends a unidirectional signal to a node
// Can be sent via relays but not routes. For routed 'signal' like capabilities, use AppMessage. // 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( pub async fn rpc_call_signal(
&self, &self,
dest: Destination, dest: Destination,

View file

@ -3,7 +3,7 @@ use super::*;
impl_veilid_log_facility!("rpc"); impl_veilid_log_facility!("rpc");
impl RPCProcessor { 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<()> { pub(super) async fn process_start_tunnel_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> {
// Ignore if disabled // Ignore if disabled
#[cfg(feature = "unstable-tunnels")] #[cfg(feature = "unstable-tunnels")]

View file

@ -18,7 +18,7 @@ impl RPCProcessor {
// direct -> node status + sender info // direct -> node status + sender info
// safety -> node status // safety -> node status
// private -> nothing // 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( pub async fn rpc_call_status(
&self, &self,
dest: Destination, dest: Destination,

View file

@ -3,7 +3,7 @@ use super::*;
impl_veilid_log_facility!("rpc"); impl_veilid_log_facility!("rpc");
impl RPCProcessor { 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<()> { pub(super) async fn process_supply_block_q(&self, msg: RPCMessage) -> RPCNetworkResult<()> {
// Ignore if disabled // Ignore if disabled
#[cfg(feature = "unstable-blockstore")] #[cfg(feature = "unstable-blockstore")]

View file

@ -4,7 +4,7 @@ impl_veilid_log_facility!("rpc");
impl RPCProcessor { impl RPCProcessor {
// Can only be sent directly, not via relays or routes // 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( pub async fn rpc_call_validate_dial_info(
&self, &self,
peer: NodeRef, peer: NodeRef,

View file

@ -5,7 +5,7 @@ impl_veilid_log_facility!("rpc");
impl RPCProcessor { impl RPCProcessor {
// Sends a dht value change notification // Sends a dht value change notification
// Can be sent via all methods including relays and routes but never over a safety route // 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( pub async fn rpc_call_value_changed(
&self, &self,
dest: Destination, dest: Destination,

View file

@ -22,7 +22,7 @@ impl RPCProcessor {
fields(ret.expiration, fields(ret.expiration,
ret.latency, ret.latency,
ret.peers.len ret.peers.len
),err)] ),err(level=Level::DEBUG))]
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub async fn rpc_call_watch_value( pub async fn rpc_call_watch_value(
&self, &self,

View file

@ -6,7 +6,7 @@ import 'dart:async';
import 'package:async_tools/async_tools.dart'; import 'package:async_tools/async_tools.dart';
import 'package:veilid/veilid.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 { abstract class VeilidFixture {
Future<void> setUp(); Future<void> setUp();
@ -111,6 +111,8 @@ class DefaultVeilidFixture implements VeilidFixture {
_veilidUpdateSubscription = us.listen((update) { _veilidUpdateSubscription = us.listen((update) {
if (update is VeilidLog) { if (update is VeilidLog) {
// Tests should print logs
// ignore: avoid_print
print(update.message); print(update.message);
} else if (update is VeilidUpdateAttachment) { } else if (update is VeilidUpdateAttachment) {
} else if (update is VeilidUpdateConfig) { } else if (update is VeilidUpdateConfig) {