Refactor local crate & update/clean dependencies (#191)

pull/195/head
Chip Senkbeil 12 months ago committed by GitHub
parent 40c265e35b
commit e99329d9a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,18 +38,12 @@ jobs:
toolchain: stable toolchain: stable
components: clippy components: clippy
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
key: "ci-clippy-${{ matrix.os }}"
- name: Check Cargo availability - name: Check Cargo availability
run: cargo --version run: cargo --version
- name: distant-auth (all features) - name: Run clippy (all features)
run: cargo clippy -p distant-auth --all-targets --verbose --all-features run: cargo clippy --workspace --all-targets --verbose --all-features
- name: distant-net (all features)
run: cargo clippy -p distant-net --all-targets --verbose --all-features
- name: distant-core (all features)
run: cargo clippy -p distant-core --all-targets --verbose --all-features
- name: distant-ssh2 (all features)
run: cargo clippy -p distant-ssh2 --all-targets --verbose --all-features
- name: distant (all features)
run: cargo clippy --all-targets --verbose --all-features
rustfmt: rustfmt:
name: "Verify code formatting (${{ matrix.os }})" name: "Verify code formatting (${{ matrix.os }})"
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@ -73,6 +67,8 @@ jobs:
toolchain: stable toolchain: stable
components: rustfmt components: rustfmt
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
key: "ci-rustfmt-${{ matrix.os }}"
- name: Check Cargo availability - name: Check Cargo availability
run: cargo --version run: cargo --version
- run: cargo fmt --all -- --check - run: cargo fmt --all -- --check
@ -102,6 +98,8 @@ jobs:
with: with:
tool: cargo-nextest@0.9.45 tool: cargo-nextest@0.9.45
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
key: "ci-tests-${{ matrix.os }}-${{ matrix.rust }}-${{ matrix.target }}"
- name: Check Cargo availability - name: Check Cargo availability
run: cargo --version run: cargo --version
- uses: nick-fields/retry@v2 - uses: nick-fields/retry@v2
@ -157,58 +155,13 @@ jobs:
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force
} }
- name: Extend Windows retry count to be more resilient - name: Extend Windows retry count to be more resilient
if: matrix.os == 'windows-latest'
run: echo "NEXTEST_RETRIES=9" >> $GITHUB_ENV run: echo "NEXTEST_RETRIES=9" >> $GITHUB_ENV
shell: bash shell: bash
- name: Run auth tests (all features) if: matrix.os == 'windows-latest'
run: cargo nextest run --profile ci --release --all-features -p distant-auth
- name: Run net tests (default features)
run: cargo nextest run --profile ci --release -p distant-net
- name: Build core (default features)
run: cargo build --release -p distant-core
- name: Run core tests (all features)
run: cargo nextest run --profile ci --release --all-features -p distant-core
- name: Ensure /run/sshd exists on Unix - name: Ensure /run/sshd exists on Unix
run: mkdir -p /run/sshd run: mkdir -p /run/sshd
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
- name: Build ssh2 (default features) - name: Run all workspace tests (all features)
run: cargo build --release -p distant-ssh2 run: cargo nextest run --profile ci --release --all-features --workspace
- name: Run ssh2 client tests (all features) - name: Run all doc tests (all features)
run: cargo nextest run --profile ci --release --all-features -p distant-ssh2 ssh2::client run: cargo test --release --all-features --workspace --doc
- name: Build CLI (no default features)
run: cargo build --release --no-default-features
- name: Build CLI (default features)
run: cargo build --release
- name: Run CLI tests (all features)
run: cargo nextest run --profile ci --release --all-features
ssh-launch-tests:
name: "Test ssh launch using Rust ${{ matrix.rust }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: --cfg ci
RUST_LOG: trace
strategy:
fail-fast: false
matrix:
include:
- { rust: stable, os: macos-latest }
- { rust: stable, os: ubuntu-latest }
steps:
- uses: actions/checkout@v3
- name: Install Rust ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
- uses: taiki-e/install-action@v1
with:
tool: cargo-nextest@0.9.45
- uses: Swatinem/rust-cache@v2
- name: Check Cargo availability
run: cargo --version
- name: Install distant cli for use in launch tests
run: |
cargo install --path .
echo "DISTANT_PATH=$HOME/.cargo/bin/distant" >> $GITHUB_ENV
- name: Run ssh2 launch tests (all features)
run: cargo nextest run --profile ci --release --all-features -p distant-ssh2 ssh2::launched

