mirror of
https://github.com/EasyTier/EasyTier.git
synced 2024-11-16 11:42:27 +08:00
make release bin smaller (#127)
This commit is contained in:
parent
abf9d23d52
commit
f1e9864d08
12
.github/workflows/core.yml
vendored
12
.github/workflows/core.yml
vendored
|
@ -85,11 +85,21 @@ jobs:
|
||||||
- name: Build Core & Cli
|
- name: Build Core & Cli
|
||||||
run: |
|
run: |
|
||||||
if [[ $OS =~ ^ubuntu.*$ && $TARGET =~ ^mips.*$ ]]; then
|
if [[ $OS =~ ^ubuntu.*$ && $TARGET =~ ^mips.*$ ]]; then
|
||||||
cargo +nightly build -r --verbose --target $TARGET -Z build-std --no-default-features --features mips
|
cargo +nightly build -r --verbose --target $TARGET -Z build-std=std,panic_abort --no-default-features --features mips
|
||||||
else
|
else
|
||||||
cargo build --release --verbose --target $TARGET
|
cargo build --release --verbose --target $TARGET
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Run UPX
|
||||||
|
if: ${{ matrix.OS != 'macos-latest' }}
|
||||||
|
uses: crazy-max/ghaction-upx@v3
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
files: |
|
||||||
|
./target/$TARGET/release/easytier-core*
|
||||||
|
./target/$TARGET/release/easytier-cli*
|
||||||
|
args: -9
|
||||||
|
|
||||||
- name: Compress
|
- name: Compress
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./artifacts/objects/
|
mkdir -p ./artifacts/objects/
|
||||||
|
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
@ -62,6 +62,6 @@ jobs:
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
sudo -E env "PATH=$PATH" cargo test --verbose
|
sudo -E env "PATH=$PATH" cargo test --no-default-features --features=full --verbose
|
||||||
sudo chown -R $USER:$USER ./target
|
sudo chown -R $USER:$USER ./target
|
||||||
sudo chown -R $USER:$USER ~/.cargo
|
sudo chown -R $USER:$USER ~/.cargo
|
||||||
|
|
257
Cargo.lock
generated
257
Cargo.lock
generated
|
@ -685,7 +685,7 @@ dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"clap_lex",
|
"clap_lex",
|
||||||
"strsim 0.11.1",
|
"strsim",
|
||||||
"terminal_size",
|
"terminal_size",
|
||||||
"unicase",
|
"unicase",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
|
@ -1004,38 +1004,14 @@ dependencies = [
|
||||||
"syn 2.0.65",
|
"syn 2.0.65",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "darling"
|
|
||||||
version = "0.10.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858"
|
|
||||||
dependencies = [
|
|
||||||
"darling_core 0.10.2",
|
|
||||||
"darling_macro 0.10.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling"
|
name = "darling"
|
||||||
version = "0.20.9"
|
version = "0.20.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1"
|
checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core 0.20.9",
|
"darling_core",
|
||||||
"darling_macro 0.20.9",
|
"darling_macro",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "darling_core"
|
|
||||||
version = "0.10.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b"
|
|
||||||
dependencies = [
|
|
||||||
"fnv",
|
|
||||||
"ident_case",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"strsim 0.9.3",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1048,28 +1024,17 @@ dependencies = [
|
||||||
"ident_case",
|
"ident_case",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"strsim 0.11.1",
|
"strsim",
|
||||||
"syn 2.0.65",
|
"syn 2.0.65",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "darling_macro"
|
|
||||||
version = "0.10.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
|
|
||||||
dependencies = [
|
|
||||||
"darling_core 0.10.2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling_macro"
|
name = "darling_macro"
|
||||||
version = "0.20.9"
|
version = "0.20.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178"
|
checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core 0.20.9",
|
"darling_core",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.65",
|
"syn 2.0.65",
|
||||||
]
|
]
|
||||||
|
@ -1087,12 +1052,6 @@ dependencies = [
|
||||||
"parking_lot_core",
|
"parking_lot_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "data-encoding"
|
|
||||||
version = "2.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "defguard_wireguard_rs"
|
name = "defguard_wireguard_rs"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
|
@ -1134,31 +1093,6 @@ dependencies = [
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "derive_builder"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a2658621297f2cf68762a6f7dc0bb7e1ff2cfd6583daef8ee0fed6f7ec468ec0"
|
|
||||||
dependencies = [
|
|
||||||
"darling 0.10.2",
|
|
||||||
"derive_builder_core",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "derive_builder_core"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2791ea3e372c8495c0bc2033991d76b512cd799d07491fbd6890124db9458bef"
|
|
||||||
dependencies = [
|
|
||||||
"darling 0.10.2",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_more"
|
name = "derive_more"
|
||||||
version = "0.99.17"
|
version = "0.99.17"
|
||||||
|
@ -1220,18 +1154,6 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
|
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dns-lookup"
|
|
||||||
version = "1.0.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "53ecafc952c4528d9b51a458d1a8904b81783feff9fde08ab6ed2545ff396872"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"socket2 0.4.10",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dtoa"
|
name = "dtoa"
|
||||||
version = "1.0.9"
|
version = "1.0.9"
|
||||||
|
@ -1296,7 +1218,6 @@ dependencies = [
|
||||||
"pnet",
|
"pnet",
|
||||||
"postcard",
|
"postcard",
|
||||||
"prost",
|
"prost",
|
||||||
"public-ip",
|
|
||||||
"quinn",
|
"quinn",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"rcgen",
|
"rcgen",
|
||||||
|
@ -1306,7 +1227,7 @@ dependencies = [
|
||||||
"rustls",
|
"rustls",
|
||||||
"serde",
|
"serde",
|
||||||
"serial_test",
|
"serial_test",
|
||||||
"socket2 0.5.7",
|
"socket2",
|
||||||
"stun_codec",
|
"stun_codec",
|
||||||
"tabled",
|
"tabled",
|
||||||
"tachyonix",
|
"tachyonix",
|
||||||
|
@ -1456,24 +1377,6 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "endian-type"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "enum-as-inner"
|
|
||||||
version = "0.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "570d109b813e904becc80d8d5da38376818a143348413f7149f1340fe04754d4"
|
|
||||||
dependencies = [
|
|
||||||
"heck 0.4.1",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -2212,27 +2115,13 @@ dependencies = [
|
||||||
"httpdate",
|
"httpdate",
|
||||||
"itoa 1.0.11",
|
"itoa 1.0.11",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"socket2 0.5.7",
|
"socket2",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"tracing",
|
"tracing",
|
||||||
"want",
|
"want",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hyper-system-resolver"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6eea26c5d0b6ab9d72219f65000af310f042a740926f7b2fa3553e774036e2e7"
|
|
||||||
dependencies = [
|
|
||||||
"derive_builder",
|
|
||||||
"dns-lookup",
|
|
||||||
"hyper",
|
|
||||||
"tokio",
|
|
||||||
"tower-service",
|
|
||||||
"tracing",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper-timeout"
|
name = "hyper-timeout"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
@ -2297,17 +2186,6 @@ version = "1.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "idna"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
|
|
||||||
dependencies = [
|
|
||||||
"matches",
|
|
||||||
"unicode-bidi",
|
|
||||||
"unicode-normalization",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
@ -2941,15 +2819,6 @@ version = "1.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nibble_vec"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43"
|
|
||||||
dependencies = [
|
|
||||||
"smallvec",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.25.1"
|
version = "0.25.1"
|
||||||
|
@ -3793,27 +3662,6 @@ dependencies = [
|
||||||
"prost",
|
"prost",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "public-ip"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7b4c40db5262d93298c363a299f8bc1b3a956a78eecddba3bc0e58b76e2f419a"
|
|
||||||
dependencies = [
|
|
||||||
"dns-lookup",
|
|
||||||
"futures-core",
|
|
||||||
"futures-util",
|
|
||||||
"http 0.2.12",
|
|
||||||
"hyper",
|
|
||||||
"hyper-system-resolver",
|
|
||||||
"pin-project-lite",
|
|
||||||
"thiserror",
|
|
||||||
"tokio",
|
|
||||||
"tracing",
|
|
||||||
"tracing-futures",
|
|
||||||
"trust-dns-client",
|
|
||||||
"trust-dns-proto",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-xml"
|
name = "quick-xml"
|
||||||
version = "0.31.0"
|
version = "0.31.0"
|
||||||
|
@ -3866,7 +3714,7 @@ checksum = "cb7ad7bc932e4968523fa7d9c320ee135ff779de720e9350fee8728838551764"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"socket2 0.5.7",
|
"socket2",
|
||||||
"tracing",
|
"tracing",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
@ -3880,16 +3728,6 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "radix_trie"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd"
|
|
||||||
dependencies = [
|
|
||||||
"endian-type",
|
|
||||||
"nibble_vec",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.7.3"
|
version = "0.7.3"
|
||||||
|
@ -4489,7 +4327,7 @@ version = "3.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2"
|
checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling 0.20.9",
|
"darling",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.65",
|
"syn 2.0.65",
|
||||||
|
@ -4619,16 +4457,6 @@ version = "1.13.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "socket2"
|
|
||||||
version = "0.4.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
version = "0.5.7"
|
version = "0.5.7"
|
||||||
|
@ -4729,12 +4557,6 @@ dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "strsim"
|
|
||||||
version = "0.9.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
|
@ -5310,7 +5132,7 @@ dependencies = [
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"socket2 0.5.7",
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
@ -5588,18 +5410,6 @@ dependencies = [
|
||||||
"valuable",
|
"valuable",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tracing-futures"
|
|
||||||
version = "0.2.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
|
|
||||||
dependencies = [
|
|
||||||
"futures",
|
|
||||||
"futures-task",
|
|
||||||
"pin-project",
|
|
||||||
"tracing",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-log"
|
name = "tracing-log"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -5672,51 +5482,6 @@ dependencies = [
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "trust-dns-client"
|
|
||||||
version = "0.20.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5b4ef9b9bde0559b78a4abb00339143750085f05e5a453efb7b8bef1061f09dc"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"data-encoding",
|
|
||||||
"futures-channel",
|
|
||||||
"futures-util",
|
|
||||||
"lazy_static",
|
|
||||||
"log",
|
|
||||||
"radix_trie",
|
|
||||||
"rand 0.8.5",
|
|
||||||
"thiserror",
|
|
||||||
"time",
|
|
||||||
"tokio",
|
|
||||||
"trust-dns-proto",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "trust-dns-proto"
|
|
||||||
version = "0.20.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ca94d4e9feb6a181c690c4040d7a24ef34018d8313ac5044a61d21222ae24e31"
|
|
||||||
dependencies = [
|
|
||||||
"async-trait",
|
|
||||||
"cfg-if",
|
|
||||||
"data-encoding",
|
|
||||||
"enum-as-inner",
|
|
||||||
"futures-channel",
|
|
||||||
"futures-io",
|
|
||||||
"futures-util",
|
|
||||||
"idna 0.2.3",
|
|
||||||
"ipnet",
|
|
||||||
"lazy_static",
|
|
||||||
"log",
|
|
||||||
"rand 0.8.5",
|
|
||||||
"smallvec",
|
|
||||||
"thiserror",
|
|
||||||
"tinyvec",
|
|
||||||
"tokio",
|
|
||||||
"url",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "try-lock"
|
name = "try-lock"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
|
@ -5818,7 +5583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
|
checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"form_urlencoded",
|
"form_urlencoded",
|
||||||
"idna 0.5.0",
|
"idna",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -7,9 +7,7 @@ default-members = ["easytier"]
|
||||||
panic = "unwind"
|
panic = "unwind"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = "unwind"
|
panic = "abort"
|
||||||
# panic = "abort"
|
lto = true
|
||||||
# lto = true
|
codegen-units = 1
|
||||||
# codegen-units = 1
|
strip = true
|
||||||
# strip = true
|
|
||||||
# opt-level = "z"
|
|
||||||
|
|
|
@ -126,7 +126,6 @@ rand = "0.8.5"
|
||||||
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
pnet = { version = "0.34.0", features = ["serde"] }
|
pnet = { version = "0.34.0", features = ["serde"] }
|
||||||
public-ip = { version = "0.2", features = ["default"] }
|
|
||||||
|
|
||||||
clap = { version = "4.4.8", features = ["unicode", "derive", "wrap_help"] }
|
clap = { version = "4.4.8", features = ["unicode", "derive", "wrap_help"] }
|
||||||
|
|
||||||
|
@ -181,10 +180,17 @@ defguard_wireguard_rs = "0.4.2"
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["wireguard", "quic", "mimalloc", "websocket"]
|
default = ["wireguard", "mimalloc", "websocket"]
|
||||||
|
full = ["quic", "websocket", "wireguard", "mimalloc", "aes-gcm"]
|
||||||
mips = ["aes-gcm", "mimalloc", "wireguard"]
|
mips = ["aes-gcm", "mimalloc", "wireguard"]
|
||||||
wireguard = ["dep:boringtun", "dep:ring"]
|
wireguard = ["dep:boringtun", "dep:ring"]
|
||||||
quic = ["dep:quinn", "dep:rustls", "dep:rcgen"]
|
quic = ["dep:quinn", "dep:rustls", "dep:rcgen"]
|
||||||
mimalloc = ["dep:mimalloc-rust"]
|
mimalloc = ["dep:mimalloc-rust"]
|
||||||
aes-gcm = ["dep:aes-gcm"]
|
aes-gcm = ["dep:aes-gcm"]
|
||||||
websocket = ["dep:tokio-websockets", "dep:http", "dep:tokio-rustls"]
|
websocket = [
|
||||||
|
"dep:tokio-websockets",
|
||||||
|
"dep:http",
|
||||||
|
"dep:tokio-rustls",
|
||||||
|
"dep:rustls",
|
||||||
|
"dep:rcgen",
|
||||||
|
]
|
||||||
|
|
|
@ -88,6 +88,8 @@ impl GlobalCtx {
|
||||||
|
|
||||||
let (event_bus, _) = tokio::sync::broadcast::channel(100);
|
let (event_bus, _) = tokio::sync::broadcast::channel(100);
|
||||||
|
|
||||||
|
let stun_info_collection = Arc::new(StunInfoCollector::new_with_default_servers());
|
||||||
|
|
||||||
GlobalCtx {
|
GlobalCtx {
|
||||||
inst_name: config_fs.get_inst_name(),
|
inst_name: config_fs.get_inst_name(),
|
||||||
id,
|
id,
|
||||||
|
@ -99,11 +101,11 @@ impl GlobalCtx {
|
||||||
cached_ipv4: AtomicCell::new(None),
|
cached_ipv4: AtomicCell::new(None),
|
||||||
cached_proxy_cidrs: AtomicCell::new(None),
|
cached_proxy_cidrs: AtomicCell::new(None),
|
||||||
|
|
||||||
ip_collector: Arc::new(IPCollector::new(net_ns)),
|
ip_collector: Arc::new(IPCollector::new(net_ns, stun_info_collection.clone())),
|
||||||
|
|
||||||
hostname,
|
hostname,
|
||||||
|
|
||||||
stun_info_collection: Box::new(StunInfoCollector::new_with_default_servers()),
|
stun_info_collection: Box::new(stun_info_collection),
|
||||||
|
|
||||||
running_listeners: Mutex::new(Vec::new()),
|
running_listeners: Mutex::new(Vec::new()),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{ops::Deref, sync::Arc};
|
use std::{net::IpAddr, ops::Deref, sync::Arc};
|
||||||
|
|
||||||
use crate::rpc::peer::GetIpListResponse;
|
use crate::rpc::peer::GetIpListResponse;
|
||||||
use pnet::datalink::NetworkInterface;
|
use pnet::datalink::NetworkInterface;
|
||||||
|
@ -7,7 +7,7 @@ use tokio::{
|
||||||
task::JoinSet,
|
task::JoinSet,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::netns::NetNS;
|
use super::{netns::NetNS, stun::StunInfoCollectorTrait};
|
||||||
|
|
||||||
pub const CACHED_IP_LIST_TIMEOUT_SEC: u64 = 60;
|
pub const CACHED_IP_LIST_TIMEOUT_SEC: u64 = 60;
|
||||||
|
|
||||||
|
@ -142,14 +142,16 @@ pub struct IPCollector {
|
||||||
cached_ip_list: Arc<RwLock<GetIpListResponse>>,
|
cached_ip_list: Arc<RwLock<GetIpListResponse>>,
|
||||||
collect_ip_task: Mutex<JoinSet<()>>,
|
collect_ip_task: Mutex<JoinSet<()>>,
|
||||||
net_ns: NetNS,
|
net_ns: NetNS,
|
||||||
|
stun_info_collector: Arc<Box<dyn StunInfoCollectorTrait>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IPCollector {
|
impl IPCollector {
|
||||||
pub fn new(net_ns: NetNS) -> Self {
|
pub fn new<T: StunInfoCollectorTrait + 'static>(net_ns: NetNS, stun_info_collector: T) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cached_ip_list: Arc::new(RwLock::new(GetIpListResponse::new())),
|
cached_ip_list: Arc::new(RwLock::new(GetIpListResponse::new())),
|
||||||
collect_ip_task: Mutex::new(JoinSet::new()),
|
collect_ip_task: Mutex::new(JoinSet::new()),
|
||||||
net_ns,
|
net_ns,
|
||||||
|
stun_info_collector: Arc::new(Box::new(stun_info_collector)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,16 +160,41 @@ impl IPCollector {
|
||||||
if task.is_empty() {
|
if task.is_empty() {
|
||||||
let cached_ip_list = self.cached_ip_list.clone();
|
let cached_ip_list = self.cached_ip_list.clone();
|
||||||
*cached_ip_list.write().await =
|
*cached_ip_list.write().await =
|
||||||
Self::do_collect_ip_addrs(false, self.net_ns.clone()).await;
|
Self::do_collect_local_ip_addrs(self.net_ns.clone()).await;
|
||||||
let net_ns = self.net_ns.clone();
|
let net_ns = self.net_ns.clone();
|
||||||
|
let stun_info_collector = self.stun_info_collector.clone();
|
||||||
task.spawn(async move {
|
task.spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
let ip_addrs = Self::do_collect_ip_addrs(true, net_ns.clone()).await;
|
let ip_addrs = Self::do_collect_local_ip_addrs(net_ns.clone()).await;
|
||||||
*cached_ip_list.write().await = ip_addrs;
|
*cached_ip_list.write().await = ip_addrs;
|
||||||
tokio::time::sleep(std::time::Duration::from_secs(CACHED_IP_LIST_TIMEOUT_SEC))
|
tokio::time::sleep(std::time::Duration::from_secs(CACHED_IP_LIST_TIMEOUT_SEC))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let cached_ip_list = self.cached_ip_list.clone();
|
||||||
|
task.spawn(async move {
|
||||||
|
loop {
|
||||||
|
let stun_info = stun_info_collector.get_stun_info();
|
||||||
|
for ip in stun_info.public_ip.iter() {
|
||||||
|
let Ok(ip_addr) = ip.parse::<IpAddr>() else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
if ip_addr.is_ipv4() {
|
||||||
|
cached_ip_list.write().await.public_ipv4 = ip.clone();
|
||||||
|
} else {
|
||||||
|
cached_ip_list.write().await.public_ipv6 = ip.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sleep_sec = if !cached_ip_list.read().await.public_ipv4.is_empty() {
|
||||||
|
CACHED_IP_LIST_TIMEOUT_SEC
|
||||||
|
} else {
|
||||||
|
3
|
||||||
|
};
|
||||||
|
tokio::time::sleep(std::time::Duration::from_secs(sleep_sec)).await;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.cached_ip_list.read().await.deref().clone();
|
return self.cached_ip_list.read().await.deref().clone();
|
||||||
|
@ -193,21 +220,9 @@ impl IPCollector {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(net_ns))]
|
#[tracing::instrument(skip(net_ns))]
|
||||||
async fn do_collect_ip_addrs(with_public: bool, net_ns: NetNS) -> GetIpListResponse {
|
async fn do_collect_local_ip_addrs(net_ns: NetNS) -> GetIpListResponse {
|
||||||
let mut ret = crate::rpc::peer::GetIpListResponse::new();
|
let mut ret = crate::rpc::peer::GetIpListResponse::new();
|
||||||
|
|
||||||
if with_public {
|
|
||||||
if let Some(v4_addr) =
|
|
||||||
public_ip::addr_with(public_ip::http::ALL, public_ip::Version::V4).await
|
|
||||||
{
|
|
||||||
ret.public_ipv4 = v4_addr.to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(v6_addr) = public_ip::addr_v6().await {
|
|
||||||
ret.public_ipv6 = v6_addr.to_string();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let ifaces = Self::collect_interfaces(net_ns.clone()).await;
|
let ifaces = Self::collect_interfaces(net_ns.clone()).await;
|
||||||
let _g = net_ns.guard();
|
let _g = net_ns.guard();
|
||||||
for iface in ifaces {
|
for iface in ifaces {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user