Merge branch 'doc-work' into 'main'

Rustdoc And Android Work

See merge request veilid/veilid!165
This commit is contained in:
Christien Rioux 2023-09-02 02:19:35 +00:00
commit 1d604477a8
No known key found for this signature in database
50 changed files with 794 additions and 457 deletions

341
Cargo.lock generated
View File

@ -4,9 +4,9 @@ version = 3
[[package]]
name = "addr2line"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3"
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
dependencies = [
"gimli",
]
@ -64,9 +64,9 @@ dependencies = [
[[package]]
name = "aho-corasick"
version = "1.0.4"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a"
checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783"
dependencies = [
"memchr",
]
@ -86,24 +86,6 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]]
name = "android-logd-logger"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d7b9303373a56714732e3371513edd14d12987d04ff4f48527444e804bc3ae"
dependencies = [
"bytes 1.4.0",
"env_logger 0.10.0",
"lazy_static",
"libc",
"log",
"parking_lot 0.12.1",
"redox_syscall 0.3.5",
"thiserror",
"time 0.3.25",
"winapi",
]
[[package]]
name = "android-tzdata"
version = "0.1.1"
@ -116,13 +98,31 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
[[package]]
name = "android_log-sys"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937"
[[package]]
name = "android_logger"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8619b80c242aa7bd638b5c7ddd952addeecb71f69c75e33f1d47b2804f8f883a"
dependencies = [
"android_log-sys",
"android_log-sys 0.2.0",
"env_logger 0.10.0",
"log",
"once_cell",
]
[[package]]
name = "android_logger"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f"
dependencies = [
"android_log-sys 0.3.1",
"env_logger 0.10.0",
"log",
"once_cell",
@ -158,24 +158,23 @@ dependencies = [
[[package]]
name = "anstream"
version = "0.3.2"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is-terminal",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd"
checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea"
[[package]]
name = "anstyle-parse"
@ -197,9 +196,9 @@ dependencies = [
[[package]]
name = "anstyle-wincon"
version = "1.0.2"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c"
checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd"
dependencies = [
"anstyle",
"windows-sys 0.48.0",
@ -213,9 +212,9 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "arboard"
version = "3.2.0"
version = "3.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854"
checksum = "ac57f2b058a76363e357c056e4f74f1945bf734d37b8b3ef49066c4787dde0fc"
dependencies = [
"clipboard-win",
"core-graphics",
@ -224,7 +223,6 @@ dependencies = [
"objc",
"objc-foundation",
"objc_id",
"once_cell",
"parking_lot 0.12.1",
"thiserror",
"winapi",
@ -610,9 +608,9 @@ dependencies = [
[[package]]
name = "backtrace"
version = "0.3.68"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12"
checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
dependencies = [
"addr2line",
"cc",
@ -637,9 +635,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "base64"
version = "0.21.2"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d"
checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53"
[[package]]
name = "base64ct"
@ -854,9 +852,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.82"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
@ -923,9 +921,9 @@ dependencies = [
[[package]]
name = "chrono"
version = "0.4.26"
version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5"
checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f"
dependencies = [
"android-tzdata",
"iana-time-zone",
@ -933,7 +931,7 @@ dependencies = [
"num-traits",
"time 0.1.45",
"wasm-bindgen",
"winapi",
"windows-targets 0.48.5",
]
[[package]]
@ -984,20 +982,19 @@ dependencies = [
[[package]]
name = "clap"
version = "4.3.23"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3"
checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6"
dependencies = [
"clap_builder",
"clap_derive",
"once_cell",
]
[[package]]
name = "clap_builder"
version = "4.3.23"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98"
checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08"
dependencies = [
"anstream",
"anstyle",
@ -1008,9 +1005,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "4.3.12"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050"
checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873"
dependencies = [
"heck",
"proc-macro2",
@ -1020,9 +1017,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.5.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"
[[package]]
name = "clipboard-win"
@ -1167,11 +1164,11 @@ checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
[[package]]
name = "core-foundation"
version = "0.6.4"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
dependencies = [
"core-foundation-sys 0.6.2",
"core-foundation-sys 0.7.0",
"libc",
]
@ -1187,9 +1184,9 @@ dependencies = [
[[package]]
name = "core-foundation-sys"
version = "0.6.2"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]]
name = "core-foundation-sys"
@ -1310,7 +1307,7 @@ version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a011bbe2c35ce9c1f143b7af6f94f29a167beb4cd1d29e6740ce836f723120e"
dependencies = [
"nix 0.26.2",
"nix 0.26.4",
"windows-sys 0.48.0",
]
@ -1343,7 +1340,7 @@ dependencies = [
"flexi_logger",
"lazy_static",
"log",
"time 0.3.25",
"time 0.3.28",
"unicode-width",
]
@ -1385,7 +1382,7 @@ dependencies = [
"owning_ref",
"serde_json",
"serde_yaml",
"time 0.3.25",
"time 0.3.28",
"tokio",
"toml 0.7.6",
"unicode-segmentation",
@ -1510,9 +1507,9 @@ dependencies = [
[[package]]
name = "dashmap"
version = "5.5.0"
version = "5.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6943ae99c34386c84a470c499d3414f66502a41340aa895406e0d2e4a207b91d"
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
dependencies = [
"cfg-if 1.0.0",
"hashbrown 0.14.0",
@ -1764,9 +1761,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f"
checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
dependencies = [
"errno-dragonfly",
"libc",
@ -1914,7 +1911,7 @@ dependencies = [
"regex",
"rustversion",
"thiserror",
"time 0.3.25",
"time 0.3.28",
]
[[package]]
@ -1967,12 +1964,12 @@ dependencies = [
[[package]]
name = "fs4"
version = "0.5.4"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cef5c93884e5cef757f63446122c2f420713c3e03f85540d09485b9415983b4a"
checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47"
dependencies = [
"libc",
"winapi",
"rustix 0.38.11",
"windows-sys 0.48.0",
]
[[package]]
@ -2159,9 +2156,9 @@ dependencies = [
[[package]]
name = "gimli"
version = "0.27.3"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e"
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]]
name = "glob"
@ -2226,9 +2223,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.3.20"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049"
checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833"
dependencies = [
"bytes 1.4.0",
"fnv",
@ -2296,9 +2293,9 @@ dependencies = [
[[package]]
name = "hashlink"
version = "0.8.3"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "312f66718a2d7789ffef4f4b7b213138ed9f1eb3aa1d0d82fc99f88fb3ffd26f"
checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7"
dependencies = [
"hashbrown 0.14.0",
]
@ -2639,17 +2636,6 @@ version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6"
[[package]]
name = "is-terminal"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi 0.3.2",
"rustix 0.38.8",
"windows-sys 0.48.0",
]
[[package]]
name = "itertools"
version = "0.10.5"
@ -2665,20 +2651,6 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "jni"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "039022cdf4d7b1cf548d31f60ae783138e5fd42013f6271049d7df7afadef96c"
dependencies = [
"cesu8",
"combine",
"jni-sys",
"log",
"thiserror",
"walkdir",
]
[[package]]
name = "jni"
version = "0.21.1"
@ -2735,13 +2707,13 @@ dependencies = [
[[package]]
name = "keychain-services"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fd01702fbd22eee99431f553959f86d558cfc1dbf7f98b8df159be14e29a349"
version = "0.1.2"
source = "git+https://github.com/iqlusioninc/keychain-services.rs.git?rev=7410fb8baf4ecdf04cdcd7d06d02658f4f158d77#7410fb8baf4ecdf04cdcd7d06d02658f4f158d77"
dependencies = [
"core-foundation 0.6.4",
"core-foundation 0.7.0",
"failure",
"failure_derive",
"zeroize",
]
[[package]]
@ -2752,9 +2724,9 @@ dependencies = [
"cfg-if 1.0.0",
"core-foundation 0.9.3",
"core-foundation-sys 0.8.4",
"directories 4.0.1",
"directories 5.0.1",
"fs4",
"jni 0.20.0",
"jni",
"keychain-services",
"lazy_static",
"log",
@ -2962,9 +2934,9 @@ checksum = "ed1202b2a6f884ae56f04cff409ab315c5ce26b5e58d7412e484f01fd52f52ef"
[[package]]
name = "memchr"
version = "2.5.0"
version = "2.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e"
[[package]]
name = "memoffset"
@ -3075,7 +3047,7 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f"
dependencies = [
"android_logger",
"android_logger 0.11.3",
"libc",
"log",
"ndk",
@ -3210,16 +3182,26 @@ dependencies = [
[[package]]
name = "nix"
version = "0.26.2"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a"
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
dependencies = [
"bitflags 1.3.2",
"cfg-if 1.0.0",
"libc",
"memoffset 0.7.1",
"pin-utils",
"static_assertions",
]
[[package]]
name = "nix"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
"bitflags 2.4.0",
"cfg-if 1.0.0",
"libc",
]
[[package]]
@ -3287,9 +3269,9 @@ dependencies = [
[[package]]
name = "num-bigint"
version = "0.4.3"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f"
checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0"
dependencies = [
"autocfg",
"num-integer",
@ -3418,9 +3400,9 @@ dependencies = [
[[package]]
name = "object"
version = "0.31.1"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1"
checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe"
dependencies = [
"memchr",
]
@ -3684,19 +3666,20 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
[[package]]
name = "pest"
version = "2.7.2"
version = "2.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a"
checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33"
dependencies = [
"memchr",
"thiserror",
"ucd-trie",
]
[[package]]
name = "pest_derive"
version = "2.7.2"
version = "2.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853"
checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a"
dependencies = [
"pest",
"pest_generator",
@ -3704,9 +3687,9 @@ dependencies = [
[[package]]
name = "pest_generator"
version = "2.7.2"
version = "2.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929"
checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141"
dependencies = [
"pest",
"pest_meta",
@ -3717,9 +3700,9 @@ dependencies = [
[[package]]
name = "pest_meta"
version = "2.7.2"
version = "2.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48"
checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f"
dependencies = [
"once_cell",
"pest",
@ -3728,12 +3711,12 @@ dependencies = [
[[package]]
name = "petgraph"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
dependencies = [
"fixedbitset",
"indexmap 1.9.3",
"indexmap 2.0.0",
]
[[package]]
@ -3788,9 +3771,9 @@ dependencies = [
[[package]]
name = "pin-project-lite"
version = "0.2.12"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pin-utils"
@ -3816,9 +3799,9 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
[[package]]
name = "platforms"
version = "3.0.2"
version = "3.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630"
checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8"
[[package]]
name = "png"
@ -4099,14 +4082,14 @@ dependencies = [
[[package]]
name = "regex"
version = "1.9.3"
version = "1.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"
checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata 0.3.6",
"regex-syntax 0.7.4",
"regex-automata 0.3.7",
"regex-syntax 0.7.5",
]
[[package]]
@ -4120,13 +4103,13 @@ dependencies = [
[[package]]
name = "regex-automata"
version = "0.3.6"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"
checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax 0.7.4",
"regex-syntax 0.7.5",
]
[[package]]
@ -4137,9 +4120,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
version = "0.7.4"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "resolv-conf"
@ -4203,7 +4186,7 @@ dependencies = [
"netlink-packet-utils",
"netlink-proto",
"netlink-sys",
"nix 0.26.2",
"nix 0.26.4",
"thiserror",
"tokio",
]
@ -4217,7 +4200,7 @@ dependencies = [
"bitflags 2.4.0",
"fallible-iterator",
"fallible-streaming-iterator",
"hashlink 0.8.3",
"hashlink 0.8.4",
"libsqlite3-sys",
"smallvec",
]
@ -4269,9 +4252,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.8"
version = "0.38.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f"
checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453"
dependencies = [
"bitflags 2.4.0",
"errno",
@ -4282,9 +4265,9 @@ dependencies = [
[[package]]
name = "rustls"
version = "0.20.8"
version = "0.20.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f"
checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99"
dependencies = [
"log",
"ring",
@ -4298,7 +4281,7 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2"
dependencies = [
"base64 0.21.2",
"base64 0.21.3",
]
[[package]]
@ -4324,9 +4307,9 @@ dependencies = [
[[package]]
name = "schemars"
version = "0.8.12"
version = "0.8.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f"
checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161"
dependencies = [
"dyn-clone",
"schemars_derive",
@ -4336,9 +4319,9 @@ dependencies = [
[[package]]
name = "schemars_derive"
version = "0.8.12"
version = "0.8.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c"
checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737"
dependencies = [
"proc-macro2",
"quote",
@ -4434,9 +4417,9 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.183"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
dependencies = [
"serde_derive",
]
@ -4462,9 +4445,9 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.183"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
dependencies = [
"proc-macro2",
"quote",
@ -4716,14 +4699,14 @@ checksum = "acee08041c5de3d5048c8b3f6f13fafb3026b24ba43c6a695a0c76179b844369"
dependencies = [
"log",
"termcolor",
"time 0.3.25",
"time 0.3.28",
]
[[package]]
name = "slab"
version = "0.4.8"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d"
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
dependencies = [
"autocfg",
]
@ -4900,7 +4883,7 @@ dependencies = [
"cfg-if 1.0.0",
"fastrand 2.0.0",
"redox_syscall 0.3.5",
"rustix 0.38.8",
"rustix 0.38.11",
"windows-sys 0.48.0",
]
@ -4986,9 +4969,9 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.25"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea"
checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48"
dependencies = [
"deranged",
"itoa",
@ -5007,9 +4990,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
[[package]]
name = "time-macros"
version = "0.2.11"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd"
checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572"
dependencies = [
"time-core",
]
@ -5179,7 +5162,7 @@ checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a"
dependencies = [
"async-trait",
"axum",
"base64 0.21.2",
"base64 0.21.3",
"bytes 1.4.0",
"futures-core",
"futures-util",
@ -5264,7 +5247,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e"
dependencies = [
"crossbeam-channel",
"time 0.3.25",
"time 0.3.28",
"tracing-subscriber",
]
@ -5570,9 +5553,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "url"
version = "2.4.0"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb"
checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5"
dependencies = [
"form_urlencoded",
"idna 0.4.0",
@ -5624,7 +5607,7 @@ dependencies = [
"async-tungstenite 0.8.0",
"bugsalot",
"cfg-if 1.0.0",
"clap 4.3.23",
"clap 4.4.2",
"config",
"crossbeam-channel",
"cursive",
@ -5689,7 +5672,7 @@ dependencies = [
"hex",
"ifstructs",
"igd",
"jni 0.21.1",
"jni",
"jni-sys",
"js-sys",
"json",
@ -5705,7 +5688,7 @@ dependencies = [
"ndk-glue",
"netlink-packet-route",
"netlink-sys",
"nix 0.26.2",
"nix 0.26.4",
"num-traits",
"once_cell",
"owning_ref",
@ -5767,7 +5750,7 @@ dependencies = [
"ffi-support",
"futures-util",
"hostname",
"jni 0.21.1",
"jni",
"lazy_static",
"opentelemetry",
"opentelemetry-otlp",
@ -5794,7 +5777,7 @@ dependencies = [
"backtrace",
"bugsalot",
"cfg-if 1.0.0",
"clap 4.3.23",
"clap 4.4.2",
"color-eyre",
"config",
"console-subscriber",
@ -5806,7 +5789,7 @@ dependencies = [
"hostname",
"json",
"lazy_static",
"nix 0.26.2",
"nix 0.27.1",
"opentelemetry",
"opentelemetry-otlp",
"opentelemetry-semantic-conventions",
@ -5838,7 +5821,7 @@ dependencies = [
name = "veilid-tools"
version = "0.1.10"
dependencies = [
"android-logd-logger",
"android_logger 0.13.3",
"async-lock",
"async-std",
"async_executors",
@ -5850,7 +5833,7 @@ dependencies = [
"flume",
"fn_name",
"futures-util",
"jni 0.21.1",
"jni",
"jni-sys",
"js-sys",
"lazy_static",
@ -5858,7 +5841,7 @@ dependencies = [
"log",
"ndk",
"ndk-glue",
"nix 0.26.2",
"nix 0.26.4",
"once_cell",
"oslog",
"paranoid-android",
@ -6085,9 +6068,9 @@ dependencies = [
[[package]]
name = "webpki"
version = "0.22.0"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e"
dependencies = [
"ring",
"untrusted",
@ -6383,9 +6366,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "winnow"
version = "0.5.14"
version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97"
checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc"
dependencies = [
"memchr",
]

3
build_docs.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
cargo doc --no-deps -p veilid-core
cargo doc --no-deps -p veilid-tools

View File

@ -123,13 +123,13 @@ if [ "$BREW_USER" == "" ]; then
BREW_USER=`whoami`
fi
fi
sudo -H -u $BREW_USER brew install capnp cmake wabt llvm protobuf openjdk@11 jq
sudo -H -u $BREW_USER brew install capnp cmake wabt llvm protobuf openjdk@17 jq
# Ensure android sdk packages are installed
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager build-tools\;33.0.1 ndk\;25.1.8937393 cmake\;3.22.1 platform-tools platforms\;android-33
# install targets
rustup target add aarch64-apple-darwin aarch64-apple-ios x86_64-apple-darwin x86_64-apple-ios wasm32-unknown-unknown aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
rustup target add aarch64-apple-darwin aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-darwin x86_64-apple-ios wasm32-unknown-unknown aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
# install cargo packages
cargo install wasm-bindgen-cli wasm-pack
@ -137,4 +137,5 @@ cargo install wasm-bindgen-cli wasm-pack
# install pip packages
pip3 install --upgrade bumpversion
echo Installing cocoapods. This may take a while.
sudo gem install cocoapods

@ -1 +1 @@
Subproject commit 290b15474663f38b351ac514f457948b05b782bb
Subproject commit e00be7d4130f3e3f69548121de26b24aeb935df2

View File

@ -13,10 +13,27 @@ AVD_NAME="testavd"
AVD_TAG="google_atd"
AVD_IMAGE="system-images;android-30;$AVD_TAG;$ANDROID_ABI"
AVD_DEVICE="Nexus 10"
SDKMANAGER=$ANDROID_SDK_ROOT/tools/bin/sdkmanager
AVDMANAGER=$ANDROID_SDK_ROOT/tools/bin/avdmanager
if ! command -v $SDKMANAGER; then
SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
AVDMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager
if ! command -v $SDKMANAGER; then
echo "Can't find 'sdkmanager' in the usual places."
exit
fi
fi
EMULATOR=$ANDROID_SDK_ROOT/emulator/emulator
if ! command -v $EMULATOR; then
echo "Can't find 'emulator' in the usual places."
exit
fi
# Install AVD image
$ANDROID_SDK_ROOT/tools/bin/sdkmanager --install "$AVD_IMAGE"
$SDKMANAGER --install "$AVD_IMAGE"
# Make AVD
echo "no" | $ANDROID_SDK_ROOT/tools/bin/avdmanager --verbose create avd --force --name "$AVD_NAME" --package "$AVD_IMAGE" --tag "$AVD_TAG" --abi "$ANDROID_ABI" --device "$AVD_DEVICE"
echo "no" | $AVDMANAGER --verbose create avd --force --name "$AVD_NAME" --package "$AVD_IMAGE" --tag "$AVD_TAG" --abi "$ANDROID_ABI" --device "$AVD_DEVICE"
# Run emulator
$ANDROID_SDK_ROOT/emulator/emulator -avd testavd -no-snapshot -no-boot-anim -no-window &
( trap exit SIGINT ; read -r -d '' _ </dev/tty ) ## wait for Ctrl-C

View File

@ -169,6 +169,8 @@ fn main() -> Result<(), String> {
} else if #[cfg(feature="rt-tokio")] {
// Wait for ui and connection to complete
let _ = tokio::join!(ui_future, connection_future);
} else {
compile_error!("needs executor implementation")
}
}
});

View File

@ -19,7 +19,8 @@ cfg_if! {
let local = tokio::task::LocalSet::new();
local.block_on(&rt, f)
}
} else {
compile_error!("needs executor implementation")
}
}

View File

@ -12,10 +12,15 @@ crate-type = ["cdylib", "staticlib", "rlib"]
[features]
# Common features
default = ["enable-crypto-vld0"]
default = ["enable-crypto-vld0", "rt-tokio"]
default-async-std = ["enable-crypto-vld0", "rt-async-std"]
default-wasm = ["enable-crypto-vld0"]
# Runtimes
rt-async-std = [
"async-std",
"async-std-resolver",
"trust-dns-resolver",
"async_executors/async_std",
"rtnetlink/smol_socket",
"veilid-tools/rt-async-std",
@ -31,7 +36,6 @@ rt-tokio = [
"rtnetlink/tokio_socket",
"veilid-tools/rt-tokio",
]
rt-wasm-bindgen = ["veilid-tools/rt-wasm-bindgen", "async_executors/bindgen"]
# Crypto support features
enable-crypto-vld0 = []
@ -52,7 +56,9 @@ network-result-extra = ["veilid-tools/network-result-extra"]
[dependencies]
# Tools
veilid-tools = { path = "../veilid-tools", features = ["tracing"] }
veilid-tools = { path = "../veilid-tools", features = [
"tracing",
], default-features = false }
paste = "1.0.14"
once_cell = "1.18.0"
owning_ref = "0.4.1"
@ -171,6 +177,10 @@ socket2 = { version = "0.5.3", features = ["all"] }
# Dependencies for WASM builds only
[target.'cfg(target_arch = "wasm32")'.dependencies]
veilid-tools = { path = "../veilid-tools", default-features = false, features = [
"rt-wasm-bindgen",
] }
# Tools
getrandom = { version = "0.2.4", features = ["js"] }

View File

@ -3,7 +3,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pushd $SCRIPTDIR 2>/dev/null
if [[ "$1" == "wasm" ]]; then
WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --firefox --headless --features=rt-wasm-bindgen
WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --firefox --headless --no-default-features --features=default-wasm
elif [[ "$1" == "ios" ]]; then
SYMROOT=/tmp/testout
APPNAME=veilidcore-tests
@ -59,7 +59,7 @@ elif [[ "$1" == "android" ]]; then
popd >/dev/null
else
cargo test --features=rt-tokio
cargo test --features=rt-async-std
cargo test
cargo test --no-default-features --features=default-async-std
fi
popd 2>/dev/null

View File

@ -1,4 +1,4 @@
@echo off
cargo test --features=rt-tokio -- --nocapture
cargo test -- --nocapture
cargo test --features=rt-async-std -- --nocapture

View File

@ -86,18 +86,18 @@ impl AttachmentManager {
self.unlocked_inner.network_manager.clone()
}
pub fn is_attached(&self) -> bool {
let s = self.inner.lock().last_attachment_state;
!matches!(s, AttachmentState::Detached | AttachmentState::Detaching)
}
pub fn is_detached(&self) -> bool {
let s = self.inner.lock().last_attachment_state;
matches!(s, AttachmentState::Detached)
}
// pub fn is_attached(&self) -> bool {
// let s = self.inner.lock().last_attachment_state;
// !matches!(s, AttachmentState::Detached | AttachmentState::Detaching)
// }
// pub fn is_detached(&self) -> bool {
// let s = self.inner.lock().last_attachment_state;
// matches!(s, AttachmentState::Detached)
// }
pub fn get_attach_timestamp(&self) -> Option<Timestamp> {
self.inner.lock().attach_ts
}
// pub fn get_attach_timestamp(&self) -> Option<Timestamp> {
// self.inner.lock().attach_ts
// }
fn translate_routing_table_health(
health: &RoutingTableHealth,
@ -321,9 +321,9 @@ impl AttachmentManager {
}
}
pub fn get_attachment_state(&self) -> AttachmentState {
self.inner.lock().last_attachment_state
}
// pub fn get_attachment_state(&self) -> AttachmentState {
// self.inner.lock().last_attachment_state
// }
fn get_veilid_state_inner(inner: &AttachmentManagerInner) -> VeilidStateAttachment {
VeilidStateAttachment {

View File

@ -290,6 +290,14 @@ lazy_static::lazy_static! {
static ref INITIALIZED: AsyncMutex<bool> = AsyncMutex::new(false);
}
/// Initialize a Veilid node.
///
/// Must be called only once at the start of an application
///
/// * `update_callback` - called when internal state of the Veilid node changes, for example, when app-level messages are received, when private routes die and need to be reallocated, or when routing table states change
/// * `config_callback` - called at startup to supply a configuration object directly to Veilid
///
/// Returns a [VeilidAPI] object that can be used to operate the node
#[instrument(err, skip_all)]
pub async fn api_startup(
update_callback: UpdateCallback,
@ -313,6 +321,14 @@ pub async fn api_startup(
Ok(veilid_api)
}
/// Initialize a Veilid node, with the configuration in JSON format
///
/// Must be called only once at the start of an application
///
/// * `update_callback` - called when internal state of the Veilid node changes, for example, when app-level messages are received, when private routes die and need to be reallocated, or when routing table states change
/// * `config_json` - called at startup to supply a JSON configuration object
///
/// Returns a [VeilidAPI] object that can be used to operate the node
#[instrument(err, skip_all)]
pub async fn api_startup_json(
update_callback: UpdateCallback,

View File

@ -7,6 +7,7 @@ mod types;
pub mod crypto_system;
#[cfg(feature = "enable-crypto-none")]
pub mod none;
#[doc(hidden)]
pub mod tests;
#[cfg(feature = "enable-crypto-vld0")]
pub mod vld0;
@ -14,7 +15,6 @@ pub mod vld0;
pub use blake3digest512::*;
pub use crypto_system::*;
pub use dh_cache::*;
pub use envelope::*;
pub use receipt::*;
pub use types::*;
@ -26,6 +26,7 @@ pub use vld0::*;
use super::*;
use core::convert::TryInto;
use dh_cache::*;
use hashlink::linked_hash_map::Entry;
use hashlink::LruCache;

View File

@ -1,13 +1,14 @@
use super::*;
use jni::errors::Result as JniResult;
use jni::objects::JString;
#[allow(dead_code)]
pub fn get_files_dir() -> String {
let aglock = ANDROID_GLOBALS.lock();
let ag = aglock.as_ref().unwrap();
let env = ag.vm.attach_current_thread().unwrap();
let mut env = ag.vm.attach_current_thread().unwrap();
with_null_local_frame(*env, 64, || {
env.with_local_frame(64, |env| {
// context.getFilesDir().getAbsolutePath()
let file = env
.call_method(ag.ctx.as_obj(), "getFilesDir", "()Ljava/io/File;", &[])
@ -20,8 +21,9 @@ pub fn get_files_dir() -> String {
.l()
.unwrap();
let jstrval = env.get_string(JString::from(path)).unwrap();
Ok(String::from(jstrval.to_string_lossy()))
let jstr = JString::from(path);
let jstrval = env.get_string(&jstr).unwrap();
JniResult::Ok(String::from(jstrval.to_string_lossy()))
})
.unwrap()
}
@ -30,9 +32,9 @@ pub fn get_files_dir() -> String {
pub fn get_cache_dir() -> String {
let aglock = ANDROID_GLOBALS.lock();
let ag = aglock.as_ref().unwrap();
let env = ag.vm.attach_current_thread().unwrap();
let mut env = ag.vm.attach_current_thread().unwrap();
with_null_local_frame(*env, 64, || {
env.with_local_frame(64, |env| {
// context.getCacheDir().getAbsolutePath()
let file = env
.call_method(ag.ctx.as_obj(), "getCacheDir", "()Ljava/io/File;", &[])
@ -45,8 +47,9 @@ pub fn get_cache_dir() -> String {
.l()
.unwrap();
let jstrval = env.get_string(JString::from(path)).unwrap();
Ok(String::from(jstrval.to_string_lossy()))
let jstr = JString::from(path);
let jstrval = env.get_string(&jstr).unwrap();
JniResult::Ok(String::from(jstrval.to_string_lossy()))
})
.unwrap()
}

View File

@ -2,7 +2,6 @@ mod get_directories;
pub use get_directories::*;
use crate::*;
use jni::errors::Result as JniResult;
use jni::{objects::GlobalRef, objects::JObject, JNIEnv, JavaVM};
use lazy_static::*;
@ -41,13 +40,3 @@ pub fn get_android_globals() -> (JavaVM, GlobalRef) {
let ctx = globals.ctx.clone();
(vm, ctx)
}
pub fn with_null_local_frame<'b, T, F>(env: JNIEnv<'b>, s: i32, f: F) -> JniResult<T>
where
F: FnOnce() -> JniResult<T>,
{
env.push_local_frame(s)?;
let out = f();
env.pop_local_frame(JObject::null())?;
out
}

View File

@ -17,6 +17,8 @@ cfg_if! {
use netlink_sys::{SmolSocket as RTNetLinkSocket};
} else if #[cfg(feature="rt-tokio")] {
use netlink_sys::{TokioSocket as RTNetLinkSocket};
} else {
compile_error!("needs executor implementation")
}
}
use std::convert::TryInto;

View File

@ -18,6 +18,7 @@ cfg_if! {
cfg_if! {
if #[cfg(feature="rt-async-std")] {
use async_std_resolver::{config, resolver, resolver_from_system_conf, AsyncStdResolver as AsyncResolver};
use trust_dns_resolver::error::ResolveErrorKind;
} else if #[cfg(feature="rt-tokio")] {
use trust_dns_resolver::{config, TokioAsyncResolver as AsyncResolver, error::ResolveError, error::ResolveErrorKind};
@ -35,6 +36,8 @@ cfg_if! {
pub async fn resolver_from_system_conf() -> Result<AsyncResolver, ResolveError> {
AsyncResolver::tokio_from_system_conf()
}
} else {
compile_error!("needs executor implementation")
}
}

View File

@ -1,3 +1,26 @@
//! # The Veilid Framework
//!
//! Core library used to create a Veilid node and operate it as part of an application.
//!
//! `veilid-core` contains all of the core logic for Veilid and can be used in mobile applications as well as desktop
//! and in-browser WebAssembly apps.
//!
//! The public API is accessed by getting a [VeilidAPI] object via a call to [api_startup] or [api_startup_json].
//!
//! From there, a [RoutingContext] object can get you access to public and private routed operations.
//!
//! ## Features
//!
//! The default `veilid-core` configurations are:
//!
//! * `default` - Uses `tokio` as the async runtime
//!
//! If you use `--no-default-features`, you can switch to other runtimes:
//!
//! * `default-async-std` - Uses `async-std` as the async runtime
//! * `default-wasm` - When building for the `wasm32` architecture, use this to enable `wasm-bindgen-futures` as the async runtime
//!
#![deny(clippy::all)]
#![deny(unused_must_use)]
#![recursion_limit = "256"]
@ -41,15 +64,20 @@ pub use self::veilid_config::*;
pub use self::veilid_layer_filter::*;
pub use veilid_tools as tools;
/// The on-the-wire serialization format for Veilid RPC
pub mod veilid_capnp {
include!(concat!(env!("OUT_DIR"), "/proto/veilid_capnp.rs"));
}
#[doc(hidden)]
pub mod tests;
/// Return the cargo package version of veilid-core in string format
pub fn veilid_version_string() -> String {
env!("CARGO_PKG_VERSION").to_owned()
}
/// Return the cargo package version of veilid-core in tuple format
pub fn veilid_version() -> (u32, u32, u32) {
(
u32::from_str(env!("CARGO_PKG_VERSION_MAJOR")).unwrap(),
@ -90,6 +118,7 @@ pub static DEFAULT_LOG_IGNORE_LIST: [&str; 23] = [
use cfg_if::*;
use enumset::*;
use eyre::{bail, eyre, Report as EyreReport, Result as EyreResult, WrapErr};
#[allow(unused_imports)]
use futures_util::stream::{FuturesOrdered, FuturesUnordered};
use parking_lot::*;
use schemars::{schema_for, JsonSchema};

View File

@ -16,6 +16,7 @@ mod stats;
mod tasks;
mod types;
#[doc(hidden)]
pub mod tests;
////////////////////////////////////////////////////////////////////////////////////////

View File

@ -489,14 +489,12 @@ impl DiscoveryContext {
#[instrument(level = "trace", skip(self), ret, err)]
pub async fn protocol_process_nat(&self) -> EyreResult<bool> {
// Get the external dial info for our use here
let (node_1, external_1_dial_info, external_1_address, protocol_type, address_type) = {
let (node_1, external_1_dial_info, protocol_type) = {
let inner = self.inner.lock();
(
inner.node_1.as_ref().unwrap().clone(),
inner.external_1_dial_info.as_ref().unwrap().clone(),
inner.external_1_address.unwrap(),
inner.protocol_type.unwrap(),
inner.address_type.unwrap(),
)
};
@ -595,13 +593,10 @@ impl DiscoveryContext {
// We are restricted, determine what kind of restriction
// Get the external dial info for our use here
let (node_1, external_1_dial_info, external_1_address, protocol_type, address_type) = {
let (external_1_address, address_type) = {
let inner = self.inner.lock();
(
inner.node_1.as_ref().unwrap().clone(),
inner.external_1_dial_info.as_ref().unwrap().clone(),
inner.external_1_address.unwrap(),
inner.protocol_type.unwrap(),
inner.address_type.unwrap(),
)
};

View File

@ -132,6 +132,30 @@ impl Network {
}
};
#[cfg(all(feature = "rt-async-std", unix))]
{
// async-std does not directly support linger on tcpsocket yet
use std::os::fd::AsRawFd;
use std::os::fd::FromRawFd;
if let Err(e) = unsafe { socket2::Socket::from_raw_fd(tcp_stream.as_raw_fd()) }
.set_linger(Some(core::time::Duration::from_secs(0)))
{
log_net!(debug "Couldn't set TCP linger: {}", e);
return;
}
}
#[cfg(all(feature = "rt-async-std", windows))]
{
// async-std does not directly support linger on tcpsocket yet
use std::os::windows::io::AsRawSocket;
if let Err(e) = unsafe { socket2::socket_from_raw(tcp_stream.as_raw_socket()) }
.set_linger(Some(core::time::Duration::from_secs(0)))
{
log_net!(debug "Couldn't set TCP linger: {}", e);
return;
}
}
#[cfg(not(feature = "rt-async-std"))]
if let Err(e) = tcp_stream.set_linger(Some(core::time::Duration::from_secs(0))) {
log_net!(debug "Couldn't set TCP linger: {}", e);
return;
@ -240,6 +264,8 @@ impl Network {
} else if #[cfg(feature="rt-tokio")] {
std_listener.set_nonblocking(true).expect("failed to set nonblocking");
let listener = TcpListener::from_std(std_listener).wrap_err("failed to create tokio tcp listener")?;
} else {
compile_error!("needs executor implementation")
}
}
@ -267,6 +293,8 @@ impl Network {
let incoming_stream = listener.incoming();
} else if #[cfg(feature="rt-tokio")] {
let incoming_stream = tokio_stream::wrappers::TcpListenerStream::new(listener);
} else {
compile_error!("needs executor implementation")
}
}

View File

@ -136,6 +136,8 @@ impl Network {
} else if #[cfg(feature="rt-tokio")] {
std_udp_socket.set_nonblocking(true).expect("failed to set nonblocking");
let udp_socket = UdpSocket::from_std(std_udp_socket).wrap_err("failed to make outbound v4 tokio udpsocket")?;
} else {
compile_error!("needs executor implementation")
}
}
let socket_arc = Arc::new(udp_socket);
@ -160,6 +162,8 @@ impl Network {
} else if #[cfg(feature="rt-tokio")] {
std_udp_socket.set_nonblocking(true).expect("failed to set nonblocking");
let udp_socket = UdpSocket::from_std(std_udp_socket).wrap_err("failed to make outbound v6 tokio udpsocket")?;
} else {
compile_error!("needs executor implementation")
}
}
let socket_arc = Arc::new(udp_socket);
@ -190,6 +194,8 @@ impl Network {
} else if #[cfg(feature="rt-tokio")] {
std_udp_socket.set_nonblocking(true).expect("failed to set nonblocking");
let udp_socket = UdpSocket::from_std(std_udp_socket).wrap_err("failed to make inbound tokio udpsocket")?;
} else {
compile_error!("needs executor implementation")
}
}
let socket_arc = Arc::new(udp_socket);

View File

@ -8,6 +8,8 @@ cfg_if! {
} else if #[cfg(feature="rt-tokio")] {
pub use tokio::net::{TcpStream, TcpListener, UdpSocket};
pub use tokio_util::compat::*;
} else {
compile_error!("needs executor implementation")
}
}
@ -224,6 +226,8 @@ pub async fn nonblocking_connect(
Ok(TimeoutOr::value(TcpStream::from(async_stream.into_inner()?)))
} else if #[cfg(feature="rt-tokio")] {
Ok(TimeoutOr::value(TcpStream::from_std(async_stream.into_inner()?)?))
} else {
compile_error!("needs executor implementation")
}
}
}

View File

@ -36,7 +36,9 @@ impl RawTcpNetworkConnection {
// self.tcp_stream.get_mut()
// .shutdown()
// .await
// }
// } else {
// compile_error!("needs executor implementation")
// }
// }
// }

View File

@ -14,6 +14,8 @@ cfg_if! {
pub type WebsocketNetworkConnectionWSS =
WebsocketNetworkConnection<async_tls::client::TlsStream<Compat<TcpStream>>>;
pub type WebsocketNetworkConnectionWS = WebsocketNetworkConnection<Compat<TcpStream>>;
} else {
compile_error!("needs executor implementation")
}
}

View File

@ -50,9 +50,9 @@ impl RoutedOperation {
&self.data
}
pub fn destructure(self) -> (Sequencing, Vec<Signature>, Nonce, Vec<u8>) {
(self.sequencing, self.signatures, self.nonce, self.data)
}
// pub fn destructure(self) -> (Sequencing, Vec<Signature>, Nonce, Vec<u8>) {
// (self.sequencing, self.signatures, self.nonce, self.data)
// }
pub fn decode(reader: &veilid_capnp::routed_operation::Reader) -> Result<Self, RPCError> {
let sigs_reader = reader.get_signatures().map_err(RPCError::protocol)?;
@ -125,9 +125,9 @@ impl RPCOperationRoute {
pub fn safety_route(&self) -> &SafetyRoute {
&self.safety_route
}
pub fn operation(&self) -> &RoutedOperation {
&self.operation
}
// pub fn operation(&self) -> &RoutedOperation {
// &self.operation
// }
pub fn destructure(self) -> (SafetyRoute, RoutedOperation) {
(self.safety_route, self.operation)
}

View File

@ -164,7 +164,7 @@ impl TableStore {
self.flush().await;
}
pub fn maybe_unprotect_device_encryption_key(
pub(crate) fn maybe_unprotect_device_encryption_key(
&self,
dek_bytes: &[u8],
device_encryption_key_password: &str,
@ -218,7 +218,7 @@ impl TableStore {
))
}
pub fn maybe_protect_device_encryption_key(
pub(crate) fn maybe_protect_device_encryption_key(
&self,
dek: TypedSharedSecret,
device_encryption_key_password: &str,

View File

@ -167,7 +167,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "../../../../../scripts/ios_build.sh veilid_core --features veilid_core_ios_tests,rt-tokio\n";
shellScript = "../../../../../scripts/ios_build.sh veilid_core --features veilid_core_ios_tests\n";
};
/* End PBXShellScriptBuildPhase section */
@ -332,7 +332,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = ZJPQSFX5MW;
DEVELOPMENT_TEAM = XP5LBLT7M7;
INFOPLIST_FILE = "veilidcore-tests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.3;
LD_RUNPATH_SEARCH_PATHS = (
@ -364,7 +364,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = ZJPQSFX5MW;
DEVELOPMENT_TEAM = XP5LBLT7M7;
INFOPLIST_FILE = "veilidcore-tests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.3;
LD_RUNPATH_SEARCH_PATHS = (

View File

@ -41,17 +41,21 @@ pub async fn run_all_tests() {
info!("Finished unit tests");
}
#[allow(dead_code)]
#[cfg(feature = "rt-tokio")]
pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(f)
}
#[cfg(feature = "rt-async-std")]
#[allow(dead_code)]
pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
async_std::task::block_on(f)
cfg_if::cfg_if! {
if #[cfg(feature = "rt-async-std")] {
#[allow(dead_code)]
pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
async_std::task::block_on(f)
}
} else if #[cfg(feature = "rt-tokio")] {
#[allow(dead_code)]
pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(f)
}
} else {
compile_error!("needs executor implementation")
}
}
///////////////////////////////////////////////////////////////////////////

View File

@ -20,6 +20,19 @@ impl Drop for VeilidAPIInner {
}
}
/// The primary developer entrypoint into `veilid-core` functionality
///
/// From [VeilidAPI] one can access:
///
/// * [VeilidConfig] - The Veilid configuration specified by at startup time
/// * [Crypto] - The available set of cryptosystems provided by Veilid
/// * [TableStore] - The Veilid table-based encrypted persistent key-value store
/// * [ProtectedStore] - The Veilid abstract of the device's low-level 'protected secret storage'
/// * [VeilidState] - The current state of the Veilid node this API accesses
/// * [RoutingContext] - Communication methods between Veilid nodes and private routes
/// * Attach and detach from the network
/// * Create and import private routes
/// * Reply to `AppCall` RPCs
#[derive(Clone, Debug)]
pub struct VeilidAPI {
inner: Arc<Mutex<VeilidAPIInner>>,
@ -35,6 +48,7 @@ impl VeilidAPI {
}
}
/// Shut down Veilid and terminate the API
#[instrument(skip_all)]
pub async fn shutdown(self) {
let context = { self.inner.lock().context.take() };
@ -43,12 +57,15 @@ impl VeilidAPI {
}
}
/// Check to see if Veilid is already shut down
pub fn is_shutdown(&self) -> bool {
self.inner.lock().context.is_none()
}
////////////////////////////////////////////////////////////////
// Accessors
// Public Accessors
/// Access the configuration that Veilid was initialized with
pub fn config(&self) -> VeilidAPIResult<VeilidConfig> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
@ -56,6 +73,8 @@ impl VeilidAPI {
}
Err(VeilidAPIError::NotInitialized)
}
/// Get the cryptosystem manager
pub fn crypto(&self) -> VeilidAPIResult<Crypto> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
@ -63,6 +82,8 @@ impl VeilidAPI {
}
Err(VeilidAPIError::NotInitialized)
}
/// Get the TableStore manager
pub fn table_store(&self) -> VeilidAPIResult<TableStore> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
@ -70,14 +91,8 @@ impl VeilidAPI {
}
Err(VeilidAPIError::not_initialized())
}
#[cfg(feature = "unstable-blockstore")]
pub fn block_store(&self) -> VeilidAPIResult<BlockStore> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
return Ok(context.block_store.clone());
}
Err(VeilidAPIError::not_initialized())
}
/// Get the ProtectedStore manager
pub fn protected_store(&self) -> VeilidAPIResult<ProtectedStore> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
@ -85,46 +100,57 @@ impl VeilidAPI {
}
Err(VeilidAPIError::not_initialized())
}
pub fn attachment_manager(&self) -> VeilidAPIResult<AttachmentManager> {
////////////////////////////////////////////////////////////////
// Internal Accessors
pub(crate) fn attachment_manager(&self) -> VeilidAPIResult<AttachmentManager> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
return Ok(context.attachment_manager.clone());
}
Err(VeilidAPIError::not_initialized())
}
pub fn network_manager(&self) -> VeilidAPIResult<NetworkManager> {
pub(crate) fn network_manager(&self) -> VeilidAPIResult<NetworkManager> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
return Ok(context.attachment_manager.network_manager());
}
Err(VeilidAPIError::not_initialized())
}
pub fn rpc_processor(&self) -> VeilidAPIResult<RPCProcessor> {
pub(crate) fn rpc_processor(&self) -> VeilidAPIResult<RPCProcessor> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
return Ok(context.attachment_manager.network_manager().rpc_processor());
}
Err(VeilidAPIError::NotInitialized)
}
pub fn routing_table(&self) -> VeilidAPIResult<RoutingTable> {
pub(crate) fn routing_table(&self) -> VeilidAPIResult<RoutingTable> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
return Ok(context.attachment_manager.network_manager().routing_table());
}
Err(VeilidAPIError::NotInitialized)
}
pub fn storage_manager(&self) -> VeilidAPIResult<StorageManager> {
pub(crate) fn storage_manager(&self) -> VeilidAPIResult<StorageManager> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
return Ok(context.storage_manager.clone());
}
Err(VeilidAPIError::NotInitialized)
}
#[cfg(feature = "unstable-blockstore")]
pub(crate) fn block_store(&self) -> VeilidAPIResult<BlockStore> {
let inner = self.inner.lock();
if let Some(context) = &inner.context {
return Ok(context.block_store.clone());
}
Err(VeilidAPIError::not_initialized())
}
////////////////////////////////////////////////////////////////
// Attach/Detach
/// Get a full copy of the current state
/// Get a full copy of the current state of Veilid
pub async fn get_state(&self) -> VeilidAPIResult<VeilidState> {
let attachment_manager = self.attachment_manager()?;
let network_manager = attachment_manager.network_manager();
@ -162,16 +188,47 @@ impl VeilidAPI {
////////////////////////////////////////////////////////////////
// Routing Context
/// Get a new `RoutingContext` object to use to send messages over the Veilid network.
pub fn routing_context(&self) -> RoutingContext {
RoutingContext::new(self.clone())
}
/// Parse a string into a target object that can be used in a [RoutingContext]
///
/// Strings are in base64url format and can either be a remote route id or a node id.
/// Strings may have a [CryptoKind] [FourCC] prefix separated by a colon, such as:
/// `VLD0:XmnGyJrjMJBRC5ayJZRPXWTBspdX36-pbLb98H3UMeE` but if the prefix is left off
/// `XmnGyJrjMJBRC5ayJZRPXWTBspdX36-pbLb98H3UMeE` will be parsed with the 'best' cryptosystem
/// available (at the time of this writing this is `VLD0`)
pub async fn parse_as_target<S: AsRef<str>>(&self, s: S) -> VeilidAPIResult<Target> {
// Is this a route id?
if let Ok(rrid) = RouteId::from_str(s.as_ref()) {
let routing_table = self.routing_table()?;
let rss = routing_table.route_spec_store();
// Is this a valid remote route id? (can't target allocated routes)
if rss.is_route_id_remote(&rrid) {
return Ok(Target::PrivateRoute(rrid));
}
}
// Is this a node id?
if let Ok(nid) = TypedKey::from_str(s.as_ref()) {
return Ok(Target::NodeId(nid));
}
Err(VeilidAPIError::invalid_target())
}
////////////////////////////////////////////////////////////////
// Private route allocation
/// Allocate a new private route set with default cryptography and network options
/// Returns a route id and a publishable 'blob' with the route encrypted with each crypto kind
/// Those nodes importing the blob will have their choice of which crypto kind to use
///
/// Returns a route id and 'blob' that can be published over some means (DHT or otherwise) to be
/// imported by another Veilid node.
pub async fn new_private_route(&self) -> VeilidAPIResult<(RouteId, Vec<u8>)> {
self.new_custom_private_route(
&VALID_CRYPTO_KINDS,
@ -181,7 +238,12 @@ impl VeilidAPI {
.await
}
/// Allocate a new private route and specify a specific cryptosystem, stability and sequencing preference
/// Returns a route id and a publishable 'blob' with the route encrypted with each crypto kind
/// Those nodes importing the blob will have their choice of which crypto kind to use
///
/// Returns a route id and 'blob' that can be published over some means (DHT or otherwise) to be
/// imported by another Veilid node.
pub async fn new_custom_private_route(
&self,
crypto_kinds: &[CryptoKind],
@ -237,12 +299,19 @@ impl VeilidAPI {
Ok((route_id, blob))
}
/// Import a private route blob as a remote private route.
///
/// Returns a route id that can be used to send private messages to the node creating this route.
pub fn import_remote_private_route(&self, blob: Vec<u8>) -> VeilidAPIResult<RouteId> {
let rss = self.routing_table()?.route_spec_store();
rss.import_remote_private_route(blob)
.map_err(|e| VeilidAPIError::invalid_argument(e, "blob", "private route blob"))
}
/// Release either a locally allocated or remotely imported private route
///
/// This will deactivate the route and free its resources and it can no longer be sent to
/// or received from.
pub fn release_private_route(&self, route_id: RouteId) -> VeilidAPIResult<()> {
let rss = self.routing_table()?.route_spec_store();
if !rss.release_route(route_id) {
@ -254,6 +323,10 @@ impl VeilidAPI {
////////////////////////////////////////////////////////////////
// App Calls
/// Respond to an AppCall received over a [VeilidUpdate::AppCall].
///
/// * `call_id` - specifies which call to reply to, and it comes from a [VeilidUpdate::AppCall], specifically the [VeilidAppCall::id()] value.
/// * `message` - is an answer blob to be returned by the remote node's [RoutingContext::app_call()] function, and may be up to 32768 bytes
pub async fn app_call_reply(
&self,
call_id: OperationId,

View File

@ -1363,6 +1363,7 @@ impl VeilidAPI {
}
}
/// Get the help text for 'internal debug' commands
pub async fn debug_help(&self, _args: String) -> VeilidAPIResult<String> {
Ok(r#"buckets [dead|reliable]
dialinfo
@ -1425,6 +1426,7 @@ record list <local|remote>
.to_owned())
}
/// Execute an 'internal debug command'
pub async fn debug(&self, args: String) -> VeilidAPIResult<String> {
let res = {
let args = args.trim_start();

View File

@ -8,6 +8,7 @@ mod serialize_helpers;
mod types;
pub mod json_api;
#[doc(hidden)]
pub mod tests;
pub use api::*;
@ -18,19 +19,19 @@ pub use serialize_helpers::*;
pub use types::*;
pub use alloc::string::ToString;
pub use attachment_manager::AttachmentManager;
pub use core::str::FromStr;
pub use crypto::*;
#[cfg(feature = "unstable-blockstore")]
pub use intf::BlockStore;
pub use intf::ProtectedStore;
pub use network_manager::NetworkManager;
pub use routing_table::{NodeRef, NodeRefBase};
pub use table_store::{TableDB, TableDBTransaction, TableStore};
use crate::*;
use attachment_manager::AttachmentManager;
use core::fmt;
use core_context::{api_shutdown, VeilidCoreContext};
use network_manager::NetworkManager;
use routing_table::{Direction, RouteSpecStore, RoutingTable};
use rpc_processor::*;
use storage_manager::StorageManager;

View File

@ -2,10 +2,13 @@ use super::*;
///////////////////////////////////////////////////////////////////////////////////////
/// Valid destinations for a message sent over a routing context
#[derive(Clone, Debug)]
pub enum Target {
NodeId(TypedKey), // Node by its public key
PrivateRoute(RouteId), // Remote private route by its id
/// Node by its public key
NodeId(TypedKey),
/// Remote private route by its id
PrivateRoute(RouteId),
}
pub struct RoutingContextInner {}
@ -24,6 +27,12 @@ impl Drop for RoutingContextInner {
}
}
/// Routing contexts are the way you specify the communication preferences for Veilid.
///
/// By default routing contexts are 'direct' from node to node, offering no privacy. To enable sender
/// privacy, use [RoutingContext::with_privacy()]. To enable receiver privacy, you should send to a private route RouteId that you have
/// imported, rather than directly to a NodeId.
///
#[derive(Clone)]
pub struct RoutingContext {
/// Veilid API handle
@ -45,6 +54,15 @@ impl RoutingContext {
}
}
/// Turn on sender privacy, enabling the use of safety routes.
///
/// Default values for hop count, stability and sequencing preferences are used.
///
/// * Hop count default is dependent on config, but is set to 1 extra hop.
/// * Stability default is to choose 'low latency' routes, preferring them over long-term reliability.
/// * Sequencing default is to have no preference for ordered vs unordered message delivery
///
/// To modify these defaults, use [RoutingContext::with_custom_privacy()].
pub fn with_privacy(self) -> VeilidAPIResult<Self> {
let config = self.api.config()?;
let c = config.get();
@ -57,6 +75,7 @@ impl RoutingContext {
}))
}
/// Turn on privacy using a custom [SafetySelection]
pub fn with_custom_privacy(self, safety_selection: SafetySelection) -> VeilidAPIResult<Self> {
Ok(Self {
api: self.api.clone(),
@ -65,6 +84,7 @@ impl RoutingContext {
})
}
/// Use a specified [Sequencing] preference, with or without privacy
pub fn with_sequencing(self, sequencing: Sequencing) -> Self {
Self {
api: self.api.clone(),
@ -90,6 +110,7 @@ impl RoutingContext {
}
}
/// Get the [VeilidAPI] object that created this [RoutingContext]
pub fn api(&self) -> VeilidAPI {
self.api.clone()
}
@ -135,6 +156,14 @@ impl RoutingContext {
////////////////////////////////////////////////////////////////
// App-level Messaging
/// App-level bidirectional call that expects a response to be returned.
///
/// Veilid apps may use this for arbitrary message passing.
///
/// * `target` - can be either a direct node id or a private route
/// * `message` - an arbitrary message blob of up to 32768 bytes
///
/// Returns an answer blob of up to 32768 bytes
pub async fn app_call(&self, target: Target, message: Vec<u8>) -> VeilidAPIResult<Vec<u8>> {
let rpc_processor = self.api.rpc_processor()?;
@ -162,6 +191,12 @@ impl RoutingContext {
Ok(answer.answer)
}
/// App-level unidirectional message that does not expect any value to be returned.
///
/// Veilid apps may use this for arbitrary message passing.
///
/// * `target` - can be either a direct node id or a private route
/// * `message` - an arbitrary message blob of up to 32768 bytes
pub async fn app_message(&self, target: Target, message: Vec<u8>) -> VeilidAPIResult<()> {
let rpc_processor = self.api.rpc_processor()?;
@ -192,7 +227,10 @@ impl RoutingContext {
/// DHT Records
/// Creates a new DHT record a specified crypto kind and schema
/// Returns the newly allocated DHT record's key if successful. The records is considered 'open' after the create operation succeeds.
///
/// The record is considered 'open' after the create operation succeeds.
///
/// Returns the newly allocated DHT record's key if successful.
pub async fn create_dht_record(
&self,
schema: DHTSchema,
@ -206,9 +244,12 @@ impl RoutingContext {
.await
}
/// Opens a DHT record at a specific key. Associates a secret if one is provided to provide writer capability.
/// Opens a DHT record at a specific key
///
/// Associates a secret if one is provided to provide writer capability.
/// Records may only be opened or created. To re-open with a different routing context, first close the value.
///
/// Returns the DHT record descriptor for the opened record if successful
/// Records may only be opened or created . To re-open with a different routing context, first close the value.
pub async fn open_dht_record(
&self,
key: TypedKey,
@ -222,6 +263,7 @@ impl RoutingContext {
}
/// Closes a DHT record at a specific key that was opened with create_dht_record or open_dht_record.
///
/// Closing a record allows you to re-open it with a different routing context
pub async fn close_dht_record(&self, key: TypedKey) -> VeilidAPIResult<()> {
Crypto::validate_crypto_kind(key.kind)?;
@ -229,7 +271,9 @@ impl RoutingContext {
storage_manager.close_record(key).await
}
/// Deletes a DHT record at a specific key. If the record is opened, it must be closed before it is deleted.
/// Deletes a DHT record at a specific key
///
/// If the record is opened, it must be closed before it is deleted.
/// Deleting a record does not delete it from the network, but will remove the storage of the record
/// locally, and will prevent its value from being refreshed on the network by this node.
pub async fn delete_dht_record(&self, key: TypedKey) -> VeilidAPIResult<()> {
@ -239,9 +283,11 @@ impl RoutingContext {
}
/// Gets the latest value of a subkey
///
/// May pull the latest value from the network, but by settings 'force_refresh' you can force a network data refresh
/// Returns None if the value subkey has not yet been set
/// Returns Some(data) if the value subkey has valid data
///
/// Returns `None` if the value subkey has not yet been set
/// Returns `Some(data)` if the value subkey has valid data
pub async fn get_dht_value(
&self,
key: TypedKey,
@ -254,8 +300,9 @@ impl RoutingContext {
}
/// Pushes a changed subkey value to the network
/// Returns None if the value was successfully put
/// Returns Some(data) if the value put was older than the one available on the network
///
/// Returns `None` if the value was successfully put
/// Returns `Some(data)` if the value put was older than the one available on the network
pub async fn set_dht_value(
&self,
key: TypedKey,
@ -268,9 +315,11 @@ impl RoutingContext {
}
/// Watches changes to an opened or created value
///
/// Changes to subkeys within the subkey range are returned via a ValueChanged callback
/// If the subkey range is empty, all subkey changes are considered
/// Expiration can be infinite to keep the watch for the maximum amount of time
///
/// Return value upon success is the amount of time allowed for the watch
pub async fn watch_dht_values(
&self,
@ -287,6 +336,7 @@ impl RoutingContext {
}
/// Cancels a watch early
///
/// This is a convenience function that cancels watching all subkeys in a range
pub async fn cancel_dht_watch(
&self,

View File

@ -1,4 +1,5 @@
mod fixtures;
#[doc(hidden)]
pub mod test_serialize_json;
mod test_types;
mod test_types_dht;

View File

@ -3,15 +3,13 @@ use super::*;
/// Direct statement blob passed to hosting application for processing
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct VeilidAppMessage {
/// Some(sender) if the message was sent directly, None if received via a private/safety route
#[serde(with = "as_human_opt_string")]
#[schemars(with = "Option<String>")]
pub sender: Option<TypedKey>,
sender: Option<TypedKey>,
/// The content of the message to deliver to the application
#[serde(with = "as_human_base64")]
#[schemars(with = "String")]
pub message: Vec<u8>,
message: Vec<u8>,
}
impl VeilidAppMessage {
@ -19,9 +17,12 @@ impl VeilidAppMessage {
Self { sender, message }
}
/// Some(sender) if the message was sent directly, None if received via a private/safety route
pub fn sender(&self) -> Option<&TypedKey> {
self.sender.as_ref()
}
/// The content of the message to deliver to the application
pub fn message(&self) -> &[u8] {
&self.message
}
@ -30,17 +31,14 @@ impl VeilidAppMessage {
/// Direct question blob passed to hosting application for processing to send an eventual AppReply
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct VeilidAppCall {
/// Some(sender) if the request was sent directly, None if received via a private/safety route
#[serde(with = "as_human_opt_string")]
#[schemars(with = "Option<String>")]
sender: Option<TypedKey>,
/// The content of the request to deliver to the application
#[serde(with = "as_human_base64")]
#[schemars(with = "String")]
message: Vec<u8>,
/// The id to reply to
#[serde(with = "as_human_string")]
#[schemars(with = "String")]
call_id: OperationId,
@ -55,12 +53,16 @@ impl VeilidAppCall {
}
}
/// Some(sender) if the request was sent directly, None if received via a private/safety route
pub fn sender(&self) -> Option<&TypedKey> {
self.sender.as_ref()
}
/// The content of the request to deliver to the application
pub fn message(&self) -> &[u8] {
&self.message
}
/// The id to specify as `call_id` in the [VeilidAPI::app_call_reply] function
pub fn id(&self) -> OperationId {
self.call_id
}

View File

@ -27,7 +27,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
veilid: a54f57b7bcf0e4e072fe99272d76ca126b2026d0
PODFILE CHECKSUM: 73d2f470b1d889e27fcfda1d6e6efec66f98af3f

View File

@ -101,10 +101,10 @@ packages:
dependency: transitive
description:
name: ffi
sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
version: "2.1.0"
file_utils:
dependency: transitive
description:
@ -138,10 +138,10 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4"
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
url: "https://pub.dev"
source: hosted
version: "2.0.2"
version: "2.0.3"
flutter_test:
dependency: "direct dev"
description: flutter
@ -196,10 +196,10 @@ packages:
dependency: transitive
description:
name: macos_window_utils
sha256: b78a210aa70ca7ccad6e7b7b810fb4689c507f4a46e299214900b2a1eb70ea23
sha256: "43a90473f8786f00f07203e6819dab67e032f8896dafa4a6f85fbc71fba32c0b"
url: "https://pub.dev"
source: hosted
version: "1.1.3"
version: "1.2.0"
matcher:
dependency: transitive
description:
@ -236,58 +236,58 @@ packages:
dependency: "direct main"
description:
name: path_provider
sha256: "3087813781ab814e4157b172f1a11c46be20179fcc9bea043e0fba36bc0acaa2"
sha256: "909b84830485dbcd0308edf6f7368bc8fd76afa26a270420f34cabea2a6467a0"
url: "https://pub.dev"
source: hosted
version: "2.0.15"
version: "2.1.0"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86"
sha256: "5d44fc3314d969b84816b569070d7ace0f1dea04bd94a83f74c4829615d22ad8"
url: "https://pub.dev"
source: hosted
version: "2.0.27"
version: "2.1.0"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "916731ccbdce44d545414dd9961f26ba5fbaa74bcbb55237d8e65a623a8c7297"
sha256: "1b744d3d774e5a879bb76d6cd1ecee2ba2c6960c03b1020cd35212f6aa267ac5"
url: "https://pub.dev"
source: hosted
version: "2.2.4"
version: "2.3.0"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57
sha256: ba2b77f0c52a33db09fc8caf85b12df691bf28d983e84cf87ff6d693cfa007b3
url: "https://pub.dev"
source: hosted
version: "2.1.11"
version: "2.2.0"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec"
sha256: bced5679c7df11190e1ddc35f3222c858f328fff85c3942e46e7f5589bf9eb84
url: "https://pub.dev"
source: hosted
version: "2.0.6"
version: "2.1.0"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96"
sha256: ee0e0d164516b90ae1f970bdf29f726f1aa730d7cfc449ecc74c495378b705da
url: "https://pub.dev"
source: hosted
version: "2.1.7"
version: "2.2.0"
platform:
dependency: transitive
description:
name: platform
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
sha256: "57c07bf82207aee366dfaa3867b3164e4f03a238a461a11b0e8a3a510d51203d"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
version: "3.1.1"
platform_info:
dependency: transitive
description:
@ -300,10 +300,10 @@ packages:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc"
sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.1.5"
quiver:
dependency: transitive
description:
@ -416,18 +416,18 @@ packages:
dependency: transitive
description:
name: win32
sha256: dfdf0136e0aa7a1b474ea133e67cb0154a0acd2599c4f3ada3b49d38d38793ee
sha256: "9e82a402b7f3d518fb9c02d0e9ae45952df31b9bf34d77baf19da2de03fc2aaa"
url: "https://pub.dev"
source: hosted
version: "5.0.5"
version: "5.0.7"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: e0b1147eec179d3911f1f19b59206448f78195ca1d20514134e10641b7d7fbff
sha256: f0c26453a2d47aa4c2570c6a033246a3fc62da2fe23c7ffdd0a7495086dc0247
url: "https://pub.dev"
source: hosted
version: "1.0.1"
version: "1.0.2"
xterm:
dependency: "direct main"
description:

View File

@ -1,5 +1,5 @@
use veilid_core::tools::*;
use crate::dart_isolate_wrapper::*;
use crate::tools::*;
use allo_isolate::*;
use cfg_if::*;
use data_encoding::BASE64URL_NOPAD;
@ -10,13 +10,10 @@ use opentelemetry::*;
use opentelemetry_otlp::WithExportConfig;
use parking_lot::Mutex;
use serde::*;
use std::str::FromStr;
use std::collections::BTreeMap;
use std::os::raw::c_char;
use std::sync::Arc;
use tracing::*;
use tracing_subscriber::prelude::*;
use tracing_subscriber::*;
use veilid_core::Encodable as _;
// Globals
@ -58,29 +55,6 @@ define_string_destructor!(free_string);
type APIResult<T> = veilid_core::VeilidAPIResult<T>;
const APIRESULT_VOID: APIResult<()> = APIResult::Ok(());
// Parse target
async fn parse_target(s: String) -> APIResult<veilid_core::Target> {
// Is this a route id?
if let Ok(rrid) = veilid_core::RouteId::from_str(&s) {
let veilid_api = get_veilid_api().await?;
let routing_table = veilid_api.routing_table()?;
let rss = routing_table.route_spec_store();
// Is this a valid remote route id? (can't target allocated routes)
if rss.is_route_id_remote(&rrid) {
return Ok(veilid_core::Target::PrivateRoute(rrid));
}
}
// Is this a node id?
if let Ok(nid) = veilid_core::TypedKey::from_str(&s) {
return Ok(veilid_core::Target::NodeId(nid));
}
Err(veilid_core::VeilidAPIError::invalid_target())
}
/////////////////////////////////////////
// FFI-specific
@ -186,7 +160,7 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) {
.expect("failed to deserialize plaform config json");
// Set up subscriber and layers
let subscriber = Registry::default();
let subscriber = tracing_subscriber::Registry::default();
let mut layers = Vec::new();
let mut filters = (*FILTERS).lock();
@ -194,7 +168,7 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) {
if platform_config.logging.terminal.enabled {
let filter =
veilid_core::VeilidLayerFilter::new(platform_config.logging.terminal.level, None);
let layer = fmt::Layer::new()
let layer = tracing_subscriber::fmt::Layer::new()
.compact()
.with_writer(std::io::stdout)
.with_filter(filter.clone());
@ -217,6 +191,8 @@ pub extern "C" fn initialize_veilid_core(platform_config: FfiStr) {
.tonic()
.with_endpoint(format!("http://{}", grpc_endpoint));
let batch = opentelemetry::runtime::Tokio;
} else {
compile_error!("needs executor implementation")
}
}
@ -458,8 +434,8 @@ pub extern "C" fn routing_context_app_call(port: i64, id: u32, target: FfiStr, r
};
routing_context.clone()
};
let target = parse_target(target_string).await?;
let veilid_api = get_veilid_api().await?;
let target = veilid_api.parse_as_target(target_string).await?;
let answer = routing_context.app_call(target, request).await?;
let answer = data_encoding::BASE64URL_NOPAD.encode(&answer);
APIResult::Ok(answer)
@ -485,7 +461,8 @@ pub extern "C" fn routing_context_app_message(port: i64, id: u32, target: FfiStr
routing_context.clone()
};
let target = parse_target(target_string).await?;
let veilid_api = get_veilid_api().await?;
let target = veilid_api.parse_as_target(target_string).await?;
routing_context.app_message(target, message).await?;
APIRESULT_VOID
});

View File

@ -28,6 +28,7 @@ cfg_if! {
lazy_static::lazy_static! {
static ref GLOBAL_RUNTIME: tokio::runtime::Runtime = tokio::runtime::Runtime::new().unwrap();
}
} else {
compile_error!("needs executor implementation")
}
}

View File

@ -22,6 +22,8 @@ cfg_if! {
} else if #[cfg(feature="rt-tokio")] {
use tokio::io::AsyncBufReadExt;
use tokio::io::AsyncWriteExt;
} else {
compile_error!("needs executor implementation")
}
}
@ -114,7 +116,7 @@ impl ClientApi {
cfg_if! {
if #[cfg(feature="rt-async-std")] {
let mut incoming_stream = listener.incoming();
} else if #[cfg(feature="rt-tokio")] {
} else {
let mut incoming_stream = tokio_stream::wrappers::TcpListenerStream::new(listener);
}
}
@ -318,7 +320,7 @@ impl ClientApi {
use futures_util::AsyncReadExt;
let (reader, mut writer) = stream.split();
let reader = BufReader::new(reader);
} else if #[cfg(feature="rt-tokio")] {
} else {
let (reader, writer) = stream.into_split();
let reader = BufReader::new(reader);
}

View File

@ -19,7 +19,7 @@ use clap::{Args, Parser};
use server::*;
use settings::LogLevel;
use std::collections::HashMap;
use std::ffi::{OsString, OsStr};
use std::ffi::{OsStr, OsString};
use std::path::Path;
use std::str::FromStr;
use tools::*;
@ -40,7 +40,6 @@ pub struct Logging {
#[derive(Parser, Debug, Clone)]
#[command(author, version, about)]
pub struct CmdlineArgs {
/// Run in daemon mode in the background
#[arg(short, long)]
daemon: bool,
@ -66,7 +65,7 @@ pub struct CmdlineArgs {
new_password: Option<String>,
/// Do not automatically attach the server to the Veilid network
///
///
/// Default behaviour is to automatically attach the server to the Veilid network, this option disables this behaviour.
#[arg(long, value_name = "BOOL")]
no_attach: bool,
@ -75,7 +74,7 @@ pub struct CmdlineArgs {
logging: Logging,
/// Turn on OpenTelemetry tracing
///
///
/// This option uses the GRPC OpenTelemetry protocol, not HTTP. The format for the endpoint is host:port, like 'localhost:4317'
#[arg(long, value_name = "endpoint")]
otlp: Option<String>,
@ -85,14 +84,14 @@ pub struct CmdlineArgs {
subnode_index: Option<u16>,
/// Only generate a new keypair and print it
///
///
/// Generate a new keypair for a specific crypto kind and print both the key and its secret to the terminal, then exit immediately.
#[arg(long, value_name = "crypto_kind")]
generate_key_pair: Option<String>,
/// Set the node ids and secret keys
///
/// Specify node ids in typed key set format ('[VLD0:xxxx,VLD1:xxxx]') on the command line, a prompt appears to enter the secret key set interactively.
///
/// Specify node ids in typed key set format ('\[VLD0:xxxx,VLD1:xxxx\]') on the command line, a prompt appears to enter the secret key set interactively.
#[arg(long, value_name = "key_set")]
set_node_id: Option<String>,
@ -156,7 +155,7 @@ fn main() -> EyreResult<()> {
// Check for one-off commands
#[cfg(debug_assertions)]
if args.wait_for_debug{
if args.wait_for_debug {
use bugsalot::debugger;
debugger::wait_until_attached(None).expect("state() not implemented on this platform");
}
@ -204,7 +203,9 @@ fn main() -> EyreResult<()> {
println!("Enabling OTLP tracing");
settingsrw.logging.otlp.enabled = true;
settingsrw.logging.otlp.grpc_endpoint = NamedSocketAddrs::from_str(
args.otlp.expect("should not be null because of default missing value").as_str(),
args.otlp
.expect("should not be null because of default missing value")
.as_str(),
)
.wrap_err("failed to parse OTLP address")?;
settingsrw.logging.otlp.level = LogLevel::Trace;
@ -222,10 +223,16 @@ fn main() -> EyreResult<()> {
settingsrw.core.table_store.delete = true;
}
if let Some(password) = args.password {
settingsrw.core.protected_store.device_encryption_key_password = password;
settingsrw
.core
.protected_store
.device_encryption_key_password = password;
}
if let Some(new_password) = args.new_password {
settingsrw.core.protected_store.new_device_encryption_key_password = Some(new_password);
settingsrw
.core
.protected_store
.new_device_encryption_key_password = Some(new_password);
}
if let Some(network_key) = args.network_key {
settingsrw.core.network.network_key_password = Some(network_key);
@ -241,8 +248,8 @@ fn main() -> EyreResult<()> {
settingsrw.logging.terminal.enabled = false;
// Split or get secret
let tks =
TypedKeyGroup::from_str(&key_set).wrap_err("failed to decode node id set from command line")?;
let tks = TypedKeyGroup::from_str(&key_set)
.wrap_err("failed to decode node id set from command line")?;
let buffer = rpassword::prompt_password("Enter secret key set (will not echo): ")
.wrap_err("invalid secret key")?;
@ -265,7 +272,7 @@ fn main() -> EyreResult<()> {
}
settingsrw.core.network.routing_table.bootstrap = bootstrap_list;
};
#[cfg(feature = "rt-tokio")]
if args.console {
settingsrw.logging.console.enabled = true;
@ -299,8 +306,8 @@ fn main() -> EyreResult<()> {
let mut tks = veilid_core::TypedKeyGroup::new();
let mut tss = veilid_core::TypedSecretGroup::new();
for ck in veilid_core::VALID_CRYPTO_KINDS {
let tkp = veilid_core::Crypto::generate_keypair(ck)
.wrap_err("invalid crypto kind")?;
let tkp =
veilid_core::Crypto::generate_keypair(ck).wrap_err("invalid crypto kind")?;
tks.add(veilid_core::TypedKey::new(tkp.kind, tkp.value.key));
tss.add(veilid_core::TypedSecret::new(tkp.kind, tkp.value.secret));
}
@ -312,8 +319,7 @@ fn main() -> EyreResult<()> {
} else {
let ck: veilid_core::CryptoKind =
veilid_core::FourCC::from_str(&ckstr).wrap_err("couldn't parse crypto kind")?;
let tkp =
veilid_core::Crypto::generate_keypair(ck).wrap_err("invalid crypto kind")?;
let tkp = veilid_core::Crypto::generate_keypair(ck).wrap_err("invalid crypto kind")?;
println!("{}", tkp.to_string());
}
return Ok(());

View File

@ -48,6 +48,7 @@ cfg_if! {
let local = tokio::task::LocalSet::new();
local.block_on(&rt, f)
}
} else {
compile_error!("needs executor implementation")
}
}

View File

@ -80,6 +80,8 @@ impl VeilidLogs {
.tonic()
.with_endpoint(format!("http://{}", grpc_endpoint));
let batch = opentelemetry::runtime::Tokio;
} else {
compile_error!("needs executor implementation")
}
}

View File

@ -7,29 +7,40 @@ edition = "2021"
[lib]
# staticlib for iOS tests, cydlib for android tests, rlib for everything else
crate-type = [ "cdylib", "staticlib", "rlib" ]
crate-type = ["cdylib", "staticlib", "rlib"]
[features]
default = []
rt-async-std = [ "async-std", "async_executors/async_std" ]
rt-tokio = [ "tokio", "tokio-util", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer" ]
rt-wasm-bindgen = [ "async_executors/bindgen", "async_executors/timer"]
default = ["rt-tokio"]
rt-async-std = ["async-std", "async_executors/async_std"]
rt-tokio = [
"tokio",
"tokio-util",
"async_executors/tokio_tp",
"async_executors/tokio_io",
"async_executors/tokio_timer",
]
rt-wasm-bindgen = ["async_executors/bindgen", "async_executors/timer"]
veilid_tools_android_tests = [ "dep:paranoid-android" ]
veilid_tools_ios_tests = [ "dep:oslog", "dep:tracing-oslog" ]
tracing = [ "dep:tracing", "dep:tracing-subscriber" ]
veilid_tools_android_tests = ["dep:paranoid-android"]
veilid_tools_ios_tests = ["dep:oslog", "dep:tracing-oslog"]
tracing = ["dep:tracing", "dep:tracing-subscriber"]
network-result-extra = []
network-result-info = []
[dependencies]
tracing = { version = "0.1.37", features = ["log", "attributes"], optional = true }
tracing = { version = "0.1.37", features = [
"log",
"attributes",
], optional = true }
tracing-subscriber = { version = "0.3.17", optional = true }
log = { version = "0.4.20" }
eyre = "0.6.8"
static_assertions = "1.1.0"
cfg-if = "1.0.0"
thiserror = "1.0.47"
futures-util = { version = "0.3.28", default_features = false, features = ["alloc"] }
futures-util = { version = "0.3.28", default_features = false, features = [
"alloc",
] }
parking_lot = "0.12.1"
once_cell = "1.18.0"
stop-token = { version = "0.7.0", default-features = false }
@ -43,10 +54,15 @@ flume = { version = "0.11.0", features = ["async"] }
# Dependencies for native builds only
# Linux, Windows, Mac, iOS, Android
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
async-std = { version = "1.12.0", features = ["unstable"], optional = true}
tokio = { version = "1.32.0", features = ["full"], optional = true}
tokio-util = { version = "0.7.8", features = ["compat"], optional = true}
futures-util = { version = "0.3.28", default-features = false, features = ["async-await", "sink", "std", "io"] }
async-std = { version = "1.12.0", features = ["unstable"], optional = true }
tokio = { version = "1.32.0", features = ["full"], optional = true }
tokio-util = { version = "0.7.8", features = ["compat"], optional = true }
futures-util = { version = "0.3.28", default-features = false, features = [
"async-await",
"sink",
"std",
"io",
] }
chrono = "0.4.26"
libc = "0.2.147"
@ -57,7 +73,8 @@ nix = "0.26.2"
wasm-bindgen = "0.2.87"
js-sys = "0.3.64"
wasm-bindgen-futures = "0.4.37"
async_executors = { version = "0.7.0", default-features = false}
async_executors = { version = "0.7.0", default-features = false }
async-lock = "2.8.0"
send_wrapper = { version = "0.6.0", features = ["futures"] }
@ -69,7 +86,7 @@ ndk = { version = "0.7.0" }
ndk-glue = { version = "0.7.0", features = ["logger"] }
lazy_static = "1.4.0"
paranoid-android = { version = "0.2.1", optional = true }
android-logd-logger = "0.4.2"
android_logger = "0.13.3"
# Dependencies for Windows
# [target.'cfg(target_os = "windows")'.dependencies]
@ -85,7 +102,7 @@ tracing-oslog = { version = "0.1.2", optional = true }
[dev-dependencies]
serial_test = "^2.0.0"
simplelog = { version = "0.12.1", features = [ "test" ] }
simplelog = { version = "0.12.1", features = ["test"] }
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
console_error_panic_hook = "0.1.7"
@ -100,6 +117,10 @@ tracing-wasm = { version = "0.2.1" }
wasm-opt = ["-O", "--enable-mutable-globals"]
[package.metadata.ios]
build_targets = ["aarch64-apple-ios", "aarch64-apple-ios-sim", "x86_64-apple-ios"]
build_targets = [
"aarch64-apple-ios",
"aarch64-apple-ios-sim",
"x86_64-apple-ios",
]
deployment_target = "12.0"
build_id_prefix = "com.veilid.veilidtools"

View File

@ -59,9 +59,9 @@ elif [[ "$1" == "android" ]]; then
popd >/dev/null
else
cargo test --features=rt-tokio,tracing -- --nocapture
cargo test --features=rt-async-std,tracing -- --nocapture
cargo test --features=rt-tokio -- --nocapture
cargo test --features=rt-async-std -- --nocapture
cargo test -- --nocapture
cargo test --features=tracing -- --nocapture
cargo test --no-default-features --features=rt-async-std -- --nocapture
cargo test --no-default-features --features=rt-async-std,tracing -- --nocapture
fi
popd 2>/dev/null

View File

@ -1,3 +1,7 @@
//! Packet reassembly and fragmentation handler
//!
//! * [AssemblyBuffer] handles both the sender and received end of fragmentation and reassembly.
use super::*;
use range_set_blaze::RangeSetBlaze;
use std::io::{Error, ErrorKind};
@ -12,7 +16,12 @@ const MAX_LEN: usize = LengthType::MAX as usize;
// XXX: keep statistics on all drops and why we dropped them
// XXX: move to config eventually?
/// The hard-coded maximum fragment size used by AssemblyBuffer
///
/// Eventually this should parameterized and made configurable.
pub const FRAGMENT_LEN: usize = 1280 - HEADER_LEN;
const MAX_CONCURRENT_HOSTS: usize = 256;
const MAX_ASSEMBLIES_PER_HOST: usize = 256;
const MAX_BUFFER_PER_HOST: usize = 256 * 1024;
@ -202,8 +211,23 @@ struct AssemblyBufferUnlockedInner {
}
/// Packet reassembly and fragmentation handler
/// No retry, no acknowledgment, no flow control
/// Just trying to survive lower path MTU for larger messages
///
/// Used to provide, for raw unordered protocols such as UDP, a means to achieve:
///
/// * Fragmentation of packets to ensure they are smaller than a common MTU
/// * Reassembly of fragments upon receipt accounting for:
/// * duplication
/// * drops
/// * overlaops
///
/// AssemblyBuffer does not try to replicate TCP or other highly reliable protocols. Here are some
/// of the design limitations to be aware of when using AssemblyBuffer:
///
/// * No packet acknowledgment. The sender does not know if a packet was received.
/// * No flow control. If there are buffering problems or drops, the sender and receiver have no protocol to address this.
/// * No retries or retransmission.
/// * No sequencing of packets. Packets may still be delivered to the application out of order, but this guarantees that only whole packets will be delivered if all of their fragments are received.
#[derive(Clone)]
pub struct AssemblyBuffer {
inner: Arc<Mutex<AssemblyBufferInner>>,

View File

@ -1,32 +1,55 @@
// mod bump_port;
mod assembly_buffer;
mod async_peek_stream;
mod async_tag_lock;
mod clone_stream;
mod eventual;
mod eventual_base;
mod eventual_value;
mod eventual_value_clone;
mod interval;
mod ip_addr_port;
mod ip_extra;
mod log_thru;
mod must_join_handle;
mod must_join_single_future;
mod mutable_future;
mod network_result;
mod random;
mod single_shot_eventual;
mod sleep;
mod spawn;
mod split_url;
mod tick_task;
mod timeout;
mod timeout_or;
mod timestamp;
mod tools;
//! # Veilid Tools
//!
//! A collection of baseline tools for Rust development use by Veilid and Veilid-enabled Rust applications
//!
//! These are used by `veilid-core`, `veilid-server`, `veilid-cli` and may be used by any other applications
//! that link in `veilid-core` if a common baseline of functionality is desired. Extending this crate with new
//! utility functions is encouraged rather than adding 'common' functionality to `veilid-core`, allowing it to
//! remain free of boilerplate and utility classes that could be reused elsewhere.
//!
//! Everything added to this crate must be extensively unit-tested.
//!
//! ## Features
//!
//! The default `veilid-tools` configurations are:
//!
//! * `default` - Uses `tokio` as the async runtime
//!
//! If you use `--no-default-features`, you can switch to other runtimes:
//!
//! * `rt-async-std` - Uses `async-std` as the async runtime
//! * `rt-wasm-bindgen` - When building for the `wasm32` architecture, use this to enable `wasm-bindgen-futures` as the async runtime
//!
// pub mod bump_port;
pub mod assembly_buffer;
pub mod async_peek_stream;
pub mod async_tag_lock;
pub mod clone_stream;
pub mod eventual;
pub mod eventual_base;
pub mod eventual_value;
pub mod eventual_value_clone;
pub mod interval;
pub mod ip_addr_port;
pub mod ip_extra;
pub mod log_thru;
pub mod must_join_handle;
pub mod must_join_single_future;
pub mod mutable_future;
pub mod network_result;
pub mod random;
pub mod single_shot_eventual;
pub mod sleep;
pub mod spawn;
pub mod split_url;
pub mod tick_task;
pub mod timeout;
pub mod timeout_or;
pub mod timestamp;
pub mod tools;
#[cfg(target_arch = "wasm32")]
mod wasm;
pub mod wasm;
pub type PinBox<T> = Pin<Box<T>>;
pub type PinBoxFuture<T> = PinBox<dyn Future<Output = T> + 'static>;
@ -34,85 +57,148 @@ pub type PinBoxFutureLifetime<'a, T> = PinBox<dyn Future<Output = T> + 'a>;
pub type SendPinBoxFuture<T> = PinBox<dyn Future<Output = T> + Send + 'static>;
pub type SendPinBoxFutureLifetime<'a, T> = PinBox<dyn Future<Output = T> + Send + 'a>;
#[doc(no_inline)]
pub use std::borrow::{Cow, ToOwned};
#[doc(no_inline)]
pub use std::boxed::Box;
#[doc(no_inline)]
pub use std::cell::RefCell;
#[doc(no_inline)]
pub use std::cmp;
#[doc(no_inline)]
pub use std::collections::btree_map::BTreeMap;
#[doc(no_inline)]
pub use std::collections::btree_set::BTreeSet;
#[doc(no_inline)]
pub use std::collections::hash_map::HashMap;
#[doc(no_inline)]
pub use std::collections::hash_set::HashSet;
#[doc(no_inline)]
pub use std::collections::LinkedList;
#[doc(no_inline)]
pub use std::collections::VecDeque;
#[doc(no_inline)]
pub use std::convert::{TryFrom, TryInto};
#[doc(no_inline)]
pub use std::fmt;
#[doc(no_inline)]
pub use std::future::Future;
#[doc(no_inline)]
pub use std::mem;
#[doc(no_inline)]
pub use std::net::{
IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs,
};
#[doc(no_inline)]
pub use std::ops::{Fn, FnMut, FnOnce};
#[doc(no_inline)]
pub use std::pin::Pin;
#[doc(no_inline)]
pub use std::rc::Rc;
#[doc(no_inline)]
pub use std::str::FromStr;
#[doc(no_inline)]
pub use std::string::{String, ToString};
#[doc(no_inline)]
pub use std::sync::atomic::{AtomicBool, Ordering};
#[doc(no_inline)]
pub use std::sync::{Arc, Weak};
#[doc(no_inline)]
pub use std::task;
#[doc(no_inline)]
pub use std::time::Duration;
#[doc(no_inline)]
pub use std::vec::Vec;
cfg_if! {
if #[cfg(target_arch = "wasm32")] {
#[doc(no_inline)]
pub use async_lock::Mutex as AsyncMutex;
#[doc(no_inline)]
pub use async_lock::MutexGuard as AsyncMutexGuard;
#[doc(no_inline)]
pub use async_lock::MutexGuardArc as AsyncMutexGuardArc;
#[doc(no_inline)]
pub use async_executors::JoinHandle as LowLevelJoinHandle;
} else {
cfg_if! {
if #[cfg(feature="rt-async-std")] {
#[doc(no_inline)]
pub use async_std::sync::Mutex as AsyncMutex;
#[doc(no_inline)]
pub use async_std::sync::MutexGuard as AsyncMutexGuard;
#[doc(no_inline)]
pub use async_std::sync::MutexGuardArc as AsyncMutexGuardArc;
#[doc(no_inline)]
pub use async_std::task::JoinHandle as LowLevelJoinHandle;
} else if #[cfg(feature="rt-tokio")] {
#[doc(no_inline)]
pub use tokio::sync::Mutex as AsyncMutex;
#[doc(no_inline)]
pub use tokio::sync::MutexGuard as AsyncMutexGuard;
#[doc(no_inline)]
pub use tokio::sync::OwnedMutexGuard as AsyncMutexGuardArc;
#[doc(no_inline)]
pub use tokio::task::JoinHandle as LowLevelJoinHandle;
} else {
#[compile_error("must use an executor")]
compile_error!("needs executor implementation")
}
}
}
}
// pub use bump_port::*;
#[doc(inline)]
pub use assembly_buffer::*;
#[doc(inline)]
pub use async_peek_stream::*;
#[doc(inline)]
pub use async_tag_lock::*;
#[doc(inline)]
pub use clone_stream::*;
#[doc(inline)]
pub use eventual::*;
#[doc(inline)]
pub use eventual_base::{EventualCommon, EventualResolvedFuture};
#[doc(inline)]
pub use eventual_value::*;
#[doc(inline)]
pub use eventual_value_clone::*;
#[doc(inline)]
pub use interval::*;
#[doc(inline)]
pub use ip_addr_port::*;
#[doc(inline)]
pub use ip_extra::*;
#[doc(inline)]
pub use log_thru::*;
#[doc(inline)]
pub use must_join_handle::*;
#[doc(inline)]
pub use must_join_single_future::*;
#[doc(inline)]
pub use mutable_future::*;
#[doc(inline)]
pub use network_result::*;
#[doc(inline)]
pub use random::*;
#[doc(inline)]
pub use single_shot_eventual::*;
#[doc(inline)]
pub use sleep::*;
#[doc(inline)]
pub use spawn::*;
#[doc(inline)]
pub use split_url::*;
#[doc(inline)]
pub use tick_task::*;
#[doc(inline)]
pub use timeout::*;
#[doc(inline)]
pub use timeout_or::*;
#[doc(inline)]
pub use timestamp::*;
#[doc(inline)]
pub use tools::*;
#[cfg(target_arch = "wasm32")]

View File

@ -44,14 +44,20 @@ pub fn veilid_tools_setup_android_tests() {
.try_init()
.expect("failed to init android tracing");
} else {
let mut builder = android_logd_logger::builder();
builder.tag("veilid-tools");
builder.prepend_module(true);
use log::LevelFilter;
use android_logger::{Config,FilterBuilder};
let mut builder = FilterBuilder::new();
builder.filter_level(LevelFilter::Trace);
for ig in DEFAULT_LOG_IGNORE_LIST {
builder.filter_module(ig, LevelFilter::Off);
}
builder.init();
android_logger::init_once(
Config::default()
.with_max_level(LevelFilter::Trace) // limit log level
.with_tag("veilid-tools") // logs will show under mytag tag
.with_filter(builder.build())
);
}
}

View File

@ -9,11 +9,11 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]
[features]
default = [ "veilid-core/rt-wasm-bindgen", "veilid-core/default" ]
crypto-test = [ "veilid-core/rt-wasm-bindgen", "veilid-core/crypto-test"]
default = ["veilid-core/default-wasm"]
crypto-test = ["veilid-core/crypto-test"]
[dependencies]
veilid-core = { path = "../veilid-core", default-features = false }
veilid-core = { path = "../veilid-core", default-features = false }
tracing = { version = "^0", features = ["log", "attributes"] }
tracing-wasm = "^0"

View File

@ -80,28 +80,6 @@ pub fn from_json<T: de::DeserializeOwned + Debug>(
deserialize_json(&s)
}
// Parse target
fn parse_target(s: String) -> APIResult<veilid_core::Target> {
// Is this a route id?
if let Ok(rrid) = veilid_core::RouteId::from_str(&s) {
let veilid_api = get_veilid_api()?;
let routing_table = veilid_api.routing_table()?;
let rss = routing_table.route_spec_store();
// Is this a valid remote route id? (can't target allocated routes)
if rss.is_route_id_remote(&rrid) {
return Ok(veilid_core::Target::PrivateRoute(rrid));
}
}
// Is this a node id?
if let Ok(nid) = veilid_core::TypedKey::from_str(&s) {
return Ok(veilid_core::Target::NodeId(nid));
}
Err(veilid_core::VeilidAPIError::invalid_target())
}
// Utility types for async API results
type APIResult<T> = Result<T, veilid_core::VeilidAPIError>;
const APIRESULT_UNDEFINED: APIResult<()> = APIResult::Ok(());
@ -370,7 +348,7 @@ pub fn routing_context_with_sequencing(id: u32, sequencing: String) -> u32 {
}
#[wasm_bindgen()]
pub fn routing_context_app_call(id: u32, target: String, request: String) -> Promise {
pub fn routing_context_app_call(id: u32, target_string: String, request: String) -> Promise {
let request: Vec<u8> = data_encoding::BASE64URL_NOPAD
.decode(request.as_bytes())
.unwrap();
@ -383,7 +361,8 @@ pub fn routing_context_app_call(id: u32, target: String, request: String) -> Pro
routing_context.clone()
};
let target = parse_target(target)?;
let veilid_api = get_veilid_api()?;
let target = veilid_api.parse_as_target(target_string).await?;
let answer = routing_context.app_call(target, request).await?;
let answer = data_encoding::BASE64URL_NOPAD.encode(&answer);
APIResult::Ok(answer)
@ -391,7 +370,7 @@ pub fn routing_context_app_call(id: u32, target: String, request: String) -> Pro
}
#[wasm_bindgen()]
pub fn routing_context_app_message(id: u32, target: String, message: String) -> Promise {
pub fn routing_context_app_message(id: u32, target_string: String, message: String) -> Promise {
let message: Vec<u8> = data_encoding::BASE64URL_NOPAD
.decode(message.as_bytes())
.unwrap();
@ -404,7 +383,8 @@ pub fn routing_context_app_message(id: u32, target: String, message: String) ->
routing_context.clone()
};
let target = parse_target(target)?;
let veilid_api = get_veilid_api()?;
let target = veilid_api.parse_as_target(target_string).await?;
routing_context.app_message(target, message).await?;
APIRESULT_UNDEFINED
})