Compare commits

...

3 Commits

Author SHA1 Message Date
ea85aa1b76 修改peerMap的竞态条件 2026-07-04 16:08:01 +08:00
03151cc90e in tun, should .await in eee.device.send 2026-07-04 15:20:10 +08:00
0a40eac55e loop for 3 times for connect api 2026-07-04 15:15:08 +08:00
10 changed files with 93 additions and 512 deletions

View File

@ -1,5 +1,5 @@
{
// "rust-analyzer.cargo.target": "x86_64-pc-windows-gnu",
// "rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu",
"rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu",
// "rust-analyzer.cargo.features": ["tun"]
}

480
Cargo.lock generated
View File

@ -45,12 +45,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "android_system_properties"
version = "0.1.5"
@ -105,7 +99,7 @@ version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys 0.61.2",
"windows-sys 0.60.2",
]
[[package]]
@ -116,7 +110,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys 0.61.2",
"windows-sys 0.60.2",
]
[[package]]
@ -164,15 +158,6 @@ version = "4.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
[[package]]
name = "atoi"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528"
dependencies = [
"num-traits",
]
[[package]]
name = "atomic-waker"
version = "1.1.2"
@ -218,12 +203,6 @@ dependencies = [
"fs_extra",
]
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64"
version = "0.22.1"
@ -247,9 +226,6 @@ name = "bitflags"
version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
dependencies = [
"serde_core",
]
[[package]]
name = "block-buffer"
@ -648,15 +624,6 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.21"
@ -859,12 +826,6 @@ dependencies = [
"windows-sys 0.60.2",
]
[[package]]
name = "dotenvy"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
[[package]]
name = "dunce"
version = "1.0.5"
@ -876,9 +837,6 @@ name = "either"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
dependencies = [
"serde",
]
[[package]]
name = "elf"
@ -930,18 +888,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.61.2",
]
[[package]]
name = "etcetera"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943"
dependencies = [
"cfg-if",
"home",
"windows-sys 0.48.0",
"windows-sys 0.52.0",
]
[[package]]
@ -953,12 +900,6 @@ dependencies = [
"arrayvec",
]
[[package]]
name = "event-listener"
version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]]
name = "event-listener"
version = "5.4.1"
@ -976,7 +917,7 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93"
dependencies = [
"event-listener 5.4.1",
"event-listener",
"pin-project-lite",
]
@ -1024,17 +965,6 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flume"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095"
dependencies = [
"futures-core",
"futures-sink",
"spin",
]
[[package]]
name = "flume"
version = "0.12.0"
@ -1116,17 +1046,6 @@ dependencies = [
"futures-util",
]
[[package]]
name = "futures-intrusive"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f"
dependencies = [
"futures-core",
"lock_api",
"parking_lot",
]
[[package]]
name = "futures-io"
version = "0.3.32"
@ -1267,10 +1186,6 @@ name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
"allocator-api2",
]
[[package]]
name = "hashbrown"
@ -1287,15 +1202,6 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
[[package]]
name = "hashlink"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7"
dependencies = [
"hashbrown 0.14.5",
]
[[package]]
name = "heck"
version = "0.3.3"
@ -1305,15 +1211,6 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "heck"
version = "0.5.0"
@ -1335,15 +1232,6 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hkdf"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
dependencies = [
"hmac",
]
[[package]]
name = "hmac"
version = "0.12.1"
@ -1353,15 +1241,6 @@ dependencies = [
"digest",
]
[[package]]
name = "home"
version = "0.5.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d"
dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "hostname"
version = "0.4.2"
@ -1456,7 +1335,7 @@ version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0"
dependencies = [
"base64 0.22.1",
"base64",
"bytes",
"futures-channel",
"futures-util",
@ -1485,7 +1364,7 @@ dependencies = [
"js-sys",
"log",
"wasm-bindgen",
"windows-core 0.62.2",
"windows-core 0.61.2",
]
[[package]]
@ -1780,17 +1659,6 @@ dependencies = [
"redox_syscall 0.7.3",
]
[[package]]
name = "libsqlite3-sys"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716"
dependencies = [
"cc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "linux-raw-sys"
version = "0.12.1"
@ -1877,12 +1745,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "mio"
version = "1.1.1"
@ -2066,16 +1928,6 @@ dependencies = [
"memoffset",
]
[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]]
name = "ntapi"
version = "0.4.3"
@ -2091,7 +1943,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys 0.61.2",
"windows-sys 0.59.0",
]
[[package]]
@ -2491,7 +2343,7 @@ dependencies = [
[[package]]
name = "punchnet"
version = "1.2.5"
version = "1.2.6"
dependencies = [
"ahash",
"arc-swap",
@ -2759,7 +2611,7 @@ version = "0.12.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"
dependencies = [
"base64 0.22.1",
"base64",
"bytes",
"futures-core",
"http",
@ -2824,7 +2676,7 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "319bb478ff9aae1dc7a544fa599e9eb47e2521621dc3921fba6abcaaa312092c"
dependencies = [
"flume 0.12.0",
"flume",
"libc",
"netlink-packet-core 0.8.1",
"netlink-packet-route 0.28.0",
@ -2889,7 +2741,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.61.2",
"windows-sys 0.52.0",
]
[[package]]
@ -2957,7 +2809,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
"windows-sys 0.61.2",
"windows-sys 0.52.0",
]
[[package]]
@ -3017,7 +2869,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "sdlan-sn-rs"
version = "0.1.0"
source = "git+https://gitea.s5s8.com/punchnet/sdlan-rs.git#8e93a4224be025b0a6557e2bfd885aeb467b37ab"
source = "git+https://gitea.s5s8.com/punchnet/sdlan-rs.git#1bd479df7287e4486a42a67d7ae954c180845338"
dependencies = [
"aes",
"byteorder",
@ -3032,7 +2884,6 @@ dependencies = [
"serde",
"serde_json",
"serde_repr",
"sqlx",
"tokio",
"tracing",
"tracing-appender",
@ -3143,28 +2994,6 @@ dependencies = [
"serde",
]
[[package]]
name = "sha1"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "sha2"
version = "0.10.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "sharded-slab"
version = "0.1.7"
@ -3240,7 +3069,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
dependencies = [
"libc",
"windows-sys 0.61.2",
"windows-sys 0.60.2",
]
[[package]]
@ -3262,223 +3091,12 @@ dependencies = [
"der",
]
[[package]]
name = "sqlformat"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bba3a93db0cc4f7bdece8bb09e77e2e785c20bfebf79eb8340ed80708048790"
dependencies = [
"nom",
"unicode_categories",
]
[[package]]
name = "sqlx"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9a2ccff1a000a5a59cd33da541d9f2fdcd9e6e8229cc200565942bff36d0aaa"
dependencies = [
"sqlx-core",
"sqlx-macros",
"sqlx-mysql",
"sqlx-postgres",
"sqlx-sqlite",
]
[[package]]
name = "sqlx-core"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24ba59a9342a3d9bab6c56c118be528b27c9b60e490080e9711a04dccac83ef6"
dependencies = [
"ahash",
"atoi",
"byteorder",
"bytes",
"crc",
"crossbeam-queue",
"either",
"event-listener 2.5.3",
"futures-channel",
"futures-core",
"futures-intrusive",
"futures-io",
"futures-util",
"hashlink",
"hex",
"indexmap",
"log",
"memchr",
"once_cell",
"paste",
"percent-encoding",
"serde",
"serde_json",
"sha2",
"smallvec",
"sqlformat",
"thiserror 1.0.69",
"tracing",
"url",
]
[[package]]
name = "sqlx-macros"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ea40e2345eb2faa9e1e5e326db8c34711317d2b5e08d0d5741619048a803127"
dependencies = [
"proc-macro2",
"quote",
"sqlx-core",
"sqlx-macros-core",
"syn 1.0.109",
]
[[package]]
name = "sqlx-macros-core"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5833ef53aaa16d860e92123292f1f6a3d53c34ba8b1969f152ef1a7bb803f3c8"
dependencies = [
"dotenvy",
"either",
"heck 0.4.1",
"hex",
"once_cell",
"proc-macro2",
"quote",
"serde",
"serde_json",
"sha2",
"sqlx-core",
"sqlx-mysql",
"sqlx-sqlite",
"syn 1.0.109",
"tempfile",
"url",
]
[[package]]
name = "sqlx-mysql"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ed31390216d20e538e447a7a9b959e06ed9fc51c37b514b46eb758016ecd418"
dependencies = [
"atoi",
"base64 0.21.7",
"bitflags 2.11.0",
"byteorder",
"bytes",
"crc",
"digest",
"dotenvy",
"either",
"futures-channel",
"futures-core",
"futures-io",
"futures-util",
"generic-array",
"hex",
"hkdf",
"hmac",
"itoa",
"log",
"md-5",
"memchr",
"once_cell",
"percent-encoding",
"rand 0.8.5",
"rsa",
"serde",
"sha1",
"sha2",
"smallvec",
"sqlx-core",
"stringprep",
"thiserror 1.0.69",
"tracing",
"whoami",
]
[[package]]
name = "sqlx-postgres"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c824eb80b894f926f89a0b9da0c7f435d27cdd35b8c655b114e58223918577e"
dependencies = [
"atoi",
"base64 0.21.7",
"bitflags 2.11.0",
"byteorder",
"crc",
"dotenvy",
"etcetera",
"futures-channel",
"futures-core",
"futures-io",
"futures-util",
"hex",
"hkdf",
"hmac",
"home",
"itoa",
"log",
"md-5",
"memchr",
"once_cell",
"rand 0.8.5",
"serde",
"serde_json",
"sha2",
"smallvec",
"sqlx-core",
"stringprep",
"thiserror 1.0.69",
"tracing",
"whoami",
]
[[package]]
name = "sqlx-sqlite"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b244ef0a8414da0bed4bb1910426e890b19e5e9bccc27ada6b797d05c55ae0aa"
dependencies = [
"atoi",
"flume 0.11.1",
"futures-channel",
"futures-core",
"futures-executor",
"futures-intrusive",
"futures-util",
"libsqlite3-sys",
"log",
"percent-encoding",
"serde",
"sqlx-core",
"tracing",
"url",
"urlencoding",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
[[package]]
name = "stringprep"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1"
dependencies = [
"unicode-bidi",
"unicode-normalization",
"unicode-properties",
]
[[package]]
name = "strsim"
version = "0.8.0"
@ -3628,7 +3246,7 @@ dependencies = [
"getrandom 0.4.2",
"once_cell",
"rustix",
"windows-sys 0.61.2",
"windows-sys 0.52.0",
]
[[package]]
@ -4010,33 +3628,12 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
[[package]]
name = "unicode-bidi"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
[[package]]
name = "unicode-ident"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
[[package]]
name = "unicode-normalization"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-properties"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d"
[[package]]
name = "unicode-segmentation"
version = "1.12.0"
@ -4055,12 +3652,6 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]]
name = "unicode_categories"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
[[package]]
name = "universal-hash"
version = "0.5.1"
@ -4089,12 +3680,6 @@ dependencies = [
"serde",
]
[[package]]
name = "urlencoding"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]]
name = "utf8_iter"
version = "1.0.4"
@ -4124,12 +3709,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vec_map"
version = "0.8.2"
@ -4185,12 +3764,6 @@ dependencies = [
"wit-bindgen",
]
[[package]]
name = "wasite"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
[[package]]
name = "wasm-bindgen"
version = "0.2.114"
@ -4322,16 +3895,6 @@ dependencies = [
"rustls-pki-types",
]
[[package]]
name = "whoami"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d"
dependencies = [
"libredox",
"wasite",
]
[[package]]
name = "widestring"
version = "1.2.1"
@ -4360,7 +3923,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.61.2",
"windows-sys 0.52.0",
]
[[package]]
@ -4587,15 +4150,6 @@ dependencies = [
"windows-targets 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
@ -4915,7 +4469,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10"
dependencies = [
"cfg-if",
"windows-sys 0.61.2",
"windows-sys 0.59.0",
]
[[package]]

View File

@ -1,6 +1,6 @@
[package]
name = "punchnet"
version = "1.2.5"
version = "1.2.6"
edition = "2021"
license = "MIT"
description = "punchnet client"
@ -81,7 +81,7 @@ assets = [
["target/release/punchnet", "usr/local/punchnet/punchnet", "755"],
["punchnet.service", "etc/systemd/system/punchnet.service", "755"],
# lib
["libtuntap.so", "usr/lib/", "755"],
# ["libtuntap.so", "usr/lib/", "755"],
]
maintainer-scripts = "debian"

View File

@ -34,8 +34,8 @@ libtun-musl:
rm libtuntap.* && touch libtuntap.so && cd src/network && musl-gcc -c tuntap.c -o libtuntap.o && ar rcs libtuntap.a libtuntap.o && cp libtuntap.a ../.. && cd -
deb-musl: libtun-musl
RUSTFLAGS="-L ." cargo deb --target x86_64-unknown-linux-musl --deb-revision="1-static"
deb-musl:
cargo deb --target x86_64-unknown-linux-musl --deb-revision="2-static"
deb: libtun-so
RUSTFLAGS="-L ." cargo deb --deb-revision="1-dynamic"
@ -43,3 +43,5 @@ deb: libtun-so
deb-aarch64-musl: libtun-aarch64-musl
RUSTFLAGS="-L ." cargo deb --target aarch64-unknown-linux-musl --deb-revision="1-static"
deb-aarch64:
cargo deb --target aarch64-unknown-linux-musl --deb-revision="2-static"

View File

@ -1,12 +1,12 @@
[Unit]
Description=punchnet client
Before=network.target network.service
Wants=network.target
After=network.target network.service
Requires=network.target
[Service]
Type=simple
WorkingDirectory=/usr/local/punchnet
ExecStart=/usr/local/punchnet/punchnet start
ExecStart=/usr/local/punchnet/punchnet start -f
[Install]
WantedBy=multi-user.target

View File

@ -4,6 +4,7 @@ use reqwest::Client;
use sdlan_sn_rs::utils::{Mac, Result, SDLanError};
use serde::{Deserialize, Serialize};
use md5::Md5;
use tracing::warn;
pub const TEST_PREFIX: &'static str = "https://root.punchsky.com/api";
@ -153,35 +154,46 @@ where T: Serialize + HMacCalculator,
return Err(SDLanError::IOError("failed to calculate hmac".to_owned()));
};
let response = match client
.post(url)
.header("X-sign", hmac)
.json(&data)
.send()
.await {
let mut retry_times = 0;
let mut response_ok = false;
loop {
let response = match client
.post(url)
.header("X-sign", hmac.clone())
.json(&data)
.send()
.await {
Ok(response) => {
response_ok = true;
response
}
Err(e) => {
retry_times += 1;
if retry_times > 3 {
return Err(SDLanError::IOError(format!("failed to do request: {}", e)));
}
warn!("retry connecting api in 5 seconds");
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
continue;
}
};
Ok(response) => {
response
}
// println!("status: {}", response.status());
// let text = response.text().await.unwrap();
let text = match response.text().await {
Ok(text) => text,
Err(e) => {
return Err(SDLanError::IOError(format!("failed to do request: {}", e)));
return Err(SDLanError::IOError(format!("failed to get response text: {}", e)))
}
};
};
// println!("status: {}", response.status());
// let text = response.text().await.unwrap();
let text = match response.text().await {
Ok(text) => text,
Err(e) => {
return Err(SDLanError::IOError(format!("failed to get response text: {}", e)))
}
};
let data = match serde_json::from_str(&text) {
Ok(data) => data,
Err(e) => {
return Err(SDLanError::IOError(format!("failed to deserialize text: {}", e)))
}
let data = match serde_json::from_str(&text) {
Ok(data) => data,
Err(e) => {
return Err(SDLanError::IOError(format!("failed to deserialize text: {}", e)))
}
};
return Ok(data);
};
// println!("got test: {}", text);
@ -193,7 +205,7 @@ where T: Serialize + HMacCalculator,
// };
// println!("got respose: {:?}", data);
Ok(data)
// Ok(data)
}
pub async fn login_with_user_pass(

View File

@ -362,6 +362,10 @@ fn main() {
let mut should_daemonize = true;
match &cmd.cmd {
Commands::Version => {
println!("punchnet version: {}", env!("CARGO_PKG_VERSION"));
process::exit(0);
}
Commands::Login(user) => {
let rt = Runtime::new().unwrap();
rt.block_on(async move {

View File

@ -550,18 +550,19 @@ pub async fn check_peer_registration_needed(
_v6_info: &Option<V6Info>,
peer_sock: &SdlanSock,
) {
let p = eee.known_peers.peers.get(&src_mac);
let mut p = eee.known_peers.peers.get_mut(&src_mac);
let last_seen;
let now;
match p {
None => {
drop(p);
debug!("check peer registration needed, not found in known peers");
let _ = register_with_new_peer(eee, from_sn, src_mac, _v6_info, remote_nat, peer_sock)
.await;
return;
// unimplemented!();
}
Some(k) => {
Some(ref mut k) => {
// let mut ipv4_to_ipv6 = false;
now = get_current_timestamp();
if !from_sn {
@ -575,8 +576,8 @@ pub async fn check_peer_registration_needed(
mac_to_string(&src_mac)
);
// k.sock = peer_sock.deepcopy();
// k.last_seen.store(now, Ordering::Relaxed);
k.sock = peer_sock.deepcopy();
k.last_seen.store(now, Ordering::Relaxed);
} else {
return;
}
@ -594,6 +595,7 @@ pub async fn check_peer_registration_needed(
// more than 3 seconds
}
}
drop(p);
if now - last_seen > 3 {
check_known_peer_sock_change(eee, from_sn, src_mac, peer_sock, now, false).await;
@ -673,6 +675,7 @@ async fn register_with_new_peer(
peersock.to_string(),
);
drop(scan);
if from_sn {
// should send register to peer
if eee.config.register_ttl == 1 {
@ -712,12 +715,15 @@ async fn register_with_new_peer(
send_register(eee, remote_nat, peersock, mac, v6_info).await;
}
register_with_local_peers(eee).await;
if let Some(mut s) = eee.pending_peers.peers.get_mut(&mac) {
s.last_seen
.store(get_current_timestamp(), Ordering::Relaxed);
}
} else {
scan.sock = peersock.deepcopy();
scan.last_seen
.store(get_current_timestamp(), Ordering::Relaxed);
}
scan.last_seen
.store(get_current_timestamp(), Ordering::Relaxed);
}
async fn register_with_local_peers(eee: &'static Node) {

View File

@ -443,14 +443,15 @@ impl TunTapPacketHandler for Iface {
arp.sipaddr =
[((self_ip >> 16) & 0xffff) as u16, (self_ip & 0xffff) as u16];
let mut data_buf = BytesMut::from(arp.marshal_to_bytes().as_slice());
let encryptor = edge.encryptor.load();
if let Err(e) = encryptor.encrypt(&mut data_buf) {
error!("failed to encrypt arp reply: {:?}", e);
return Ok(());
}
let mut data_buf =
BytesMut::from(arp.marshal_to_bytes().as_slice());
let encryptor = edge.encryptor.load();
if let Err(e) = encryptor.encrypt(&mut data_buf) {
error!("failed to encrypt arp reply: {:?}", e);
return Ok(());
}
let data_bytes = data_buf.freeze();
let data_bytes = data_buf.freeze();
let data = SdlData {
is_p2p: true,
@ -523,7 +524,7 @@ impl TunTapPacketHandler for Iface {
// println!("got ip packet");
// println!("got data: {:?}", rest);
match edge.device.send(rest) {
match edge.device.send(rest).await {
Ok(size) => {
debug!("send to tun {} bytes", size);
}

View File

@ -35,6 +35,8 @@ pub enum Commands {
/// exits the
Stop,
Version,
}
#[derive(Subcommand, Debug)]