@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Capabilities` message type has been changed to `Version` with new struct to - `Capabilities` message type has been changed to `Version` with new struct to
report the version information that includes a server version string, report the version information that includes a server version string,
protocol version tuple, and capabilities protocol version tuple, and capabilities
- `distant_core::api::local` moved to `distant_local`
### Removed ### Removed

159
Cargo.lock generated

@ -223,9 +223,9 @@ dependencies = [
[[package]] [[package]]
name = "async-once-cell" name = "async-once-cell"
version = "0.4.4" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b49bd4c5b769125ea6323601c39815848972880efd33ffb2d01f9f909adc699" checksum = "fddec5f567375e0a634f94bc8dab1059b9d59a8aba12134c32f5ee21ce3f5f89"
[[package]] [[package]]
name = "async-process" name = "async-process"
@ -474,9 +474,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.2.7" version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -485,9 +485,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.2.7" version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -498,18 +498,18 @@ dependencies = [
[[package]] [[package]]
name = "clap_complete" name = "clap_complete"
version = "4.2.3" version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1594fe2312ec4abf402076e407628f5c313e54c32ade058521df4ee34ecac8a8" checksum = "a04ddfaacc3bc9e6ea67d024575fafc2a813027cf374b8f24f7bc233c6b6be12"
dependencies = [ dependencies = [
"clap", "clap",
] ]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.2.0" version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
@ -519,9 +519,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.4.1" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
[[package]] [[package]]
name = "colorchoice" name = "colorchoice"
@ -820,6 +820,7 @@ dependencies = [
"dialoguer", "dialoguer",
"directories", "directories",
"distant-core", "distant-core",
"distant-local",
"distant-ssh2", "distant-ssh2",
"env_logger", "env_logger",
"file-mode", "file-mode",
@ -866,7 +867,6 @@ dependencies = [
name = "distant-core" name = "distant-core"
version = "0.20.0-alpha.7" version = "0.20.0-alpha.7"
dependencies = [ dependencies = [
"assert_fs",
"async-trait", "async-trait",
"bitflags 2.3.1", "bitflags 2.3.1",
"bytes", "bytes",
@ -875,8 +875,29 @@ dependencies = [
"distant-protocol", "distant-protocol",
"env_logger", "env_logger",
"futures", "futures",
"grep",
"hex", "hex",
"log",
"num_cpus",
"once_cell",
"rand",
"regex",
"serde",
"serde_bytes",
"serde_json",
"strum",
"test-log",
"tokio",
]
[[package]]
name = "distant-local"
version = "0.20.0-alpha.7"
dependencies = [
"assert_fs",
"async-trait",
"distant-core",
"env_logger",
"grep",
"ignore", "ignore",
"indoc", "indoc",
"log", "log",
@ -886,16 +907,10 @@ dependencies = [
"portable-pty 0.8.1", "portable-pty 0.8.1",
"predicates", "predicates",
"rand", "rand",
"regex",
"rstest", "rstest",
"serde",
"serde_bytes",
"serde_json",
"shell-words", "shell-words",
"strum",
"test-log", "test-log",
"tokio", "tokio",
"tokio-util",
"walkdir", "walkdir",
"whoami", "whoami",
"winsplit", "winsplit",
@ -1195,9 +1210,9 @@ dependencies = [
[[package]] [[package]]
name = "flexi_logger" name = "flexi_logger"
version = "0.25.4" version = "0.25.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "611de758a8869ffffa7524aafdb48658c64dae95cdce49654d68a8442e500d89" checksum = "37e7b68b1f7ce9c62856598e99cd6742b9cedb6186b47aa989a82640f20bfa9b"
dependencies = [ dependencies = [
"chrono", "chrono",
"glob", "glob",
@ -1821,12 +1836,9 @@ dependencies = [
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.17" version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
@ -1976,12 +1988,11 @@ dependencies = [
[[package]] [[package]]
name = "nu-ansi-term" name = "nu-ansi-term"
version = "0.46.0" version = "0.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" checksum = "1df031e117bca634c262e9bd3173776844b6c17a90b3741c9163663b4385af76"
dependencies = [ dependencies = [
"overload", "windows-sys 0.45.0",
"winapi",
] ]
[[package]] [[package]]
@ -2026,9 +2037,9 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.17.1" version = "1.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b"
[[package]] [[package]]
name = "opaque-debug" name = "opaque-debug"
@ -2074,12 +2085,6 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]] [[package]]
name = "p256" name = "p256"
version = "0.13.2" version = "0.13.2"
@ -2094,9 +2099,9 @@ dependencies = [
[[package]] [[package]]
name = "papergrid" name = "papergrid"
version = "0.7.1" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1526bb6aa9f10ec339fb10360f22c57edf81d5678d0278e93bc12a47ffbe4b01" checksum = "1fdfe703c51ddc52887ad78fc69cd2ea78d895ffcd6e955c9d03566db8ab5bb1"
dependencies = [ dependencies = [
"bytecount", "bytecount",
"fnv", "fnv",
@ -2557,13 +2562,13 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.8.1" version = "1.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390"
dependencies = [ dependencies = [
"aho-corasick 1.0.1", "aho-corasick 1.0.1",
"memchr", "memchr",
"regex-syntax 0.7.1", "regex-syntax 0.7.2",
] ]
[[package]] [[package]]
@ -2580,9 +2585,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
[[package]] [[package]]
name = "rfc6979" name = "rfc6979"
@ -2793,9 +2798,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
version = "0.6.1" version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -3061,9 +3066,9 @@ dependencies = [
[[package]] [[package]]
name = "sysinfo" name = "sysinfo"
version = "0.28.4" version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c2f3ca6693feb29a89724516f016488e9aafc7f37264f898593ee4b942f31b" checksum = "02f1dc6930a439cc5d154221b5387d153f8183529b07c19aca24ea31e0a167e1"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"core-foundation-sys", "core-foundation-sys",
@ -3076,9 +3081,9 @@ dependencies = [
[[package]] [[package]]
name = "tabled" name = "tabled"
version = "0.10.0" version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c3ee73732ffceaea7b8f6b719ce3bb17f253fa27461ffeaf568ebd0cdb4b85" checksum = "da1a2e56bbf7bfdd08aaa7592157a742205459eff774b73bc01809ae2d99dc2a"
dependencies = [ dependencies = [
"papergrid", "papergrid",
"tabled_derive", "tabled_derive",
@ -3087,9 +3092,9 @@ dependencies = [
[[package]] [[package]]
name = "tabled_derive" name = "tabled_derive"
version = "0.5.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beca1b4eaceb4f2755df858b88d9b9315b7ccfd1ffd0d7a48a52602301f01a57" checksum = "99f688a08b54f4f02f0a3c382aefdb7884d3d69609f785bd253dc033243e3fe4"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -3251,9 +3256,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.28.1" version = "1.28.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"bytes", "bytes",
@ -3279,20 +3284,6 @@ dependencies = [
"syn 2.0.16", "syn 2.0.16",
] ]
[[package]]
name = "tokio-util"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d"
dependencies = [
"bytes",
"futures-core",
"futures-sink",
"pin-project-lite",
"tokio",
"tracing",
]
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.5.11" version = "0.5.11"
@ -3304,18 +3295,18 @@ dependencies = [
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.6.1" version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f"
dependencies = [ dependencies = [
"serde", "serde",
] ]
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.19.8" version = "0.19.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"serde", "serde",
@ -3324,26 +3315,6 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "tracing"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if",
"pin-project-lite",
"tracing-core",
]
[[package]]
name = "tracing-core"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
dependencies = [
"once_cell",
]
[[package]] [[package]]
name = "typed-path" name = "typed-path"
version = "0.3.2" version = "0.3.2"

@ -12,7 +12,14 @@ readme = "README.md"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[workspace] [workspace]
members = ["distant-auth", "distant-core", "distant-net", "distant-protocol", "distant-ssh2"] members = [
"distant-auth",
"distant-core",
"distant-local",
"distant-net",
"distant-protocol",
"distant-ssh2",
]
[profile.release] [profile.release]
opt-level = 'z' opt-level = 'z'
@ -25,30 +32,31 @@ libssh = ["distant-ssh2/libssh"]
ssh2 = ["distant-ssh2/ssh2"] ssh2 = ["distant-ssh2/ssh2"]
[dependencies] [dependencies]
anyhow = "1.0.70" anyhow = "1.0.71"
async-trait = "0.1.68" async-trait = "0.1.68"
clap = { version = "4.2.1", features = ["derive"] } clap = { version = "4.3.0", features = ["derive"] }
clap_complete = "4.2.0" clap_complete = "4.3.0"
config = { version = "0.13.3", default-features = false, features = ["toml"] } config = { version = "0.13.3", default-features = false, features = ["toml"] }
derive_more = { version = "0.99.17", default-features = false, features = ["display", "from", "error", "is_variant"] } derive_more = { version = "0.99.17", default-features = false, features = ["display", "from", "error", "is_variant"] }
dialoguer = { version = "0.10.3", default-features = false } dialoguer = { version = "0.10.4", default-features = false }
distant-core = { version = "=0.20.0-alpha.7", path = "distant-core" } distant-core = { version = "=0.20.0-alpha.7", path = "distant-core" }
directories = "5.0.0" distant-local = { version = "=0.20.0-alpha.7", path = "distant-local" }
directories = "5.0.1"
file-mode = "0.1.2" file-mode = "0.1.2"
flexi_logger = "0.25.3" flexi_logger = "0.25.5"
indoc = "2.0.1" indoc = "2.0.1"
log = "0.4.17" log = "0.4.18"
once_cell = "1.17.1" once_cell = "1.17.2"
rand = { version = "0.8.5", features = ["getrandom"] } rand = { version = "0.8.5", features = ["getrandom"] }
rpassword = "7.2.0" rpassword = "7.2.0"
serde = { version = "1.0.159", features = ["derive"] } serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0.95" serde_json = "1.0.96"
shell-words = "1.1.0" shell-words = "1.1.0"
service-manager = { version = "0.2.0", features = ["clap", "serde"] } service-manager = { version = "0.2.0", features = ["clap", "serde"] }
tabled = "0.10.0" tabled = "0.12.0"
tokio = { version = "1.27.0", features = ["full"] } tokio = { version = "1.28.2", features = ["full"] }
toml_edit = { version = "0.19.8", features = ["serde"] } toml_edit = { version = "0.19.10", features = ["serde"] }
terminal_size = "0.2.5" terminal_size = "0.2.6"
termwiz = "0.20.0" termwiz = "0.20.0"
which = "4.4.0" which = "4.4.0"
winsplit = "0.1.0" winsplit = "0.1.0"
@ -61,14 +69,14 @@ distant-ssh2 = { version = "=0.20.0-alpha.7", path = "distant-ssh2", default-fea
fork = "0.1.21" fork = "0.1.21"
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
sysinfo = "0.28.4" sysinfo = "0.29.0"
windows-service = "0.6.0" windows-service = "0.6.0"
[dev-dependencies] [dev-dependencies]
assert_cmd = "2.0.10" assert_cmd = "2.0.11"
assert_fs = "1.0.12" assert_fs = "1.0.13"
env_logger = "0.10.0" env_logger = "0.10.0"
indoc = "2.0.1" indoc = "2.0.1"
predicates = "3.0.2" predicates = "3.0.3"
rstest = "0.17.0" rstest = "0.17.0"
test-log = "0.2.11" test-log = "0.2.11"

@ -18,10 +18,10 @@ tests = []
[dependencies] [dependencies]
async-trait = "0.1.68" async-trait = "0.1.68"
derive_more = { version = "0.99.17", default-features = false, features = ["display", "from", "error"] } derive_more = { version = "0.99.17", default-features = false, features = ["display", "from", "error"] }
log = "0.4.17" log = "0.4.18"
serde = { version = "1.0.159", features = ["derive"] } serde = { version = "1.0.163", features = ["derive"] }
[dev-dependencies] [dev-dependencies]
env_logger = "0.10.0" env_logger = "0.10.0"
test-log = "0.2.11" test-log = "0.2.11"
tokio = { version = "1.27.0", features = ["full"] } tokio = { version = "1.28.2", features = ["full"] }

@ -9,6 +9,5 @@ pub use methods::*;
#[cfg(any(test, feature = "tests"))] #[cfg(any(test, feature = "tests"))]
pub mod tests { pub mod tests {
pub use crate::TestAuthHandler; pub use crate::{TestAuthHandler, TestAuthenticator};
pub use crate::TestAuthenticator;
} }

@ -121,10 +121,10 @@ pub trait AuthenticationMethod: Send + Sync {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::mpsc; use std::sync::mpsc;
use test_log::test; use test_log::test;
use super::*; use super::*;
use crate::authenticator::TestAuthenticator; use crate::authenticator::TestAuthenticator;
struct SuccessAuthenticationMethod; struct SuccessAuthenticationMethod;

@ -13,37 +13,24 @@ license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
async-trait = "0.1.68" async-trait = "0.1.68"
bitflags = "2.0.2" bitflags = "2.3.1"
bytes = "1.4.0" bytes = "1.4.0"
derive_more = { version = "0.99.17", default-features = false, features = ["as_mut", "as_ref", "deref", "deref_mut", "display", "from", "error", "into", "into_iterator", "is_variant", "try_into"] } derive_more = { version = "0.99.17", default-features = false, features = ["as_mut", "as_ref", "deref", "deref_mut", "display", "from", "error", "into", "into_iterator", "is_variant", "try_into"] }
distant-net = { version = "=0.20.0-alpha.7", path = "../distant-net" } distant-net = { version = "=0.20.0-alpha.7", path = "../distant-net" }
distant-protocol = { version = "=0.20.0-alpha.7", path = "../distant-protocol" } distant-protocol = { version = "=0.20.0-alpha.7", path = "../distant-protocol" }
futures = "0.3.28" futures = "0.3.28"
grep = "0.2.11"
hex = "0.4.3" hex = "0.4.3"
ignore = "0.4.20" log = "0.4.18"
log = "0.4.17"
notify = { version = "6.0.0", features = ["serde"] }
num_cpus = "1.15.0" num_cpus = "1.15.0"
once_cell = "1.17.1" once_cell = "1.17.2"
portable-pty = "0.8.1"
rand = { version = "0.8.5", features = ["getrandom"] } rand = { version = "0.8.5", features = ["getrandom"] }
regex = "1.7.3" regex = "1.8.3"
serde = { version = "1.0.159", features = ["derive"] } serde = { version = "1.0.163", features = ["derive"] }
serde_bytes = "0.11.9" serde_bytes = "0.11.9"
serde_json = "1.0.95" serde_json = "1.0.96"
shell-words = "1.1.0"
strum = { version = "0.24.1", features = ["derive"] } strum = { version = "0.24.1", features = ["derive"] }
tokio = { version = "1.27.0", features = ["full"] } tokio = { version = "1.28.2", features = ["full"] }
tokio-util = { version = "0.7.7", features = ["codec"] }
walkdir = "2.3.3"
whoami = "1.4.0"
winsplit = "0.1.0"
[dev-dependencies] [dev-dependencies]
assert_fs = "1.0.12"
env_logger = "0.10.0" env_logger = "0.10.0"
indoc = "2.0.1"
predicates = "3.0.2"
rstest = "0.17.0"
test-log = "0.2.11" test-log = "0.2.11"

@ -12,9 +12,6 @@ use crate::protocol::{
SearchId, SearchQuery, SetPermissionsOptions, SystemInfo, Version, SearchId, SearchQuery, SetPermissionsOptions, SystemInfo, Version,
}; };
mod local;
pub use local::LocalDistantApi;
mod reply; mod reply;
use reply::DistantSingleReply; use reply::DistantSingleReply;
@ -42,15 +39,6 @@ where
} }
} }
impl DistantApiServerHandler<LocalDistantApi, <LocalDistantApi as DistantApi>::LocalData> {
/// Creates a new server using the [`LocalDistantApi`] implementation
pub fn local() -> io::Result<Self> {
Ok(Self {
api: LocalDistantApi::initialize()?,
})
}
}
#[inline] #[inline]
fn unsupported<T>(label: &str) -> io::Result<T> { fn unsupported<T>(label: &str) -> io::Result<T> {
Err(io::Error::new( Err(io::Error::new(

@ -5,9 +5,8 @@ use distant_net::client::Mailbox;
use distant_net::common::{Request, Response}; use distant_net::common::{Request, Response};
use log::*; use log::*;
use tokio::io; use tokio::io;
use tokio::sync::mpsc;
use tokio::sync::mpsc::error::{TryRecvError, TrySendError}; use tokio::sync::mpsc::error::{TryRecvError, TrySendError};
use tokio::sync::RwLock; use tokio::sync::{mpsc, RwLock};
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use crate::client::DistantChannel; use crate::client::DistantChannel;

@ -1,5 +1,3 @@
use std::time::Duration;
/// Capacity associated stdin, stdout, and stderr pipes receiving data from remote server /// Capacity associated stdin, stdout, and stderr pipes receiving data from remote server
pub const CLIENT_PIPE_CAPACITY: usize = 10000; pub const CLIENT_PIPE_CAPACITY: usize = 10000;
@ -8,16 +6,3 @@ pub const CLIENT_WATCHER_CAPACITY: usize = 100;
/// Capacity associated with a client searcher receiving matches /// Capacity associated with a client searcher receiving matches
pub const CLIENT_SEARCHER_CAPACITY: usize = 10000; pub const CLIENT_SEARCHER_CAPACITY: usize = 10000;
/// Capacity associated with the server's file watcher to pass events outbound
pub const SERVER_WATCHER_CAPACITY: usize = 10000;
/// Represents the maximum size (in bytes) that data will be read from pipes
/// per individual `read` call
///
/// Current setting is 16k size
pub const MAX_PIPE_CHUNK_SIZE: usize = 16384;
/// Duration in milliseconds to sleep between reading stdout/stderr chunks
/// to avoid sending many small messages to clients
pub const READ_PAUSE_DURATION: Duration = Duration::from_millis(1);

@ -12,6 +12,5 @@ mod serde_str;
/// Network functionality. /// Network functionality.
pub use distant_net as net; pub use distant_net as net;
/// Protocol structures. /// Protocol structures.
pub use distant_protocol as protocol; pub use distant_protocol as protocol;

@ -0,0 +1,36 @@
[package]
name = "distant-local"
description = "Library implementing distant API for local interactions"
categories = ["network-programming"]
version = "0.20.0-alpha.7"
authors = ["Chip Senkbeil <chip@senkbeil.org>"]
edition = "2021"
homepage = "https://github.com/chipsenkbeil/distant"
repository = "https://github.com/chipsenkbeil/distant"
readme = "README.md"
license = "MIT OR Apache-2.0"
[dependencies]
async-trait = "0.1.68"
distant-core = { version = "=0.20.0-alpha.7", path = "../distant-core" }
grep = "0.2.12"
ignore = "0.4.20"
log = "0.4.18"
notify = { version = "6.0.0", features = ["serde"] }
num_cpus = "1.15.0"
portable-pty = "0.8.1"
rand = { version = "0.8.5", features = ["getrandom"] }
shell-words = "1.1.0"
tokio = { version = "1.28.2", features = ["full"] }
walkdir = "2.3.3"
whoami = "1.4.0"
winsplit = "0.1.0"
[dev-dependencies]
assert_fs = "1.0.13"
env_logger = "0.10.0"
indoc = "2.0.1"
once_cell = "1.17.2"
predicates = "3.0.3"
rstest = "0.17.0"
test-log = "0.2.11"

@ -3,17 +3,16 @@ use std::time::SystemTime;
use std::{env, io}; use std::{env, io};
use async_trait::async_trait; use async_trait::async_trait;
use ignore::{DirEntry as WalkDirEntry, WalkBuilder}; use distant_core::protocol::{
use log::*;
use tokio::io::AsyncWriteExt;
use walkdir::WalkDir;
use crate::protocol::{
Capabilities, ChangeKind, ChangeKindSet, DirEntry, Environment, FileType, Metadata, Capabilities, ChangeKind, ChangeKindSet, DirEntry, Environment, FileType, Metadata,
Permissions, ProcessId, PtySize, SearchId, SearchQuery, SetPermissionsOptions, SystemInfo, Permissions, ProcessId, PtySize, SearchId, SearchQuery, SetPermissionsOptions, SystemInfo,
Version, PROTOCOL_VERSION, Version, PROTOCOL_VERSION,
}; };
use crate::{DistantApi, DistantCtx}; use distant_core::{DistantApi, DistantCtx};
use ignore::{DirEntry as WalkDirEntry, WalkBuilder};
use log::*;
use tokio::io::AsyncWriteExt;
use walkdir::WalkDir;
mod process; mod process;
@ -23,7 +22,7 @@ use state::*;
/// Represents an implementation of [`DistantApi`] that works with the local machine /// Represents an implementation of [`DistantApi`] that works with the local machine
/// where the server using this api is running. In other words, this is a direct /// where the server using this api is running. In other words, this is a direct
/// impementation of the API instead of a proxy to another machine as seen with /// impementation of the API instead of a proxy to another machine as seen with
/// implementations on top of SSH and other protocol /// implementations on top of SSH and other protocol.
pub struct LocalDistantApi { pub struct LocalDistantApi {
state: GlobalState, state: GlobalState,
} }
@ -451,7 +450,7 @@ impl DistantApi for LocalDistantApi {
unix: Some({ unix: Some({
use std::os::unix::prelude::*; use std::os::unix::prelude::*;
let mode = metadata.mode(); let mode = metadata.mode();
crate::protocol::UnixMetadata::from(mode) distant_core::protocol::UnixMetadata::from(mode)
}), }),
#[cfg(not(unix))] #[cfg(not(unix))]
unix: None, unix: None,
@ -460,7 +459,7 @@ impl DistantApi for LocalDistantApi {
windows: Some({ windows: Some({
use std::os::windows::prelude::*; use std::os::windows::prelude::*;
let attributes = metadata.file_attributes(); let attributes = metadata.file_attributes();
crate::protocol::WindowsMetadata::from(attributes) distant_core::protocol::WindowsMetadata::from(attributes)
}), }),
#[cfg(not(windows))] #[cfg(not(windows))]
windows: None, windows: None,
@ -702,15 +701,14 @@ mod tests {
use std::time::Duration; use std::time::Duration;
use assert_fs::prelude::*; use assert_fs::prelude::*;
use distant_net::server::Reply; use distant_core::net::server::{ConnectionCtx, Reply};
use distant_core::protocol::Response;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use predicates::prelude::*; use predicates::prelude::*;
use test_log::test; use test_log::test;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use super::*; use super::*;
use crate::api::ConnectionCtx;
use crate::protocol::Response;
static TEMP_SCRIPT_DIR: Lazy<assert_fs::TempDir> = static TEMP_SCRIPT_DIR: Lazy<assert_fs::TempDir> =
Lazy::new(|| assert_fs::TempDir::new().unwrap()); Lazy::new(|| assert_fs::TempDir::new().unwrap());

@ -1,11 +1,10 @@
use std::future::Future; use std::future::Future;
use std::pin::Pin; use std::pin::Pin;
use distant_core::protocol::{ProcessId, PtySize};
use tokio::io; use tokio::io;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use crate::protocol::{ProcessId, PtySize};
mod pty; mod pty;
pub use pty::*; pub use pty::*;

@ -3,6 +3,7 @@ use std::io::{self, Read, Write};
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::{Arc, Mutex, Weak}; use std::sync::{Arc, Mutex, Weak};
use distant_core::protocol::Environment;
use log::*; use log::*;
use portable_pty::{CommandBuilder, MasterPty, PtySize as PortablePtySize}; use portable_pty::{CommandBuilder, MasterPty, PtySize as PortablePtySize};
use tokio::sync::mpsc; use tokio::sync::mpsc;
@ -13,7 +14,6 @@ use super::{
ProcessPty, PtySize, WaitRx, ProcessPty, PtySize, WaitRx,
}; };
use crate::constants::{MAX_PIPE_CHUNK_SIZE, READ_PAUSE_DURATION}; use crate::constants::{MAX_PIPE_CHUNK_SIZE, READ_PAUSE_DURATION};
use crate::protocol::Environment;
/// Represents a process that is associated with a pty /// Represents a process that is associated with a pty
pub struct PtyProcess { pub struct PtyProcess {

@ -2,6 +2,7 @@ use std::ffi::OsStr;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Stdio; use std::process::Stdio;
use distant_core::protocol::Environment;
use log::*; use log::*;
use tokio::io; use tokio::io;
use tokio::process::Command; use tokio::process::Command;
@ -12,7 +13,6 @@ use super::{
wait, ExitStatus, FutureReturn, InputChannel, NoProcessPty, OutputChannel, Process, ProcessId, wait, ExitStatus, FutureReturn, InputChannel, NoProcessPty, OutputChannel, Process, ProcessId,
ProcessKiller, WaitRx, ProcessKiller, WaitRx,
}; };
use crate::protocol::Environment;
mod tasks; mod tasks;

@ -3,12 +3,11 @@ use std::io;
use std::ops::Deref; use std::ops::Deref;
use std::path::PathBuf; use std::path::PathBuf;
use distant_net::server::Reply; use distant_core::net::server::Reply;
use distant_core::protocol::{Environment, ProcessId, PtySize, Response};
use tokio::sync::{mpsc, oneshot}; use tokio::sync::{mpsc, oneshot};
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use crate::protocol::{Environment, ProcessId, PtySize, Response};
mod instance; mod instance;
pub use instance::*; pub use instance::*;

@ -2,14 +2,14 @@ use std::future::Future;
use std::io; use std::io;
use std::path::PathBuf; use std::path::PathBuf;
use distant_net::server::Reply; use distant_core::net::server::Reply;
use distant_core::protocol::{Environment, ProcessId, PtySize, Response};
use log::*; use log::*;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use crate::api::local::process::{ use crate::api::process::{
InputChannel, OutputChannel, Process, ProcessKiller, ProcessPty, PtyProcess, SimpleProcess, InputChannel, OutputChannel, Process, ProcessKiller, ProcessPty, PtyProcess, SimpleProcess,
}; };
use crate::protocol::{Environment, ProcessId, PtySize, Response};
/// Holds information related to a spawned process on the server /// Holds information related to a spawned process on the server
pub struct ProcessInstance { pub struct ProcessInstance {

@ -3,7 +3,12 @@ use std::ops::Deref;
use std::path::Path; use std::path::Path;
use std::{cmp, io}; use std::{cmp, io};
use distant_net::server::Reply; use distant_core::net::server::Reply;
use distant_core::protocol::{
Response, SearchId, SearchQuery, SearchQueryContentsMatch, SearchQueryMatch,
SearchQueryMatchData, SearchQueryOptions, SearchQueryPathMatch, SearchQuerySubmatch,
SearchQueryTarget,
};
use grep::matcher::Matcher; use grep::matcher::Matcher;
use grep::regex::{RegexMatcher, RegexMatcherBuilder}; use grep::regex::{RegexMatcher, RegexMatcherBuilder};
use grep::searcher::{BinaryDetection, Searcher, SearcherBuilder, Sink, SinkMatch}; use grep::searcher::{BinaryDetection, Searcher, SearcherBuilder, Sink, SinkMatch};
@ -13,12 +18,6 @@ use log::*;
use tokio::sync::{broadcast, mpsc, oneshot}; use tokio::sync::{broadcast, mpsc, oneshot};
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use crate::protocol::{
Response, SearchId, SearchQuery, SearchQueryContentsMatch, SearchQueryMatch,
SearchQueryMatchData, SearchQueryOptions, SearchQueryPathMatch, SearchQuerySubmatch,
SearchQueryTarget,
};
const MAXIMUM_SEARCH_THREADS: usize = 12; const MAXIMUM_SEARCH_THREADS: usize = 12;
/// Holds information related to active searches on the server /// Holds information related to active searches on the server
@ -807,10 +806,10 @@ mod tests {
use std::path::PathBuf; use std::path::PathBuf;
use assert_fs::prelude::*; use assert_fs::prelude::*;
use distant_core::protocol::{FileType, SearchQueryCondition, SearchQueryMatchData};
use test_log::test; use test_log::test;
use super::*; use super::*;
use crate::protocol::{FileType, SearchQueryCondition, SearchQueryMatchData};
fn make_path(path: &str) -> PathBuf { fn make_path(path: &str) -> PathBuf {
use std::path::MAIN_SEPARATOR; use std::path::MAIN_SEPARATOR;

@ -3,20 +3,19 @@ use std::io;
use std::ops::Deref; use std::ops::Deref;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use distant_net::common::ConnectionId; use distant_core::net::common::ConnectionId;
use distant_core::protocol::ChangeKind;
use log::*; use log::*;
use notify::event::{AccessKind, AccessMode, ModifyKind}; use notify::event::{AccessKind, AccessMode, ModifyKind};
use notify::{ use notify::{
Config as WatcherConfig, Error as WatcherError, ErrorKind as WatcherErrorKind, Config as WatcherConfig, Error as WatcherError, ErrorKind as WatcherErrorKind,
Event as WatcherEvent, EventKind, PollWatcher, RecursiveMode, Watcher, Event as WatcherEvent, EventKind, PollWatcher, RecursiveMode, Watcher,
}; };
use tokio::sync::mpsc;
use tokio::sync::mpsc::error::TrySendError; use tokio::sync::mpsc::error::TrySendError;
use tokio::sync::oneshot; use tokio::sync::{mpsc, oneshot};
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use crate::constants::SERVER_WATCHER_CAPACITY; use crate::constants::SERVER_WATCHER_CAPACITY;
use crate::protocol::ChangeKind;
mod path; mod path;
pub use path::*; pub use path::*;

@ -2,10 +2,9 @@ use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::{fmt, io}; use std::{fmt, io};
use distant_net::common::ConnectionId; use distant_core::net::common::ConnectionId;
use distant_net::server::Reply; use distant_core::net::server::Reply;
use distant_core::protocol::{Change, ChangeKind, ChangeKindSet, Error, Response};
use crate::protocol::{Change, ChangeKind, ChangeKindSet, Error, Response};
/// Represents a path registered with a watcher that includes relevant state including /// Represents a path registered with a watcher that includes relevant state including
/// the ability to reply with /// the ability to reply with

@ -0,0 +1,14 @@
use std::time::Duration;
/// Capacity associated with the server's file watcher to pass events outbound
pub const SERVER_WATCHER_CAPACITY: usize = 10000;
/// Represents the maximum size (in bytes) that data will be read from pipes
/// per individual `read` call
///
/// Current setting is 16k size
pub const MAX_PIPE_CHUNK_SIZE: usize = 16384;
/// Duration in milliseconds to sleep between reading stdout/stderr chunks
/// to avoid sending many small messages to clients
pub const READ_PAUSE_DURATION: Duration = Duration::from_millis(1);

@ -0,0 +1,15 @@
mod api;
mod constants;
pub use api::LocalDistantApi;
use distant_core::{DistantApi, DistantApiServerHandler};
/// Implementation of [`DistantApiServerHandler`] using [`LocalDistantApi`].
pub type LocalDistantApiServerHandler =
DistantApiServerHandler<LocalDistantApi, <LocalDistantApi as DistantApi>::LocalData>;
/// Initializes a new [`LocalDistantApiServerHandler`].
pub fn initialize_handler() -> std::io::Result<LocalDistantApiServerHandler> {
Ok(LocalDistantApiServerHandler::new(
LocalDistantApi::initialize()?,
))
}

@ -5,7 +5,8 @@ use distant_core::net::auth::{DummyAuthHandler, Verifier};
use distant_core::net::client::{Client, TcpConnector}; use distant_core::net::client::{Client, TcpConnector};
use distant_core::net::common::PortRange; use distant_core::net::common::PortRange;
use distant_core::net::server::Server; use distant_core::net::server::Server;
use distant_core::{DistantApiServerHandler, DistantClient, LocalDistantApi}; use distant_core::{DistantApiServerHandler, DistantClient};
use distant_local::LocalDistantApi;
use rstest::*; use rstest::*;
use tokio::sync::mpsc; use tokio::sync::mpsc;

@ -18,23 +18,23 @@ chacha20poly1305 = "0.10.1"
derive_more = { version = "0.99.17", default-features = false, features = ["as_mut", "as_ref", "deref", "deref_mut", "display", "from", "error", "into", "into_iterator", "is_variant", "try_into"] } derive_more = { version = "0.99.17", default-features = false, features = ["as_mut", "as_ref", "deref", "deref_mut", "display", "from", "error", "into", "into_iterator", "is_variant", "try_into"] }
distant-auth = { version = "=0.20.0-alpha.7", path = "../distant-auth" } distant-auth = { version = "=0.20.0-alpha.7", path = "../distant-auth" }
dyn-clone = "1.0.11" dyn-clone = "1.0.11"
flate2 = "1.0.25" flate2 = "1.0.26"
hex = "0.4.3" hex = "0.4.3"
hkdf = "0.12.3" hkdf = "0.12.3"
log = "0.4.17" log = "0.4.18"
paste = "1.0.12" paste = "1.0.12"
p256 = { version = "0.13.0", features = ["ecdh", "pem"] } p256 = { version = "0.13.2", features = ["ecdh", "pem"] }
rand = { version = "0.8.5", features = ["getrandom"] } rand = { version = "0.8.5", features = ["getrandom"] }
rmp-serde = "1.1.1" rmp-serde = "1.1.1"
sha2 = "0.10.6" sha2 = "0.10.6"
serde = { version = "1.0.159", features = ["derive"] } serde = { version = "1.0.163", features = ["derive"] }
serde_bytes = "0.11.9" serde_bytes = "0.11.9"
strum = { version = "0.24.1", features = ["derive"] } strum = { version = "0.24.1", features = ["derive"] }
tokio = { version = "1.27.0", features = ["full"] } tokio = { version = "1.28.2", features = ["full"] }
[dev-dependencies] [dev-dependencies]
distant-auth = { version = "=0.20.0-alpha.7", path = "../distant-auth", features = ["tests"] } distant-auth = { version = "=0.20.0-alpha.7", path = "../distant-auth", features = ["tests"] }
env_logger = "0.10.0" env_logger = "0.10.0"
serde_json = "1.0.95" serde_json = "1.0.96"
tempfile = "3.5.0" tempfile = "3.5.0"
test-log = "0.2.11" test-log = "0.2.11"

@ -1,10 +1,11 @@
use crate::common::utils; use std::io;
use crate::common::{FramedTransport, Transport};
use async_trait::async_trait; use async_trait::async_trait;
use distant_auth::msg::*; use distant_auth::msg::*;
use distant_auth::{AuthHandler, Authenticate, Authenticator}; use distant_auth::{AuthHandler, Authenticate, Authenticator};
use log::*; use log::*;
use std::io;
use crate::common::{utils, FramedTransport, Transport};
macro_rules! write_frame { macro_rules! write_frame {
($transport:expr, $data:expr) => {{ ($transport:expr, $data:expr) => {{

@ -9,8 +9,7 @@ use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::{InmemoryTransport, Interest, Ready, Reconnectable, Transport}; use super::{InmemoryTransport, Interest, Ready, Reconnectable, Transport};
use crate::common::utils; use crate::common::{utils, SecretKey32};
use crate::common::SecretKey32;
mod backup; mod backup;
mod codec; mod codec;

@ -5,8 +5,7 @@ pub mod manager;
pub mod server; pub mod server;
pub use client::{Client, ReconnectStrategy}; pub use client::{Client, ReconnectStrategy};
pub use server::Server;
pub use {log, paste};
/// Authentication functionality tied to network operations. /// Authentication functionality tied to network operations.
pub use distant_auth as auth; pub use distant_auth as auth;
pub use server::Server;
pub use {log, paste};

@ -16,10 +16,10 @@ default = []
tests = [] tests = []
[dependencies] [dependencies]
bitflags = "2.0.2" bitflags = "2.3.1"
derive_more = { version = "0.99.17", default-features = false, features = ["deref", "deref_mut", "display", "from", "error", "into", "into_iterator", "is_variant"] } derive_more = { version = "0.99.17", default-features = false, features = ["deref", "deref_mut", "display", "from", "error", "into", "into_iterator", "is_variant"] }
regex = "1.7.3" regex = "1.8.3"
serde = { version = "1.0.159", features = ["derive"] } serde = { version = "1.0.163", features = ["derive"] }
serde_bytes = "0.11.9" serde_bytes = "0.11.9"
strum = { version = "0.24.1", features = ["derive"] } strum = { version = "0.24.1", features = ["derive"] }

@ -96,6 +96,7 @@ impl Permissions {
other_exec: None, other_exec: None,
} }
} }
/// Creates a set of [`Permissions`] that indicate globally writable status. /// Creates a set of [`Permissions`] that indicate globally writable status.
/// ///
/// ``` /// ```

