remove unnescesary Arc<_>
This commit is contained in:
parent
d6fbf79ded
commit
ef844183d6
6 changed files with 433 additions and 60 deletions
355
Cargo.lock
generated
355
Cargo.lock
generated
|
|
@ -2,6 +2,15 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
|
|
@ -29,6 +38,54 @@ version = "1.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "aws-lc-rs"
|
||||
version = "1.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ea835662a0af02443aa1396d39be523bbf8f11ee6fad20329607c480bea48c3"
|
||||
dependencies = [
|
||||
"aws-lc-sys",
|
||||
"paste",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aws-lc-sys"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71b2ddd3ada61a305e1d8bb6c005d1eaa7d14d903681edfc400406d523a9b491"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
"cmake",
|
||||
"dunce",
|
||||
"fs_extra",
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.69.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn 2.0.96",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.8.0"
|
||||
|
|
@ -73,9 +130,20 @@ version = "1.2.10"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
|
@ -106,6 +174,26 @@ dependencies = [
|
|||
"inout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.52"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c682c223677e0e5b6b7f63a64b9351844c3f1b1678a68b7ee617e30fb082620e"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
|
|
@ -137,6 +225,18 @@ version = "0.15.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||
|
||||
[[package]]
|
||||
name = "dunce"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.10"
|
||||
|
|
@ -144,9 +244,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fs_extra"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
|
|
@ -157,6 +263,17 @@ dependencies = [
|
|||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.0-rc.0"
|
||||
|
|
@ -167,11 +284,26 @@ dependencies = [
|
|||
"js-sys",
|
||||
"libc",
|
||||
"rustix",
|
||||
"wasi",
|
||||
"wasi 0.13.3+wasi-0.2.2",
|
||||
"wasm-bindgen",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.61"
|
||||
|
|
@ -204,12 +336,30 @@ dependencies = [
|
|||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.77"
|
||||
|
|
@ -220,12 +370,34 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.169"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.15"
|
||||
|
|
@ -238,6 +410,28 @@ version = "0.4.25"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[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 = "num-conv"
|
||||
version = "0.1.0"
|
||||
|
|
@ -268,6 +462,12 @@ version = "1.20.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
|
|
@ -283,6 +483,16 @@ dependencies = [
|
|||
"zerocopy 0.7.35",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.2.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn 2.0.96",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.93"
|
||||
|
|
@ -328,7 +538,7 @@ version = "0.9.0-beta.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a98fa0b8309344136abe6244130311e76997e546f76fae8054422a7539b43df7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.3.0-rc.0",
|
||||
"zerocopy 0.8.14",
|
||||
]
|
||||
|
||||
|
|
@ -341,6 +551,56 @@ dependencies = [
|
|||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"getrandom 0.2.15",
|
||||
"libc",
|
||||
"spin",
|
||||
"untrusted",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.43"
|
||||
|
|
@ -351,7 +611,40 @@ dependencies = [
|
|||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8"
|
||||
dependencies = [
|
||||
"aws-lc-rs",
|
||||
"log",
|
||||
"once_cell",
|
||||
"rustls-pki-types",
|
||||
"rustls-webpki",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.102.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9"
|
||||
dependencies = [
|
||||
"aws-lc-rs",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -397,6 +690,12 @@ dependencies = [
|
|||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
|
||||
[[package]]
|
||||
name = "splatoon-server-rust"
|
||||
version = "0.1.0"
|
||||
|
|
@ -409,11 +708,18 @@ dependencies = [
|
|||
"once_cell",
|
||||
"rand",
|
||||
"rc4",
|
||||
"rustls",
|
||||
"simplelog",
|
||||
"thiserror",
|
||||
"v_byte_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
|
|
@ -510,6 +816,12 @@ version = "1.0.14"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||
|
||||
[[package]]
|
||||
name = "v_byte_macros"
|
||||
version = "0.0.3"
|
||||
|
|
@ -526,6 +838,12 @@ version = "0.9.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.13.3+wasi-0.2.2"
|
||||
|
|
@ -593,13 +911,25 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
|
||||
dependencies = [
|
||||
"either",
|
||||
"home",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -611,6 +941,15 @@ dependencies = [
|
|||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
|
|
@ -733,3 +1072,9 @@ dependencies = [
|
|||
"quote",
|
||||
"syn 2.0.96",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
||||
|
|
|
|||
|
|
@ -15,3 +15,4 @@ chrono = "0.4.39"
|
|||
log = "0.4.25"
|
||||
anyhow = "1.0.95"
|
||||
rand = "0.9.0-beta.3"
|
||||
rustls = "^0.23.21"
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ fn main() {
|
|||
info!("setting up endpoints");
|
||||
|
||||
let auth_endpoints = vec![
|
||||
Endpoint::new(auth_server.socket.clone(), VirtualPort::new(1,10))
|
||||
Endpoint::new(auth_server.socket.try_clone().unwrap(), VirtualPort::new(1,10))
|
||||
];
|
||||
|
||||
auth_server.endpoints.set(auth_endpoints)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::prudp::sockaddr::PRUDPSockAddr;
|
|||
#[derive(Debug)]
|
||||
pub struct Endpoint{
|
||||
virtual_port: VirtualPort,
|
||||
socket: Arc<UdpSocket>,
|
||||
socket: UdpSocket,
|
||||
connections: RwLock<HashMap<PRUDPSockAddr, Connection>>
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ pub struct Connection{
|
|||
}
|
||||
|
||||
impl Endpoint{
|
||||
pub fn new(socket: Arc<UdpSocket>, port: VirtualPort) -> Self{
|
||||
pub fn new(socket: UdpSocket, port: VirtualPort) -> Self{
|
||||
Self{
|
||||
socket,
|
||||
virtual_port: port,
|
||||
|
|
@ -72,6 +72,9 @@ impl Endpoint{
|
|||
|
||||
match packet.header.types_and_flags.get_types() {
|
||||
types::SYN => {
|
||||
// reset heartbeat?
|
||||
let response_header = packet.base_response_header();
|
||||
|
||||
|
||||
}
|
||||
_ => unimplemented!()
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@ use std::io;
|
|||
use std::io::{Cursor, ErrorKind, Read, Seek};
|
||||
use std::net::SocketAddrV4;
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use log::{error, warn};
|
||||
use thiserror::Error;
|
||||
use v_byte_macros::{EnumTryInto, SwapEndian};
|
||||
use crate::endianness::{IS_BIG_ENDIAN, IS_LITTLE_ENDIAN, ReadExtensions};
|
||||
use crate::prudp::sockaddr::PRUDPSockAddr;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error{
|
||||
pub enum Error {
|
||||
#[error("{0}")]
|
||||
IO(#[from] io::Error),
|
||||
#[error("invalid magic {0:#06x}")]
|
||||
|
|
@ -20,10 +21,10 @@ pub enum Error{
|
|||
#[error("invalid option id {0}")]
|
||||
InvalidOptionId(u8),
|
||||
#[error("option size {size} doesnt match expected option for given option id {id}")]
|
||||
InvalidOptionSize{
|
||||
InvalidOptionSize {
|
||||
id: u8,
|
||||
size: u8
|
||||
}
|
||||
size: u8,
|
||||
},
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
|
@ -32,7 +33,7 @@ pub type Result<T> = std::result::Result<T, Error>;
|
|||
#[derive(Copy, Clone, Pod, Zeroable, SwapEndian)]
|
||||
pub struct TypesFlags(u16);
|
||||
|
||||
impl TypesFlags{
|
||||
impl TypesFlags {
|
||||
pub fn get_types(self) -> u8 {
|
||||
(self.0 & 0x000F) as u8
|
||||
}
|
||||
|
|
@ -46,24 +47,23 @@ impl TypesFlags{
|
|||
}
|
||||
|
||||
pub fn flags(self, val: u16) -> Self {
|
||||
Self((self.0 & 0x000F) | ((val << 4) & 0xFFF0) )
|
||||
Self((self.0 & 0x000F) | ((val << 4) & 0xFFF0))
|
||||
}
|
||||
}
|
||||
|
||||
pub mod flags{
|
||||
pub mod flags {
|
||||
pub const ACK: u16 = 0x001;
|
||||
pub const RELIABLE: u16 = 0x002;
|
||||
pub const NEED_ACK: u16 = 0x004;
|
||||
pub const HAS_SIZE: u16 = 0x008;
|
||||
pub const MULTI_ACK: u16 = 0x200;
|
||||
|
||||
}
|
||||
|
||||
pub mod types {
|
||||
pub const SYN: u8 = 0x0;
|
||||
}
|
||||
|
||||
impl Debug for TypesFlags{
|
||||
impl Debug for TypesFlags {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let stream_type = self.get_types();
|
||||
let port_number = self.get_flags();
|
||||
|
|
@ -75,7 +75,7 @@ impl Debug for TypesFlags{
|
|||
#[derive(PartialEq, Eq, Copy, Clone, Pod, Zeroable, SwapEndian, Hash)]
|
||||
pub struct VirtualPort(u8);
|
||||
|
||||
impl VirtualPort{
|
||||
impl VirtualPort {
|
||||
#[inline]
|
||||
pub const fn get_stream_type(self) -> u8 {
|
||||
(self.0 & 0xF0) >> 4
|
||||
|
|
@ -103,12 +103,12 @@ impl VirtualPort{
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn new(port: u8, stream_type: u8) -> Self{
|
||||
pub fn new(port: u8, stream_type: u8) -> Self {
|
||||
Self(0).stream_type(stream_type).port_number(port)
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for VirtualPort{
|
||||
impl Debug for VirtualPort {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let stream_type = self.get_stream_type();
|
||||
let port_number = self.get_port_number();
|
||||
|
|
@ -118,7 +118,7 @@ impl Debug for VirtualPort{
|
|||
|
||||
#[repr(C, packed)]
|
||||
#[derive(Debug, Copy, Clone, Pod, Zeroable, SwapEndian)]
|
||||
pub struct PRUDPHeader{
|
||||
pub struct PRUDPHeader {
|
||||
magic: [u8; 2],
|
||||
version: u8,
|
||||
pub packet_specific_size: u8,
|
||||
|
|
@ -132,22 +132,23 @@ pub struct PRUDPHeader{
|
|||
}
|
||||
#[repr(u16)]
|
||||
#[derive(EnumTryInto)]
|
||||
enum PacketSpecificData{
|
||||
enum PacketSpecificData {
|
||||
E = 0x10
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PRUDPPacket{
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PRUDPPacket {
|
||||
pub header: PRUDPHeader,
|
||||
pub payload: Vec<u8>
|
||||
pub payload: Vec<u8>,
|
||||
pub options: Vec<(u8, Vec<u8>)>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
// Invariant: can only contain 0, 1, 2, 3 or 4
|
||||
struct OptionId(u8);
|
||||
|
||||
impl OptionId{
|
||||
fn new(val: u8) -> Result<Self>{
|
||||
impl OptionId {
|
||||
fn new(val: u8) -> Result<Self> {
|
||||
// Invariant is upheld because we only create the object if it doesn't violate the invariant
|
||||
match val {
|
||||
0 | 1 | 2 | 3 | 4 => Ok(Self(val)),
|
||||
|
|
@ -155,8 +156,8 @@ impl OptionId{
|
|||
}
|
||||
}
|
||||
|
||||
fn option_type_size(self) -> u8{
|
||||
match self.0{
|
||||
fn option_type_size(self) -> u8 {
|
||||
match self.0 {
|
||||
0 => 4,
|
||||
1 => 16,
|
||||
2 => 1,
|
||||
|
|
@ -169,39 +170,40 @@ impl OptionId{
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<u8> for OptionId{
|
||||
impl Into<u8> for OptionId {
|
||||
fn into(self) -> u8 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl PRUDPPacket{
|
||||
pub fn new(reader: &mut (impl Read + Seek)) -> Result<Self>{
|
||||
let header: PRUDPHeader = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
impl PRUDPPacket {
|
||||
pub fn new(reader: &mut (impl Read + Seek)) -> Result<Self> {
|
||||
let header: PRUDPHeader = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
|
||||
if header.magic[0] != 0xEA ||
|
||||
header.magic[1] != 0xD0{
|
||||
header.magic[1] != 0xD0 {
|
||||
return Err(Error::InvalidMagic(u16::from_be_bytes(header.magic)));
|
||||
}
|
||||
|
||||
if header.version != 1{
|
||||
return Err(Error::InvalidVersion(header.version))
|
||||
if header.version != 1 {
|
||||
return Err(Error::InvalidVersion(header.version));
|
||||
}
|
||||
|
||||
//discard it for now
|
||||
let _: [u8; 16] = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
|
||||
assert_eq!(reader.stream_position().ok(), Some(14+16));
|
||||
assert_eq!(reader.stream_position().ok(), Some(14 + 16));
|
||||
|
||||
let mut packet_specific_buffer = vec![0u8; header.packet_specific_size as usize];
|
||||
|
||||
reader.read_exact(&mut packet_specific_buffer)?;
|
||||
|
||||
|
||||
|
||||
//no clue whats up with options but they are broken
|
||||
let mut packet_specific_data_cursor = Cursor::new(&packet_specific_buffer);
|
||||
|
||||
let mut options = Vec::new();
|
||||
|
||||
|
||||
loop {
|
||||
let Ok(option_id): io::Result<u8> = packet_specific_data_cursor.read_struct(IS_BIG_ENDIAN) else {
|
||||
|
|
@ -214,22 +216,27 @@ impl PRUDPPacket{
|
|||
|
||||
if value_size == 0 {
|
||||
// skip it if its 0 and dont check?
|
||||
warn!("reading packets options might be going wrong");
|
||||
continue;
|
||||
}
|
||||
|
||||
let option_id: OptionId = OptionId::new(option_id)?;
|
||||
|
||||
if option_id.option_type_size() != value_size{
|
||||
if option_id.option_type_size() != value_size {
|
||||
error!("invalid packet options");
|
||||
return Err(Error::InvalidOptionSize {
|
||||
size: value_size,
|
||||
id: option_id.0
|
||||
})
|
||||
id: option_id.0,
|
||||
});
|
||||
}
|
||||
|
||||
let mut option_data = vec![0u8,value_size];
|
||||
if packet_specific_data_cursor.read_exact(&mut option_data).is_err(){
|
||||
let mut option_data = vec![0u8, value_size];
|
||||
if packet_specific_data_cursor.read_exact(&mut option_data).is_err() {
|
||||
error!("unable to read options");
|
||||
break;
|
||||
}
|
||||
|
||||
options.push((option_id.into(), option_data));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -237,25 +244,42 @@ impl PRUDPPacket{
|
|||
|
||||
reader.read_exact(&mut payload)?;
|
||||
|
||||
Ok(Self{
|
||||
Ok(Self {
|
||||
header,
|
||||
payload
|
||||
payload,
|
||||
options,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn source_sockaddr(&self,socket_addr_v4: SocketAddrV4) -> PRUDPSockAddr{
|
||||
PRUDPSockAddr{
|
||||
pub fn source_sockaddr(&self, socket_addr_v4: SocketAddrV4) -> PRUDPSockAddr {
|
||||
PRUDPSockAddr {
|
||||
regular_socket_addr: socket_addr_v4,
|
||||
virtual_port: self.header.source_port
|
||||
virtual_port: self.header.source_port,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn base_response_header(&self) -> PRUDPHeader {
|
||||
PRUDPHeader {
|
||||
magic: [0xEA, 0xD0],
|
||||
types_and_flags: TypesFlags(0),
|
||||
destination_port: self.header.source_port,
|
||||
source_port: self.header.destination_port,
|
||||
payload_size: 0,
|
||||
version: 1,
|
||||
packet_specific_size: 0,
|
||||
sequence_id: 0,
|
||||
session_id: 0,
|
||||
substream_id: 0,
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test{
|
||||
mod test {
|
||||
use super::{PRUDPHeader};
|
||||
#[test]
|
||||
fn size_test(){
|
||||
fn size_test() {
|
||||
assert_eq!(size_of::<PRUDPHeader>(), 14);
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ static SERVER_DATAGRAMS: Lazy<u8> = Lazy::new(||{
|
|||
|
||||
pub struct NexServer{
|
||||
pub endpoints: OnceLock<Vec<Endpoint>>,
|
||||
pub socket: Arc<UdpSocket>,
|
||||
pub socket: UdpSocket,
|
||||
pub running: AtomicBool,
|
||||
//pub auth_module: Arc<dyn AuthModule>
|
||||
_no_outside_construction: PhantomData<()>
|
||||
|
|
@ -68,7 +68,7 @@ impl NexServer{
|
|||
}
|
||||
}
|
||||
|
||||
fn server_thread_entry(self: Arc<Self>, socket: Arc<UdpSocket>){
|
||||
fn server_thread_entry(self: Arc<Self>, socket: UdpSocket){
|
||||
info!("starting datagram thread");
|
||||
|
||||
while self.running.load(Ordering::Relaxed) {
|
||||
|
|
@ -90,12 +90,12 @@ impl NexServer{
|
|||
}
|
||||
|
||||
pub fn new(addr: SocketAddrV4) -> io::Result<(Arc<Self>, JoinHandle<()>)>{
|
||||
let socket = Arc::new(UdpSocket::bind(addr)?);
|
||||
let socket = UdpSocket::bind(addr)?;
|
||||
|
||||
let own_impl = NexServer{
|
||||
endpoints: Default::default(),
|
||||
running: AtomicBool::new(true),
|
||||
socket: socket.clone(),
|
||||
socket: socket.try_clone().unwrap(),
|
||||
_no_outside_construction: Default::default()
|
||||
};
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ impl NexServer{
|
|||
let mut thread = None;
|
||||
|
||||
for _ in 0..*SERVER_DATAGRAMS {
|
||||
let socket = socket.clone();
|
||||
let socket = socket.try_clone().unwrap();
|
||||
let server= arc.clone();
|
||||
|
||||
thread = Some(thread::spawn(move || {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue