Merge branch 'main' of gitlab.hackers.town:veilid/veilid

This commit is contained in:
John Smith 2022-01-14 19:05:44 -05:00
commit 925c42b275
13 changed files with 223 additions and 176 deletions

11
.cargo/config.toml Normal file
View File

@ -0,0 +1,11 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.aarch64-linux-android]
linker = "/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang"
[target.armv7-linux-androideabi]
linker = "/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi30-clang"
[target.x86_64-linux-android]
linker = "/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang"
[target.i686-linux-android]
linker = "/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android30-clang"

167
Cargo.lock generated
View File

@ -63,7 +63,7 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom 0.2.3",
"getrandom 0.2.4",
"once_cell",
"version_check",
]
@ -116,15 +116,6 @@ dependencies = [
"log",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "anyhow"
version = "1.0.52"
@ -339,9 +330,9 @@ dependencies = [
[[package]]
name = "async_executors"
version = "0.5.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19f76fbfe0b44e406eb9b211d6a1b7eb0f86e9b6d1006b3dbf07ef0b8253ae9a"
checksum = "5b0b8626a279ab86ef8ba31cc91549e3386eb7883cd94305896d438aa6535c62"
dependencies = [
"async-std",
"blanket",
@ -434,9 +425,9 @@ dependencies = [
[[package]]
name = "blake3"
version = "1.2.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "526c210b4520e416420759af363083471656e819a75e831b8d2c9d5a584f2413"
checksum = "882e99e4a0cb2ae6cb6e442102e8e6b7131718d94110e64c3e6a34ea9b106f37"
dependencies = [
"arrayref",
"arrayvec 0.7.2",
@ -521,9 +512,9 @@ checksum = "2ecfa84116fbdfe0a25779563defa5e6600ec6ef041017efe21ef494206e6928"
[[package]]
name = "bumpalo"
version = "3.9.0"
version = "3.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe438c9d2f2b0fb88a112154ed81e30b0a491c29322afe1db3b6eec5811f5ba0"
checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
[[package]]
name = "byte-slice-cast"
@ -557,9 +548,9 @@ checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]]
name = "capnp"
version = "0.14.4"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5094b52ad2d87cde8fb88488355e76552dd6606efa27730db7592d23ab2fded1"
checksum = "16c262726f68118392269a3f7a5546baf51dcfe5cb3c3f0957b502106bf1a065"
[[package]]
name = "capnp-futures"
@ -584,9 +575,9 @@ dependencies = [
[[package]]
name = "capnpc"
version = "0.14.4"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b47bce811162518b5c38f746ed584bd2922ae7bb560ef64f230d2e4ee0d111fe"
checksum = "682f2a7a680ac01d07fcc5e201cf23e5de65f528dfad7305e4a0a5312d35952f"
dependencies = [
"capnp",
]
@ -626,21 +617,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chacha20"
version = "0.8.1"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01b72a433d0cf2aef113ba70f62634c56fddb0f244e6377185c56a7cadbd8f91"
checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412"
dependencies = [
"cfg-if 1.0.0",
"cipher 0.3.0",
"cpufeatures",
"cpufeatures 0.1.5",
"zeroize",
]
[[package]]
name = "chacha20poly1305"
version = "0.9.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b84ed6d1d5f7aa9bdde921a5090e0ca4d934d250ea3b402a5fab3a994e28a2a"
checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5"
dependencies = [
"aead",
"chacha20",
@ -686,13 +677,9 @@ version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim 0.8.0",
"textwrap 0.11.0",
"unicode-width",
"vec_map",
]
[[package]]
@ -705,7 +692,7 @@ dependencies = [
"bitflags",
"indexmap",
"os_str_bytes",
"strsim 0.10.0",
"strsim",
"termcolor",
"textwrap 0.14.2",
]
@ -721,9 +708,9 @@ dependencies = [
[[package]]
name = "combine"
version = "4.6.2"
version = "4.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b2f5d0ee456f3928812dfc8c6d9a1d592b98678f6d56db9b0cd2b7bc6c8db5"
checksum = "50b727aacc797f9fc28e355d21f34709ac4fc9adecfe470ad07b8f4464f53062"
dependencies = [
"bytes 1.1.0",
"memchr",
@ -828,6 +815,15 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "cpufeatures"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef"
dependencies = [
"libc",
]
[[package]]
name = "cpufeatures"
version = "0.2.1"
@ -875,9 +871,9 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.1"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"
checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@ -896,9 +892,9 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
version = "0.9.5"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd"
checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@ -909,9 +905,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"
checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"
dependencies = [
"cfg-if 1.0.0",
"lazy_static",
@ -1118,7 +1114,7 @@ dependencies = [
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"strsim",
"syn",
]
@ -1159,15 +1155,6 @@ dependencies = [
"generic-array",
]
[[package]]
name = "directories"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e69600ff1703123957937708eb27f7a564e48885c537782722ed0ba3189ce1d7"
dependencies = [
"dirs-sys",
]
[[package]]
name = "directories"
version = "4.0.1"
@ -1565,9 +1552,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.3"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
dependencies = [
"cfg-if 1.0.0",
"js-sys",
@ -1744,9 +1731,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.7.0"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
dependencies = [
"autocfg",
"hashbrown",
@ -1855,7 +1842,7 @@ dependencies = [
"clap 3.0.7",
"core-foundation 0.9.2",
"core-foundation-sys 0.8.3",
"directories 4.0.1",
"directories",
"fs4",
"jni",
"keychain-services",
@ -2684,7 +2671,7 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede"
dependencies = [
"cpufeatures",
"cpufeatures 0.2.1",
"opaque-debug",
"universal-hash",
]
@ -2835,7 +2822,7 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
"getrandom 0.2.3",
"getrandom 0.2.4",
]
[[package]]
@ -2902,7 +2889,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
dependencies = [
"getrandom 0.2.3",
"getrandom 0.2.4",
"redox_syscall 0.2.10",
]
@ -3330,20 +3317,20 @@ checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6"
dependencies = [
"block-buffer",
"cfg-if 1.0.0",
"cpufeatures",
"cpufeatures 0.2.1",
"digest",
"opaque-debug",
]
[[package]]
name = "sha2"
version = "0.9.8"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa"
checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
dependencies = [
"block-buffer",
"cfg-if 1.0.0",
"cpufeatures",
"cpufeatures 0.2.1",
"digest",
"opaque-debug",
]
@ -3386,9 +3373,9 @@ checksum = "f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4"
[[package]]
name = "simplelog"
version = "0.11.1"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecabc0118918611790b8615670ab79296272cbe09496b6884b02b1e929c20886"
checksum = "c1348164456f72ca0116e4538bdaabb0ddb622c7d9f16387c725af3e96d6001c"
dependencies = [
"chrono",
"log",
@ -3403,9 +3390,9 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5"
[[package]]
name = "smallvec"
version = "1.7.0"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
[[package]]
name = "snailquote"
@ -3445,12 +3432,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "strsim"
version = "0.10.0"
@ -3471,9 +3452,9 @@ checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142"
[[package]]
name = "syn"
version = "1.0.84"
version = "1.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b"
checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7"
dependencies = [
"proc-macro2",
"quote",
@ -3494,9 +3475,9 @@ dependencies = [
[[package]]
name = "sysinfo"
version = "0.22.4"
version = "0.22.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccb37aa4af23791c584202d286ed9420e023e9d27e49d5a76215623f4bcc2502"
checksum = "7f1bfab07306a27332451a662ca9c8156e3a9986f82660ba9c8e744fe8455d43"
dependencies = [
"cfg-if 1.0.0",
"core-foundation-sys 0.8.3",
@ -3515,13 +3496,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "tempfile"
version = "3.2.0"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [
"cfg-if 1.0.0",
"fastrand",
"libc",
"rand 0.8.4",
"redox_syscall 0.2.10",
"remove_dir_all",
"winapi",
@ -3789,12 +3770,6 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "veilid-cli"
version = "0.1.0"
@ -3806,14 +3781,14 @@ dependencies = [
"capnp",
"capnp-rpc",
"capnpc",
"cfg-if 0.1.10",
"clap 2.34.0",
"cfg-if 1.0.0",
"clap 3.0.7",
"config 0.10.1",
"crossbeam-channel",
"cursive",
"cursive-flexi-logger-view",
"cursive_buffered_backend",
"directories 3.0.2",
"directories",
"flexi_logger",
"futures",
"log",
@ -3842,7 +3817,7 @@ dependencies = [
"bugsalot",
"capnp",
"capnpc",
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"chacha20poly1305",
"chrono",
"config 0.11.0",
@ -3850,11 +3825,11 @@ dependencies = [
"curve25519-dalek-ng",
"data-encoding",
"digest",
"directories 3.0.2",
"directories",
"ed25519-dalek",
"futures-util",
"generic-array",
"getrandom 0.2.3",
"getrandom 0.2.4",
"hashbrown",
"hex",
"ifstructs",
@ -3913,12 +3888,12 @@ dependencies = [
"capnp",
"capnp-rpc",
"capnpc",
"cfg-if 0.1.10",
"clap 2.34.0",
"cfg-if 1.0.0",
"clap 3.0.7",
"config 0.11.0",
"ctrlc",
"daemonize",
"directories 3.0.2",
"directories",
"failure",
"futures",
"lazy_static",
@ -4288,18 +4263,18 @@ dependencies = [
[[package]]
name = "zeroize"
version = "1.4.3"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619"
checksum = "cc222aec311c323c717f56060324f32b82da1ce1dd81d9a09aa6a9030bfe08db"
dependencies = [
"zeroize_derive",
]
[[package]]
name = "zeroize_derive"
version = "1.2.2"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65f1a51723ec88c66d5d1fe80c841f17f63587d6691901d66be9bec6c3b51f73"
checksum = "81e8f13fef10b63c06356d65d416b070798ddabcadc10d3ece0c5be9b3c7eddb"
dependencies = [
"proc-macro2",
"quote",

View File

@ -16,9 +16,15 @@ deps-base:
RUN apt-get remove -y python3.5
RUN curl https://bootstrap.pypa.io/get-pip.py | python3.8
# Install Cap'n Proto
deps-capnp:
FROM +deps-base
COPY scripts/earthly/install_capnproto.sh /
RUN /bin/bash /install_capnproto.sh; rm /install_capnproto.sh
# Install Rust
deps-rust:
FROM +deps-base
FROM +deps-capnp
ENV RUSTUP_HOME=/usr/local/rustup
ENV CARGO_HOME=/usr/local/cargo
ENV PATH=/usr/local/cargo/bin:$PATH
@ -37,21 +43,28 @@ deps-rust:
# WASM
RUN rustup target add wasm32-unknown-unknown
# Install Cap'n Proto
deps-capnp:
# Install Linux cross-platform tooling
deps-cross:
FROM +deps-rust
COPY scripts/earthly/install_capnproto.sh /
RUN /bin/bash /install_capnproto.sh; rm /install_capnproto.sh
RUN apt-get install -y gcc-aarch64-linux-gnu curl unzip
# Install android tooling
deps-android:
FROM +deps-cross
RUN apt-get install -y openjdk-9-jdk-headless
RUN mkdir /Android; mkdir /Android/Sdk
RUN curl -o /Android/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
RUN cd /Android; unzip /Android/cmdline-tools.zip
RUN yes | /Android/cmdline-tools/bin/sdkmanager --sdk_root=/Android/Sdk build-tools\;30.0.3 ndk\;22.0.7026061 cmake\;3.18.1 platform-tools platforms\;android-30
# Install stub secrets daemon for keyring tests
deps-secretsd:
FROM +deps-capnp
FROM +deps-android
COPY scripts/earthly/secretsd /secretsd
RUN pip install -r /secretsd/requirements.txt
RUN pip install keyring
RUN cp /secretsd/dbus/org.freedesktop.secrets.service /usr/share/dbus-1/services/org.freedesktop.secrets.service
# Clean up the apt cache to save space
deps:
FROM +deps-secretsd
@ -59,7 +72,8 @@ deps:
code:
FROM +deps
COPY . .
COPY --dir .cargo external files scripts veilid-cli veilid-core veilid-server veilid-wasm Cargo.lock Cargo.toml /veilid
WORKDIR /veilid
# Clippy only
clippy:
@ -77,7 +91,25 @@ build-linux-arm64:
RUN cargo build --target aarch64-unknown-linux-gnu --release
SAVE ARTIFACT ./target/aarch64-unknown-linux-gnu AS LOCAL ./target/artifacts/aarch64-unknown-linux-gnu
# Unit tests
unit-test:
build-android:
FROM +code
RUN cargo test --release
WORKDIR /veilid/veilid-core
ENV PATH=$PATH:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/
RUN cargo build --target aarch64-linux-android --release
RUN cargo build --target armv7-linux-androideabi --release
RUN cargo build --target i686-linux-android --release
RUN cargo build --target x86_64-linux-android --release
WORKDIR /veilid
SAVE ARTIFACT ./target/aarch64-linux-android AS LOCAL ./target/artifacts/aarch64-linux-android
SAVE ARTIFACT ./target/armv7-linux-androideabi AS LOCAL ./target/artifacts/armv7-linux-androideabi
SAVE ARTIFACT ./target/i686-linux-android AS LOCAL ./target/artifacts/i686-linux-android
SAVE ARTIFACT ./target/x86_64-linux-android AS LOCAL ./target/artifacts/x86_64-linux-android
# Unit tests
unit-tests-linux-amd64:
FROM +code
RUN cargo test --target x86_64-unknown-linux-gnu --release
unit-tests-linux-arm64:
FROM +code
RUN cargo test --target aarch64-unknown-linux-gnu --release

View File

@ -20,14 +20,14 @@ cursive_buffered_backend = { path = "../external/cursive_buffered_backend" }
# cursive_tree_view = "0.6.0"
# cursive_table_view = "0.12.0"
# cursive-tabs = "0.5.0"
clap = "^2.33.2"
directories = "^3"
clap = "^3"
directories = "^4"
log = "^0.4"
futures = "^0.3"
serde = "^1.0.122"
serde_derive = "^1.0.122"
parking_lot = "^0.11"
cfg-if = "^0.1"
cfg-if = "^1"
capnp = "^0.14"
capnp-rpc = "^0.14"
config = { version = "0.10.1", features = ["yaml"] }

View File

@ -3,7 +3,7 @@
use anyhow::*;
use async_std::prelude::*;
use clap::{App, Arg};
use clap::{App, Arg, ColorChoice};
use flexi_logger::*;
use log::*;
use std::ffi::OsStr;
@ -22,31 +22,32 @@ pub mod veilid_client_capnp {
fn parse_command_line(default_config_path: &OsStr) -> Result<clap::ArgMatches, anyhow::Error> {
let matches = App::new("veilid-cli")
.version("0.1")
.color(ColorChoice::Auto)
.about("Veilid Console Client")
.arg(
Arg::with_name("address")
Arg::new("address")
.required(false)
.help("Address to connect to"),
)
.arg(
Arg::with_name("debug")
Arg::new("debug")
.long("debug")
.help("Turn on debug logging"),
)
.arg(
Arg::with_name("wait-for-debug")
Arg::new("wait-for-debug")
.long("wait-for-debug")
.help("Wait for debugger to attach"),
)
.arg(
Arg::with_name("trace")
Arg::new("trace")
.long("trace")
.conflicts_with("debug")
.help("Turn on trace logging"),
)
.arg(
Arg::with_name("config-file")
.short("c")
Arg::new("config-file")
.short('c')
.takes_value(true)
.value_name("FILE")
.default_value_os(default_config_path)

View File

@ -18,7 +18,7 @@ capnp = { version = "^0", default_features = false }
rust-fsm = "^0"
static_assertions = "^1"
log = "^0"
cfg-if = "^0"
cfg-if = "^1"
anyhow = "^1"
thiserror = "^1"
@ -31,7 +31,7 @@ serde-big-array = "^0"
futures-util = { version = "^0", default_features = false, features = ["alloc"] }
parking_lot = "^0"
lazy_static = "^1"
directories = "^3"
directories = "^4"
once_cell = "^1"
ed25519-dalek = { version = "^1", default_features = false, features = ["alloc", "u64_backend"] }

View File

@ -33,7 +33,13 @@ impl ProtectedStore {
let c = self.config.get();
let mut inner = self.inner.lock();
if !c.protected_store.always_use_insecure_storage {
inner.keyring_manager = KeyringManager::new_secure(&c.program_name).ok();
cfg_if! {
if #[cfg(target_os = "android")] {
inner.keyring_manager = KeyringManager::new_secure(&c.program_name, intf::native::utils::android::get_android_globals()).ok();
} else {
inner.keyring_manager = KeyringManager::new_secure(&c.program_name).ok();
}
}
}
if (c.protected_store.always_use_insecure_storage
|| c.protected_store.allow_insecure_fallback)

View File

@ -6,7 +6,7 @@ pub fn get_files_dir() -> String {
let ag = aglock.as_ref().unwrap();
let env = ag.vm.attach_current_thread().unwrap();
with_null_local_frame(env, 64, || {
with_null_local_frame(*env, 64, || {
// context.getFilesDir().getAbsolutePath()
let file = env
.call_method(ag.ctx.as_obj(), "getFilesDir", "()Ljava/io/File;", &[])
@ -30,7 +30,7 @@ pub fn get_cache_dir() -> String {
let ag = aglock.as_ref().unwrap();
let env = ag.vm.attach_current_thread().unwrap();
with_null_local_frame(env, 64, || {
with_null_local_frame(*env, 64, || {
// context.getCacheDir().getAbsolutePath()
let file = env
.call_method(ag.ctx.as_obj(), "getCacheDir", "()Ljava/io/File;", &[])
@ -44,7 +44,7 @@ pub fn get_cache_dir() -> String {
.unwrap();
let jstrval = env.get_string(JString::from(path)).unwrap();
String::from(jstrval.to_string_lossy())
Ok(String::from(jstrval.to_string_lossy()))
})
.unwrap()
}

View File

@ -68,6 +68,15 @@ pub fn veilid_core_setup_android<'a>(
});
}
pub fn get_android_globals() -> (JavaVM, GlobalRef) {
let globals_locked = ANDROID_GLOBALS.lock();
let globals = globals_locked.as_ref().unwrap();
let env = globals.vm.attach_current_thread().unwrap();
let vm = env.get_java_vm().unwrap();
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>,

View File

@ -1,6 +1,7 @@
use crate::xx::*;
use crate::*;
use core::fmt;
mod tools;
cfg_if::cfg_if! {
if #[cfg(any(target_os = "linux", target_os = "android"))] {

View File

@ -21,7 +21,7 @@ use tools::*;
fn get_interface_name(index: u32) -> Result<String, String> {
let mut ifnamebuf = [0u8; (IF_NAMESIZE + 1)];
cfg_if! {
if #[cfg(all(target_os = "android", any(target_arch = "arm", target_arch = "aarch64")))] {
if #[cfg(all(any(target_os = "android", target_os="linux"), any(target_arch = "arm", target_arch = "aarch64")))] {
if unsafe { if_indextoname(index, ifnamebuf.as_mut_ptr()) }.is_null() {
return Err("if_indextoname returned null".to_owned());
}

View File

@ -13,17 +13,17 @@ path = "src/main.rs"
[dependencies]
log = "^0"
simplelog = { version = "^0", features = ["test"] }
clap = "^2"
clap = "^3"
async-std = { version = "^1", features = ["unstable"] }
async-tungstenite = { version = "^0", features = ["async-std-runtime", "async-tls"] }
veilid-core = { path = "../veilid-core" }
directories = "^3"
directories = "^4"
capnp = "^0"
parking_lot = "^0"
capnp-rpc = "^0"
config = { version = "^0", features = ["yaml"] }
failure = "^0"
cfg-if = "^0"
cfg-if = "^1"
serde = "^1"
serde_derive = "^1"
serde_yaml = "^0"

View File

@ -17,73 +17,82 @@ use std::time::{Duration, Instant};
use veilid_core::xx::SingleShotEventual;
fn parse_command_line(default_config_path: &OsStr) -> Result<clap::ArgMatches, clap::Error> {
let matches = App::new("veilid-server")
.version("0.1")
.about("Veilid Server")
.color(clap::ColorChoice::Auto)
.arg(
Arg::with_name("daemon")
Arg::new("daemon")
.long("daemon")
.short("d")
.short('d')
.help("Run in daemon mode in the background"),
)
.arg(
Arg::with_name("subnode_index")
.long("subnode_index")
.takes_value(true)
.help("Run as an extra daemon on the same machine for testing purposes, specify a number greater than zero to offset the listening ports"),
)
.arg(
Arg::with_name("debug")
.long("debug")
.help("Turn on debug logging on the terminal"),
)
.arg(
Arg::with_name("trace")
.long("trace")
.conflicts_with("debug")
.help("Turn on trace logging on the terminal"),
)
.arg(
Arg::with_name("generate-id")
.long("generate-id")
.help("Only generate a new node id and print it"),
)
.arg(
Arg::with_name("config-file")
.short("c")
Arg::new("config-file")
.short('c')
.long("config-file")
.takes_value(true)
.value_name("FILE")
.default_value_os(default_config_path)
.help("Specify a configuration file to use"),
)
.arg(
Arg::with_name("dump-config")
.long("dump-config")
.help("Instead of running the server, print the configuration it would use to the console"),
)
.arg(
Arg::with_name("bootstrap")
.long("bootstrap")
.takes_value(true)
.value_name("BOOTSTRAP_LIST")
.help("Specify a list of bootstrap servers to use"),
)
.arg(
Arg::with_name("attach")
).arg(
Arg::new("attach")
.long("attach")
.takes_value(true)
.value_name("BOOL")
.possible_values(&["false", "true"])
.help("Automatically attach the server to the Veilid network"),
)
;
#[cfg(debug_assertions)]
let matches = matches.arg(
Arg::with_name("wait-for-debug")
.long("wait-for-debug")
.help("Wait for debugger to attach"),
);
// Dev options
.arg(
Arg::new("debug")
.long("debug")
.help("Turn on debug logging on the terminal"),
)
.arg(
Arg::new("trace")
.long("trace")
.conflicts_with("debug")
.help("Turn on trace logging on the terminal"),
)
.arg(
Arg::new("subnode_index")
.long("subnode_index")
.takes_value(true)
.help("Run as an extra daemon on the same machine for testing purposes, specify a number greater than zero to offset the listening ports"),
)
.arg(
Arg::new("generate-dht-key")
.long("generate-dht-key")
.help("Only generate a new dht key and print it"),
)
.arg(
Arg::new("dump-config")
.long("dump-config")
.help("Instead of running the server, print the configuration it would use to the console"),
)
.arg(
Arg::new("bootstrap")
.long("bootstrap")
.takes_value(true)
.value_name("BOOTSTRAP_LIST")
.help("Specify a list of bootstrap servers to use"),
)
.arg(
Arg::new("local")
.long("local")
.help("Enable local peer scope")
);
#[cfg(debug_assertions)]
let matches = matches.arg(
Arg::new("wait-for-debug")
.long("wait-for-debug")
.help("Wait for debugger to attach"),
);
Ok(matches.get_matches())
}
@ -163,6 +172,9 @@ pub async fn main() -> Result<(), String> {
if matches.is_present("attach") {
settingsrw.auto_attach = !matches!(matches.value_of("attach"), Some("true"));
}
if matches.is_present("local") {
settingsrw.core.network.enable_local_peer_scope = true;
}
if matches.occurrences_of("bootstrap") != 0 {
let bootstrap = match matches.value_of("bootstrap") {
Some(x) => {