@ -612,9 +612,10 @@ mod tests {
} }
mod changed { mod changed {
use std::path::PathBuf;
use super::*; use super::*;
use crate::common::ChangeKind; use crate::common::ChangeKind;
use std::path::PathBuf;
#[test] #[test]
fn should_be_able_to_serialize_to_json() { fn should_be_able_to_serialize_to_json() {
@ -742,9 +743,10 @@ mod tests {
} }
mod metadata { mod metadata {
use std::path::PathBuf;
use super::*; use super::*;
use crate::common::{FileType, UnixMetadata, WindowsMetadata}; use crate::common::{FileType, UnixMetadata, WindowsMetadata};
use std::path::PathBuf;
#[test] #[test]
fn should_be_able_to_serialize_minimal_payload_to_json() { fn should_be_able_to_serialize_minimal_payload_to_json() {
@ -1219,9 +1221,10 @@ mod tests {
} }
mod search_results { mod search_results {
use std::path::PathBuf;
use super::*; use super::*;
use crate::common::{SearchQueryContentsMatch, SearchQueryMatch, SearchQuerySubmatch}; use crate::common::{SearchQueryContentsMatch, SearchQueryMatch, SearchQuerySubmatch};
use std::path::PathBuf;
#[test] #[test]
fn should_be_able_to_serialize_to_json() { fn should_be_able_to_serialize_to_json() {
@ -1768,9 +1771,10 @@ mod tests {
} }
mod system_info { mod system_info {
use super::*;
use std::path::PathBuf; use std::path::PathBuf;
use super::*;
#[test] #[test]
fn should_be_able_to_serialize_to_json() { fn should_be_able_to_serialize_to_json() {
let payload = Response::SystemInfo(SystemInfo { let payload = Response::SystemInfo(SystemInfo {

@ -17,33 +17,33 @@ ssh2 = ["wezterm-ssh/ssh2", "wezterm-ssh/vendored-openssl-ssh2"]
[dependencies] [dependencies]
async-compat = "0.2.1" async-compat = "0.2.1"
async-once-cell = "0.4.4" async-once-cell = "0.5.2"
async-trait = "0.1.68" async-trait = "0.1.68"
derive_more = { version = "0.99.17", default-features = false, features = ["display", "error"] } derive_more = { version = "0.99.17", default-features = false, features = ["display", "error"] }
distant-core = { version = "=0.20.0-alpha.7", path = "../distant-core" } distant-core = { version = "=0.20.0-alpha.7", path = "../distant-core" }
futures = "0.3.28" futures = "0.3.28"
hex = "0.4.3" hex = "0.4.3"
log = "0.4.17" log = "0.4.18"
rand = { version = "0.8.5", features = ["getrandom"] } rand = { version = "0.8.5", features = ["getrandom"] }
rpassword = "7.2.0" rpassword = "7.2.0"
shell-words = "1.1.0" shell-words = "1.1.0"
smol = "1.3.0" smol = "1.3.0"
tokio = { version = "1.27.0", features = ["full"] } tokio = { version = "1.28.2", features = ["full"] }
typed-path = "0.3.2" typed-path = "0.3.2"
wezterm-ssh = { version = "0.4.0", default-features = false } wezterm-ssh = { version = "0.4.0", default-features = false }
winsplit = "0.1.0" winsplit = "0.1.0"
# Optional serde support for data structures # Optional serde support for data structures
serde = { version = "1.0.159", features = ["derive"], optional = true } serde = { version = "1.0.163", features = ["derive"], optional = true }
[dev-dependencies] [dev-dependencies]
anyhow = "1.0.70" anyhow = "1.0.71"
assert_fs = "1.0.12" assert_fs = "1.0.13"
dunce = "1.0.3" dunce = "1.0.4"
env_logger = "0.10.0" env_logger = "0.10.0"
indoc = "2.0.1" indoc = "2.0.1"
once_cell = "1.17.1" once_cell = "1.17.2"
predicates = "3.0.2" predicates = "3.0.3"
rstest = "0.17.0" rstest = "0.17.0"
test-log = "0.2.11" test-log = "0.2.11"
which = "4.4.0" which = "4.4.0"

File diff suppressed because it is too large Load Diff

@ -1,3 +1,2 @@
mod client; mod client;
mod launched;
mod ssh; mod ssh;

@ -15,7 +15,7 @@ use assert_fs::TempDir;
use async_trait::async_trait; use async_trait::async_trait;
use derive_more::{Deref, DerefMut, Display}; use derive_more::{Deref, DerefMut, Display};
use distant_core::DistantClient; use distant_core::DistantClient;
use distant_ssh2::{DistantLaunchOpts, Ssh, SshAuthEvent, SshAuthHandler, SshOpts}; use distant_ssh2::{Ssh, SshAuthEvent, SshAuthHandler, SshOpts};
use log::*; use log::*;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use rstest::*; use rstest::*;
@ -638,38 +638,6 @@ pub async fn client(sshd: Sshd) -> Ctx<DistantClient> {
} }
} }
/// Fixture to establish a client to a launched server
#[fixture]
pub async fn launched_client(sshd: Sshd) -> Ctx<DistantClient> {
let binary = std::env::var("DISTANT_PATH").unwrap_or_else(|_| String::from("distant"));
debug!("Setting path to distant binary as {binary}");
// Attempt to launch the server and connect to it, using $DISTANT_PATH as the path to the
// binary if provided, defaulting to assuming the binary is on our ssh path otherwise
//
// NOTE: Wrapping in ctx does not fully clean up the test as the launched distant server
// is not cleaned up during drop. We don't know what the server's pid is, so our
// only option would be to look up all running distant servers and kill them on drop,
// but that would cause other tests to fail.
//
// Setting an expiration of 1s would clean up running servers and possibly be good enough
let ssh_client = load_ssh_client(&sshd).await;
let mut client = ssh_client
.launch_and_connect(DistantLaunchOpts {
binary,
args: "--shutdown lonely=10".to_string(),
..Default::default()
})
.await
.context("Failed to launch and connect to distant server")
.unwrap();
client.shutdown_on_drop(true);
Ctx {
sshd,
value: client,
}
}
/// Access to raw [`Ssh`] client /// Access to raw [`Ssh`] client
#[fixture] #[fixture]
pub async fn ssh(sshd: Sshd) -> Ctx<Ssh> { pub async fn ssh(sshd: Sshd) -> Ctx<Ssh> {

@ -13,9 +13,10 @@ use distant_core::protocol::{
use distant_core::{DistantChannel, DistantChannelExt, RemoteCommand, Searcher, Watcher}; use distant_core::{DistantChannel, DistantChannelExt, RemoteCommand, Searcher, Watcher};
use log::*; use log::*;
use serde_json::json; use serde_json::json;
use tabled::object::Rows; use tabled::settings::object::Rows;
use tabled::style::Style; use tabled::settings::style::Style;
use tabled::{Alignment, Disable, Modify, Table, Tabled}; use tabled::settings::{Alignment, Disable, Modify};
use tabled::{Table, Tabled};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use crate::cli::common::{ use crate::cli::common::{

@ -8,9 +8,10 @@ use distant_core::protocol::{
SearchQueryPathMatch, SystemInfo, SearchQueryPathMatch, SystemInfo,
}; };
use log::*; use log::*;
use tabled::object::Rows; use tabled::settings::object::Rows;
use tabled::style::Style; use tabled::settings::style::Style;
use tabled::{Alignment, Disable, Modify, Table, Tabled}; use tabled::settings::{Alignment, Disable, Modify};
use tabled::{Table, Tabled};
use crate::options::Format; use crate::options::Format;

@ -4,7 +4,7 @@ use anyhow::Context;
use distant_core::net::auth::Verifier; use distant_core::net::auth::Verifier;
use distant_core::net::common::{Host, SecretKey32}; use distant_core::net::common::{Host, SecretKey32};
use distant_core::net::server::{Server, ServerConfig as NetServerConfig, ServerRef}; use distant_core::net::server::{Server, ServerConfig as NetServerConfig, ServerRef};
use distant_core::{DistantApiServerHandler, DistantSingleKeyCredentials}; use distant_core::DistantSingleKeyCredentials;
use log::*; use log::*;
use crate::options::ServerSubcommand; use crate::options::ServerSubcommand;
@ -140,8 +140,8 @@ async fn async_run(cmd: ServerSubcommand, _is_forked: bool) -> CliResult {
"using an ephemeral port".to_string() "using an ephemeral port".to_string()
} }
); );
let handler = let handler = distant_local::initialize_handler()
DistantApiServerHandler::local().context("Failed to create local distant api")?; .context("Failed to create local distant api")?;
let server = Server::tcp() let server = Server::tcp()
.config(NetServerConfig { .config(NetServerConfig {
shutdown: shutdown.into_inner(), shutdown: shutdown.into_inner(),

@ -3981,6 +3981,7 @@ mod tests {
ManagerServiceSubcommand::Install { ManagerServiceSubcommand::Install {
kind: None, kind: None,
user: false, user: false,
args: Vec::new(),
}, },
)), )),
}; };
@ -4008,6 +4009,7 @@ mod tests {
ManagerServiceSubcommand::Install { ManagerServiceSubcommand::Install {
kind: None, kind: None,
user: false, user: false,
args: Vec::new(),
}, },
)), )),
} }
@ -4026,6 +4028,7 @@ mod tests {
ManagerServiceSubcommand::Install { ManagerServiceSubcommand::Install {
kind: None, kind: None,
user: false, user: false,
args: Vec::new(),
}, },
)), )),
}; };
@ -4053,6 +4056,7 @@ mod tests {
ManagerServiceSubcommand::Install { ManagerServiceSubcommand::Install {
kind: None, kind: None,
user: false, user: false,
args: Vec::new(),
}, },
)), )),
} }

@ -8,7 +8,7 @@ use crate::cli::utils::TrimmedLinesMatchPredicate;
#[test_log::test] #[test_log::test]
fn should_output_capabilities(ctx: DistantManagerCtx) { fn should_output_capabilities(ctx: DistantManagerCtx) {
// Because all of our crates have the same version, we can expect it to match // Because all of our crates have the same version, we can expect it to match
let package_name = "distant-core"; let package_name = "distant-local";
let package_version = env!("CARGO_PKG_VERSION"); let package_version = env!("CARGO_PKG_VERSION");
let (major, minor, patch) = PROTOCOL_VERSION; let (major, minor, patch) = PROTOCOL_VERSION;

@ -3,9 +3,10 @@ use ::predicates::prelude::*;
mod predicates; mod predicates;
mod reader; mod reader;
pub use self::predicates::TrimmedLinesMatchPredicate;
pub use reader::ThreadedReader; pub use reader::ThreadedReader;
pub use self::predicates::TrimmedLinesMatchPredicate;
/// Produces a regex predicate using the given string /// Produces a regex predicate using the given string
pub fn regex_pred(s: &str) -> ::predicates::str::RegexPredicate { pub fn regex_pred(s: &str) -> ::predicates::str::RegexPredicate {
predicate::str::is_match(s).unwrap() predicate::str::is_match(s).unwrap()

@ -1,6 +1,7 @@
use std::fmt;
use predicates::reflection::PredicateReflection; use predicates::reflection::PredicateReflection;
use predicates::Predicate; use predicates::Predicate;
use std::fmt;
/// Checks if lines of text match the provided, trimming each line /// Checks if lines of text match the provided, trimming each line
/// of both before comparing. /// of both before comparing.

Loading…
Cancel
Save