mirror of
https://github.com/speyejack/smo-multi-rs.git
synced 2025-10-05 15:42:45 +02:00
Several packet fixes and small proxy
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/target
|
||||
/examples/*/target
|
||||
|
189
Cargo.lock
generated
189
Cargo.lock
generated
@@ -11,6 +11,15 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.58"
|
||||
@@ -120,15 +129,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.0"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
|
||||
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -158,12 +175,6 @@ version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.1"
|
||||
@@ -174,6 +185,12 @@ dependencies = [
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.126"
|
||||
@@ -199,6 +216,15 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||
dependencies = [
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matrixmultiply"
|
||||
version = "0.3.2"
|
||||
@@ -382,6 +408,17 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quickcheck"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"log",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.20"
|
||||
@@ -391,6 +428,24 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rawpointer"
|
||||
version = "0.2.1"
|
||||
@@ -408,9 +463,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.6"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
|
||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -418,10 +473,19 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.26"
|
||||
name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
dependencies = [
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
||||
|
||||
[[package]]
|
||||
name = "safe_arch"
|
||||
@@ -458,6 +522,15 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.0"
|
||||
@@ -487,20 +560,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
|
||||
|
||||
[[package]]
|
||||
name = "smo-rs"
|
||||
name = "smoo"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"clap",
|
||||
"dashmap",
|
||||
"env_logger",
|
||||
"hex",
|
||||
"log",
|
||||
"nalgebra",
|
||||
"quickcheck",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -565,6 +639,15 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.20.0"
|
||||
@@ -597,6 +680,68 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"matchers",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.15.0"
|
||||
@@ -609,6 +754,12 @@ version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
|
16
Cargo.toml
16
Cargo.toml
@@ -1,10 +1,14 @@
|
||||
[package]
|
||||
name = "smo-rs"
|
||||
name = "smoo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
name = "smoo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
tokio = {version="*", features=["full"]}
|
||||
clap = {version="*", features=["derive"]}
|
||||
@@ -14,6 +18,12 @@ nalgebra = "0.31.0"
|
||||
bytes = "1.2.0"
|
||||
thiserror = "1.0.31"
|
||||
dashmap = "5.3.4"
|
||||
log = "0.4.17"
|
||||
env_logger = "0.9"
|
||||
hex = "0.4.3"
|
||||
tracing = {version="0.1.36"}
|
||||
tracing-subscriber = {version="0.3.15", features=["std", "env-filter", "fmt"]}
|
||||
quickcheck = "1.0.3"
|
||||
|
||||
[worksapce]
|
||||
members = [
|
||||
"examples/proxy",
|
||||
]
|
||||
|
868
examples/proxy/Cargo.lock
generated
Normal file
868
examples/proxy/Cargo.lock
generated
Normal file
@@ -0,0 +1,868 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c91f1f46651137be86f3a2b9a8359f9ab421d04d941c62b5982e1ca21113adf9"
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5377c8865e74a160d21f29c2d40669f53286db6eab59b88540cbb12ffc8b835"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3dbbb6653e7c55cc8595ad3e1f7be8f32aba4eb7ff7f0fd1163d4f3d137c0a9"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"once_cell",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ba52acd3b0a5c33aeada5cdaa3267cdc7c594a98731d4268cdc1532f4264cb4"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "5.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3495912c9c1ccf2e18976439f4443f3fee0fd61f424ff99fde6a66b15ecb448f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"hashbrown",
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.127"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "505e71a4706fa491e9b1b55f51b95d4037d0821ee40131190475f692b35b009b"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||
dependencies = [
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matrixmultiply"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84"
|
||||
dependencies = [
|
||||
"rawpointer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nalgebra"
|
||||
version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9e0a04ce089f9401aac565c740ed30c46291260f27d4911fdbaa6ca65fa3044"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"matrixmultiply",
|
||||
"nalgebra-macros",
|
||||
"num-complex",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"simba",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nalgebra-macros"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proxy"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"smoo",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quickcheck"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"log",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rawpointer"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
dependencies = [
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
||||
|
||||
[[package]]
|
||||
name = "safe_arch"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.142"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e590c437916fb6b221e1d00df6e3294f3fccd70ca7e92541c475d6ed6ef5fee2"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.142"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34b5b8d809babe02f538c2cfec6f2c1ed10804c0e5a6a041a049a4f5588ccc2e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simba"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c48e45e5961033db030b56ad67aef22e9c908c493a6e8348c0a0f6b93433cd77"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"num-complex",
|
||||
"num-traits",
|
||||
"paste",
|
||||
"wide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
|
||||
|
||||
[[package]]
|
||||
name = "smoo"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"clap",
|
||||
"dashmap",
|
||||
"hex",
|
||||
"nalgebra",
|
||||
"quickcheck",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.99"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.20.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"bytes",
|
||||
"libc",
|
||||
"memchr",
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"matchers",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wide"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3aba2d1dac31ac7cae82847ac5b8be822aee8f99a4e100f279605016b185c5f"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"safe_arch",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
|
||||
dependencies = [
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
|
13
examples/proxy/Cargo.toml
Normal file
13
examples/proxy/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "proxy"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
smoo = {path = "../../"}
|
||||
tokio = "*"
|
||||
tracing = "*"
|
||||
tracing-subscriber = "*"
|
||||
bytes = "*"
|
78
examples/proxy/src/main.rs
Normal file
78
examples/proxy/src/main.rs
Normal file
@@ -0,0 +1,78 @@
|
||||
use bytes::BytesMut;
|
||||
use smoo::net::connection::Connection;
|
||||
use smoo::net::encoding::Encodable;
|
||||
use smoo::types::Result;
|
||||
use std::{io::Cursor, net::SocketAddr};
|
||||
use tokio;
|
||||
use tokio::net::{TcpListener, TcpSocket, TcpStream};
|
||||
use tracing::Instrument;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.init();
|
||||
|
||||
tracing::debug!("Starting");
|
||||
let addr: SocketAddr = "0.0.0.0:61884".parse().unwrap();
|
||||
let listener = TcpListener::bind(addr).await?;
|
||||
|
||||
loop {
|
||||
let (from_socket, addr) = listener.accept().await?;
|
||||
tracing::info!("new client connection: {}", addr);
|
||||
let span = tracing::info_span!("cli", addr = addr.ip().to_string());
|
||||
tokio::spawn(
|
||||
async move {
|
||||
let result = proxy_client(from_socket).await;
|
||||
if let Err(e) = result {
|
||||
tracing::warn!("Client error: {e}");
|
||||
}
|
||||
}
|
||||
.instrument(span),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
enum Origin {
|
||||
Client,
|
||||
Server,
|
||||
}
|
||||
|
||||
async fn proxy_client(cli_sock: TcpStream) -> Result<()> {
|
||||
let server_conn = tokio::net::TcpSocket::new_v4()?;
|
||||
let addr = "127.0.0.1:61888".parse().unwrap();
|
||||
let serv_sock = server_conn.connect(addr).await?;
|
||||
|
||||
let mut cli = Connection::new(cli_sock);
|
||||
let mut serv = Connection::new(serv_sock);
|
||||
|
||||
tracing::info!("Client setup and ready");
|
||||
loop {
|
||||
let (origin, packet_result) = tokio::select! {
|
||||
packet_r = cli.read_packet() => {(Origin::Client, packet_r)},
|
||||
packet_r = serv.read_packet() => {(Origin::Server, packet_r)},
|
||||
};
|
||||
tracing::debug!("packet: {:?}", &packet_result);
|
||||
|
||||
let packet = packet_result?;
|
||||
|
||||
let current_conn = match origin {
|
||||
Origin::Client => &mut cli,
|
||||
Origin::Server => &mut serv,
|
||||
};
|
||||
|
||||
// let mut buff = BytesMut::with_capacity(300);
|
||||
// packet.encode(&mut buff);
|
||||
// assert_eq!(¤t_conn.last_data[..].len(), &buff[..].len());
|
||||
|
||||
tracing::info!("got packet: {}", packet.data.get_type_name());
|
||||
|
||||
match origin {
|
||||
Origin::Client => serv.write_packet(&packet).await?,
|
||||
Origin::Server => cli.write_packet(&packet).await?,
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,7 +9,6 @@ use crate::settings::SyncSettings;
|
||||
use crate::types::ClientInitError;
|
||||
use crate::types::{Costume, SMOError};
|
||||
use crate::types::{EncodingError, Result};
|
||||
use log::info;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -17,13 +16,16 @@ use tokio::io::AsyncWriteExt;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::select;
|
||||
use tokio::sync::{mpsc, RwLock};
|
||||
use tracing::info;
|
||||
use tracing::info_span;
|
||||
use tracing::instrument;
|
||||
|
||||
pub type ClientMap = HashMap<Guid, SyncClient>;
|
||||
pub type SyncClient = Arc<RwLock<ClientData>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Client {
|
||||
pub name: String,
|
||||
pub display_name: String,
|
||||
pub data: SyncClient,
|
||||
pub guid: Guid,
|
||||
pub alive: bool,
|
||||
@@ -34,6 +36,7 @@ pub struct Client {
|
||||
|
||||
#[derive(Default, Clone, Debug)]
|
||||
pub struct ClientData {
|
||||
pub name: String,
|
||||
pub shine_sync: HashSet<i32>,
|
||||
pub scenario: u8,
|
||||
pub is_2d: bool,
|
||||
@@ -63,7 +66,7 @@ impl Client {
|
||||
while self.alive {
|
||||
let event = self.read_event().await;
|
||||
|
||||
// log::debug!("Event: {:?}", &event);
|
||||
tracing::debug!("Event: {:?}", &event);
|
||||
let result = match event {
|
||||
Ok((Origin::External, ClientEvent::Packet(p))) => self.handle_packet(p).await,
|
||||
Ok((Origin::Internal, ClientEvent::Packet(p))) => self.send_packet(&p).await,
|
||||
@@ -78,7 +81,7 @@ impl Client {
|
||||
};
|
||||
|
||||
if let Err(e) = result {
|
||||
log::warn!("Error with client {}: {}", self.guid, e)
|
||||
tracing::warn!("Error with client {}: {}", self.guid, e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +100,7 @@ impl Client {
|
||||
}
|
||||
|
||||
pub async fn disconnect(mut self) -> Result<()> {
|
||||
log::warn!("Client {} disconnected", self.name);
|
||||
tracing::warn!("Client {} disconnected", self.display_name);
|
||||
self.to_coord
|
||||
.send(Command::Server(ServerCommand::DisconnectPlayer {
|
||||
guid: self.guid,
|
||||
@@ -198,14 +201,11 @@ impl Client {
|
||||
pub async fn send_packet(&mut self, packet: &Packet) -> Result<()> {
|
||||
// TODO Handle disconnect packets
|
||||
if packet.id != self.guid {
|
||||
if packet.id
|
||||
== [
|
||||
63, 43, 68, 191, 202, 95, 117, 43, 5, 28, 207, 189, 239, 115, 237, 201,
|
||||
]
|
||||
.into()
|
||||
{
|
||||
log::info!("Sending packet: {:?}", packet);
|
||||
}
|
||||
tracing::info!(
|
||||
"Sending packet: {}->{}",
|
||||
packet.id,
|
||||
packet.data.get_type_name()
|
||||
);
|
||||
|
||||
self.conn.write_packet(packet).await
|
||||
} else {
|
||||
@@ -218,40 +218,40 @@ impl Client {
|
||||
to_coord: mpsc::Sender<Command>,
|
||||
settings: SyncSettings,
|
||||
) -> Result<()> {
|
||||
log::debug!("Starting client initializaiton");
|
||||
let (to_cli, from_server) = mpsc::channel(10);
|
||||
|
||||
let l_set = settings.read().await;
|
||||
let max_players = l_set.max_players;
|
||||
drop(l_set);
|
||||
|
||||
log::debug!("Verified max players");
|
||||
let data = ClientData {
|
||||
settings,
|
||||
..ClientData::default()
|
||||
};
|
||||
let data = Arc::new(RwLock::new(data));
|
||||
|
||||
tracing::debug!("Initializing connection");
|
||||
let mut conn = Connection::new(socket);
|
||||
|
||||
log::debug!("Created client");
|
||||
conn.write_packet(&Packet::new(
|
||||
Guid::default(),
|
||||
PacketData::Init { max_players },
|
||||
))
|
||||
.await?;
|
||||
log::debug!("Sent init packet");
|
||||
|
||||
tracing::debug!("Waiting for reply");
|
||||
let connect = conn.read_packet().await?;
|
||||
log::debug!("Received connect packet");
|
||||
|
||||
let new_player = match connect.data {
|
||||
PacketData::Connect {
|
||||
client_name: ref name,
|
||||
..
|
||||
} => {
|
||||
let to_coord = to_coord.clone();
|
||||
log::debug!("Created client data");
|
||||
let client = Client {
|
||||
let data = ClientData {
|
||||
settings,
|
||||
name: name.clone(),
|
||||
..ClientData::default()
|
||||
};
|
||||
|
||||
let data = Arc::new(RwLock::new(data));
|
||||
|
||||
let to_coord = to_coord.clone();
|
||||
tracing::debug!("Created client data");
|
||||
let client = Client {
|
||||
display_name: name.trim_matches(char::from(0)).to_string(),
|
||||
data,
|
||||
guid: connect.id,
|
||||
alive: true,
|
||||
|
@@ -13,6 +13,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
use tokio::sync::{mpsc, RwLock};
|
||||
use tracing::{info_span, Instrument};
|
||||
type SyncShineBag = Arc<RwLock<HashSet<i32>>>;
|
||||
|
||||
pub struct Coordinator {
|
||||
@@ -33,7 +34,7 @@ impl Coordinator {
|
||||
Ok(false) => break,
|
||||
Ok(true) => {}
|
||||
Err(e) => {
|
||||
log::warn!("Coordinator error: {e}")
|
||||
tracing::warn!("Coordinator error: {e}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +97,7 @@ impl Coordinator {
|
||||
client_sync_shines(channel, shine_bag, packet.id, &client)
|
||||
.await;
|
||||
if let Err(e) = result {
|
||||
log::warn!("Initial shine sync failed: {e}")
|
||||
tracing::warn!("Initial shine sync failed: {e}")
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -146,7 +147,7 @@ impl Coordinator {
|
||||
let banned_ips = &settings.banned_ips;
|
||||
|
||||
if max_players < self.clients.len() {
|
||||
log::warn!(
|
||||
tracing::warn!(
|
||||
"Reached max players: {} <= {}",
|
||||
max_players,
|
||||
self.clients.len()
|
||||
@@ -182,7 +183,11 @@ impl Coordinator {
|
||||
}
|
||||
self.to_clients.insert(id, comm.clone());
|
||||
|
||||
tokio::spawn(async move { cli.handle_events().await });
|
||||
let name = cli.display_name.clone();
|
||||
tracing::info!("New client connected: {} ({})", &name, cli.guid);
|
||||
let span = info_span!("client", name);
|
||||
tokio::spawn(async move { cli.handle_events().await }.instrument(span));
|
||||
|
||||
let result = self.setup_player(comm, *packet).await;
|
||||
if let Err(e) = result {
|
||||
self.disconnect_player(id).await?;
|
||||
@@ -192,10 +197,40 @@ impl Coordinator {
|
||||
}
|
||||
|
||||
async fn setup_player(&mut self, comm: mpsc::Sender<Command>, packet: Packet) -> Result<()> {
|
||||
for other_cli in self.clients.values() {
|
||||
tracing::debug!(
|
||||
"Setting up player ({}) with {} other players",
|
||||
packet.id,
|
||||
self.clients.len()
|
||||
);
|
||||
let settings = self.settings.read().await;
|
||||
let max_player = settings.max_players;
|
||||
|
||||
drop(settings);
|
||||
// Sync connection, costumes, and last game packet
|
||||
for (other_id, other_cli) in self.clients.iter() {
|
||||
let other_cli = other_cli.read().await;
|
||||
if let Some(p) = &other_cli.last_game_packet {
|
||||
comm.send(Command::Packet(p.clone())).await?;
|
||||
|
||||
let connect_packet = Packet::new(
|
||||
*other_id,
|
||||
PacketData::Connect {
|
||||
c_type: ConnectionType::FirstConnection,
|
||||
max_player,
|
||||
client_name: other_cli.name.clone(),
|
||||
},
|
||||
);
|
||||
|
||||
let costume_packet =
|
||||
Packet::new(*other_id, PacketData::Costume(other_cli.costume.clone()));
|
||||
|
||||
let last_game_packet = other_cli.last_game_packet.clone();
|
||||
|
||||
drop(other_cli);
|
||||
|
||||
comm.send(Command::Packet(connect_packet)).await?;
|
||||
comm.send(Command::Packet(costume_packet)).await?;
|
||||
|
||||
if let Some(p) = last_game_packet {
|
||||
comm.send(Command::Packet(p)).await?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,11 +238,13 @@ impl Coordinator {
|
||||
}
|
||||
|
||||
async fn disconnect_player(&mut self, guid: Guid) -> Result<()> {
|
||||
log::info!("Disconnecting player {}", guid);
|
||||
tracing::info!("Disconnecting player {}", guid);
|
||||
self.clients.remove(&guid);
|
||||
if let Some(comm) = self.to_clients.remove(&guid) {
|
||||
comm.send(Command::Packet(Packet::new(guid, PacketData::Disconnect)))
|
||||
.await?;
|
||||
let packet = Packet::new(guid, PacketData::Disconnect);
|
||||
self.broadcast(packet.clone()).await?;
|
||||
let disconnect = Command::Packet(packet);
|
||||
comm.send(disconnect).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@@ -1,6 +1,7 @@
|
||||
use std::{fmt::Display, str::FromStr};
|
||||
|
||||
use hex::FromHex;
|
||||
use quickcheck::Arbitrary;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::EncodingError;
|
||||
|
8
src/lib.rs
Normal file
8
src/lib.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
pub mod client;
|
||||
pub mod cmds;
|
||||
pub mod coordinator;
|
||||
pub mod guid;
|
||||
pub mod net;
|
||||
pub mod server;
|
||||
pub mod settings;
|
||||
pub mod types;
|
22
src/main.rs
22
src/main.rs
@@ -26,6 +26,7 @@ use tokio::{
|
||||
join,
|
||||
sync::{mpsc, RwLock},
|
||||
};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
@@ -41,12 +42,17 @@ async fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
fn create_default_server() -> (mpsc::Sender<Command>, Server, Coordinator) {
|
||||
// TODO Remove tihs debug panic option
|
||||
let default_panic = std::panic::take_hook();
|
||||
std::panic::set_hook(Box::new(move |info| {
|
||||
default_panic(info);
|
||||
std::process::exit(1);
|
||||
}));
|
||||
env_logger::init();
|
||||
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.init();
|
||||
|
||||
let (to_coord, from_clients) = mpsc::channel(100);
|
||||
|
||||
let settings = Settings {
|
||||
@@ -110,7 +116,7 @@ mod test {
|
||||
|
||||
use super::*;
|
||||
|
||||
// #[ignore]
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn client_connect() -> Result<()> {
|
||||
let addr = "127.0.0.1:61884".parse().unwrap();
|
||||
@@ -129,21 +135,21 @@ mod test {
|
||||
|
||||
async fn fake_client(addr: SocketAddr) -> Result<()> {
|
||||
let socket = tokio::net::TcpSocket::new_v4()?;
|
||||
log::debug!("Connecting to server");
|
||||
tracing::debug!("Connecting to server");
|
||||
let conn = socket.connect(addr).await?;
|
||||
let mut conn = Connection::new(conn);
|
||||
log::debug!("Connected to server");
|
||||
tracing::debug!("Connected to server");
|
||||
|
||||
log::debug!("Reading data from server");
|
||||
tracing::debug!("Reading data from server");
|
||||
let result: Result<Packet> = Err(EncodingError::CustomError.into());
|
||||
while result.is_err() {
|
||||
let result = conn.read_packet().await;
|
||||
log::debug!("Packet: {:?}", result);
|
||||
tracing::debug!("Packet: {:?}", result);
|
||||
// let read = conn.read(&mut buff).await?;
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
log::debug!("Read data from server");
|
||||
log::debug!("Read packet: {:?}", result);
|
||||
tracing::debug!("Read data from server");
|
||||
tracing::debug!("Read packet: {:?}", result);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ use tokio::{
|
||||
net::TcpStream,
|
||||
};
|
||||
|
||||
use super::{encoding::Decodable, Packet};
|
||||
use super::{encoding::Decodable, Packet, MAX_PACKET_SIZE};
|
||||
use crate::{
|
||||
net::encoding::Encodable,
|
||||
types::{EncodingError, Result},
|
||||
@@ -36,6 +36,7 @@ impl Connection {
|
||||
|
||||
buf.set_position(0);
|
||||
|
||||
tracing::info!("Buff: {:?}", &self.buff[..]);
|
||||
let packet = Packet::decode(&mut buf)?;
|
||||
self.buff.advance(len);
|
||||
|
||||
@@ -52,28 +53,34 @@ impl Connection {
|
||||
return Ok(packet);
|
||||
}
|
||||
|
||||
let read_amount = self.socket.read_buf(&mut self.buff).await?;
|
||||
if read_amount == 0 {
|
||||
if self.buff.is_empty() {
|
||||
return Err(EncodingError::ConnectionClose.into());
|
||||
} else {
|
||||
return Err(EncodingError::ConnectionReset.into());
|
||||
}
|
||||
self.read_socket().await?
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn read_socket(&mut self) -> Result<()> {
|
||||
let read_amount = self.socket.read_buf(&mut self.buff).await?;
|
||||
if read_amount == 0 {
|
||||
if self.buff.is_empty() {
|
||||
Err(EncodingError::ConnectionClose.into())
|
||||
} else {
|
||||
Err(EncodingError::ConnectionReset.into())
|
||||
}
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn write_packet(&mut self, packet: &Packet) -> Result<()> {
|
||||
let mut buff = BytesMut::with_capacity(100);
|
||||
let mut buff = BytesMut::with_capacity(MAX_PACKET_SIZE);
|
||||
packet.encode(&mut buff)?;
|
||||
log::debug!("Writing packet: {:?}", packet);
|
||||
tracing::trace!("Writing packet: {:?}", packet);
|
||||
let mut amount = 0;
|
||||
while amount < buff.len() {
|
||||
let last_write = self.socket.write(&buff[..]).await?;
|
||||
amount += last_write;
|
||||
}
|
||||
self.socket.flush().await?;
|
||||
log::debug!("Packet written");
|
||||
tracing::trace!("Packet written");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +1,25 @@
|
||||
use std::io::Cursor;
|
||||
use std::{fmt::Debug, io::Cursor};
|
||||
|
||||
use super::encoding::{Decodable, Encodable};
|
||||
use crate::{
|
||||
guid::Guid,
|
||||
types::{Costume, EncodingError, Quaternion, Vector3},
|
||||
};
|
||||
use bytes::{Buf, BufMut};
|
||||
use bytes::{Buf, BufMut, BytesMut};
|
||||
use quickcheck::Arbitrary;
|
||||
|
||||
type Result<T> = std::result::Result<T, EncodingError>;
|
||||
|
||||
pub const MAX_PACKET_SIZE: usize = 300;
|
||||
|
||||
const COSTUME_NAME_SIZE: usize = 0x20;
|
||||
const STAGE_NAME_SIZE: usize = 0x30;
|
||||
const CAP_ANIM_SIZE: usize = 0x30;
|
||||
const STAGE_GAME_NAME_SIZE: usize = 0x40;
|
||||
const STAGE_CHANGE_NAME_SIZE: usize = 0x30;
|
||||
const STAGE_ID_SIZE: usize = 0x10;
|
||||
const CLIENT_NAME_SIZE: usize = COSTUME_NAME_SIZE;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Packet {
|
||||
pub id: Guid,
|
||||
pub data_size: u16,
|
||||
@@ -37,7 +42,7 @@ impl Packet {
|
||||
let header_size = 16 + 2;
|
||||
let start_pos = buf.position();
|
||||
if buf.remaining() < header_size + 2 {
|
||||
// log::debug!(
|
||||
// tracing::debug!(
|
||||
// "Not enough bytes for header: {} < {}",
|
||||
// buf.remaining(),
|
||||
// header_size + 2
|
||||
@@ -47,8 +52,9 @@ impl Packet {
|
||||
|
||||
buf.advance(header_size);
|
||||
let size = buf.get_u16_le().into();
|
||||
// tracing::info!("Size: {}", size);
|
||||
if buf.remaining() < size {
|
||||
log::debug!("Not enough bytes for data: {} < {}", buf.remaining(), size);
|
||||
tracing::trace!("Not enough bytes for data: {} < {}", buf.remaining(), size);
|
||||
return Err(EncodingError::NotEnoughData);
|
||||
}
|
||||
buf.advance(size);
|
||||
@@ -56,7 +62,7 @@ impl Packet {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum PacketData {
|
||||
Unhandled {
|
||||
tag: u16,
|
||||
@@ -86,7 +92,7 @@ pub enum PacketData {
|
||||
Tag {
|
||||
update_type: TagUpdate,
|
||||
is_it: bool,
|
||||
seconds: u8,
|
||||
seconds: u16,
|
||||
minutes: u16,
|
||||
},
|
||||
Connect {
|
||||
@@ -117,18 +123,19 @@ impl PacketData {
|
||||
Self::Unhandled { data, .. } => data.len(),
|
||||
Self::Init { .. } => 2,
|
||||
Self::Player { .. } => 0x38,
|
||||
Self::Cap { .. } => 0x50,
|
||||
Self::Game { .. } => 0x42,
|
||||
Self::Cap { .. } => 29 + CAP_ANIM_SIZE + 3,
|
||||
Self::Game { .. } => 2 + STAGE_GAME_NAME_SIZE,
|
||||
Self::Tag { .. } => 6,
|
||||
Self::Connect { .. } => 6 + CLIENT_NAME_SIZE,
|
||||
Self::Disconnect { .. } => 0,
|
||||
Self::Costume { .. } => COSTUME_NAME_SIZE * 2,
|
||||
Self::Shine { .. } => 4,
|
||||
Self::Capture { .. } => COSTUME_NAME_SIZE,
|
||||
Self::ChangeStage { .. } => STAGE_ID_SIZE + STAGE_NAME_SIZE + 2,
|
||||
Self::ChangeStage { .. } => STAGE_ID_SIZE + STAGE_CHANGE_NAME_SIZE + 2,
|
||||
Self::Command { .. } => 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_type_id(&self) -> u16 {
|
||||
match self {
|
||||
Self::Unhandled { tag, .. } => *tag,
|
||||
@@ -146,17 +153,36 @@ impl PacketData {
|
||||
Self::Command { .. } => 12,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_type_name(&self) -> String {
|
||||
match self {
|
||||
Self::Unhandled { .. } => "unhandled",
|
||||
Self::Init { .. } => "init",
|
||||
Self::Player { .. } => "player",
|
||||
Self::Cap { .. } => "cap",
|
||||
Self::Game { .. } => "game",
|
||||
Self::Tag { .. } => "tag",
|
||||
Self::Connect { .. } => "connect",
|
||||
Self::Disconnect { .. } => "disconnect",
|
||||
Self::Costume { .. } => "costume",
|
||||
Self::Shine { .. } => "shine",
|
||||
Self::Capture { .. } => "capture",
|
||||
Self::ChangeStage { .. } => "changeStage",
|
||||
Self::Command { .. } => "command",
|
||||
}
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ConnectionType {
|
||||
FirstConnection,
|
||||
Reconnecting,
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum TagUpdate {
|
||||
Time = 1,
|
||||
State = 2,
|
||||
@@ -170,7 +196,7 @@ where
|
||||
{
|
||||
fn decode(buf: &mut R) -> std::result::Result<Self, EncodingError> {
|
||||
if buf.remaining() < (16 + 2 + 2) {
|
||||
log::debug!("Header size failed");
|
||||
tracing::trace!("Header size failed");
|
||||
return Err(EncodingError::NotEnoughData);
|
||||
}
|
||||
|
||||
@@ -180,10 +206,10 @@ where
|
||||
let p_size = buf.get_u16_le();
|
||||
|
||||
if buf.remaining() < p_size.into() {
|
||||
log::debug!("data size failed");
|
||||
tracing::trace!("data size failed");
|
||||
return Err(EncodingError::NotEnoughData);
|
||||
}
|
||||
// log::debug!("Attempting packet decode of: {}", p_type);
|
||||
// tracing::debug!("Attempting packet decode of: {}", p_type);
|
||||
|
||||
let data = match p_type {
|
||||
1 => PacketData::Init {
|
||||
@@ -203,17 +229,21 @@ where
|
||||
act: buf.get_u16_le(),
|
||||
sub_act: buf.get_u16_le(),
|
||||
},
|
||||
3 => PacketData::Cap {
|
||||
pos: Vector3::decode(buf)?,
|
||||
rot: Quaternion::decode(buf)?,
|
||||
cap_out: buf.get_u8() != 0,
|
||||
cap_anim: std::str::from_utf8(&buf.copy_to_bytes(COSTUME_NAME_SIZE)[..])?
|
||||
.to_string(),
|
||||
},
|
||||
3 => {
|
||||
let packet = PacketData::Cap {
|
||||
pos: Vector3::decode(buf)?,
|
||||
rot: Quaternion::decode(buf)?,
|
||||
cap_out: buf.get_u8() != 0,
|
||||
cap_anim: std::str::from_utf8(&buf.copy_to_bytes(COSTUME_NAME_SIZE)[..])?
|
||||
.to_string(),
|
||||
};
|
||||
buf.advance(3);
|
||||
packet
|
||||
}
|
||||
4 => PacketData::Game {
|
||||
is_2d: buf.get_u8() != 0,
|
||||
scenario_num: buf.get_u8(),
|
||||
stage: std::str::from_utf8(&buf.copy_to_bytes(COSTUME_NAME_SIZE)[..])?.to_string(),
|
||||
stage: buf_size_to_string(buf, STAGE_GAME_NAME_SIZE)?,
|
||||
},
|
||||
5 => PacketData::Tag {
|
||||
update_type: if buf.get_u8() == 1 {
|
||||
@@ -222,41 +252,38 @@ where
|
||||
TagUpdate::State
|
||||
},
|
||||
is_it: buf.get_u8() != 0,
|
||||
seconds: buf.get_u8(),
|
||||
seconds: buf.get_u16_le(),
|
||||
minutes: buf.get_u16_le(),
|
||||
},
|
||||
6 => {
|
||||
tracing::debug!("Parsing connect: {}", buf.remaining());
|
||||
let c_type = if buf.get_u32_le() == 0 {
|
||||
ConnectionType::FirstConnection
|
||||
} else {
|
||||
ConnectionType::Reconnecting
|
||||
};
|
||||
let max_player = buf.get_u16_le();
|
||||
let str_bytes = &buf.copy_to_bytes(CLIENT_NAME_SIZE)[..];
|
||||
log::info!("Str bytes! {:x?}", str_bytes);
|
||||
log::info!("From utf8! {:?}", std::str::from_utf8(str_bytes));
|
||||
let client_name = buf_size_to_string(buf, CLIENT_NAME_SIZE)?;
|
||||
PacketData::Connect {
|
||||
c_type,
|
||||
max_player,
|
||||
client_name: std::str::from_utf8(str_bytes)?.to_string(),
|
||||
client_name,
|
||||
}
|
||||
}
|
||||
7 => PacketData::Disconnect,
|
||||
8 => PacketData::Costume(Costume {
|
||||
body_name: std::str::from_utf8(&buf.copy_to_bytes(COSTUME_NAME_SIZE)[..])?
|
||||
.to_string(),
|
||||
cap_name: std::str::from_utf8(&buf.copy_to_bytes(COSTUME_NAME_SIZE)[..])?
|
||||
.to_string(),
|
||||
body_name: buf_size_to_string(buf, COSTUME_NAME_SIZE)?,
|
||||
cap_name: buf_size_to_string(buf, COSTUME_NAME_SIZE)?,
|
||||
}),
|
||||
9 => PacketData::Shine {
|
||||
shine_id: buf.get_i32_le(),
|
||||
},
|
||||
10 => PacketData::Capture {
|
||||
model: std::str::from_utf8(&buf.copy_to_bytes(COSTUME_NAME_SIZE)[..])?.to_string(),
|
||||
model: buf_size_to_string(buf, COSTUME_NAME_SIZE)?,
|
||||
},
|
||||
11 => PacketData::ChangeStage {
|
||||
stage: std::str::from_utf8(&buf.copy_to_bytes(STAGE_NAME_SIZE)[..])?.to_string(),
|
||||
id: std::str::from_utf8(&buf.copy_to_bytes(STAGE_ID_SIZE)[..])?.to_string(),
|
||||
stage: buf_size_to_string(buf, STAGE_CHANGE_NAME_SIZE)?,
|
||||
id: buf_size_to_string(buf, STAGE_ID_SIZE)?,
|
||||
scenerio: buf.get_i8(),
|
||||
sub_scenario: buf.get_u8(),
|
||||
},
|
||||
@@ -267,6 +294,15 @@ where
|
||||
},
|
||||
};
|
||||
|
||||
let excess_padding = data.get_size() - p_size as usize;
|
||||
if excess_padding > 0 {
|
||||
tracing::debug!(
|
||||
"Removing extra padding from struct: {} bytes",
|
||||
excess_padding
|
||||
);
|
||||
buf.advance(excess_padding);
|
||||
}
|
||||
|
||||
Ok(Packet {
|
||||
id: id.into(),
|
||||
data_size: p_size,
|
||||
@@ -281,12 +317,12 @@ where
|
||||
{
|
||||
fn encode(&self, buf: &mut W) -> Result<()> {
|
||||
buf.put_slice(&self.id.id[..]);
|
||||
buf.put_u16(self.data.get_type_id());
|
||||
buf.put_u16(self.data_size);
|
||||
buf.put_u16_le(self.data.get_type_id());
|
||||
buf.put_u16_le(self.data_size);
|
||||
match &self.data {
|
||||
PacketData::Unhandled { data, .. } => buf.put_slice(&data[..]),
|
||||
PacketData::Init { max_players } => {
|
||||
buf.put_u16(*max_players);
|
||||
buf.put_u16_le(*max_players);
|
||||
}
|
||||
PacketData::Player {
|
||||
pos,
|
||||
@@ -300,8 +336,8 @@ where
|
||||
for weight in animation_blend_weights {
|
||||
buf.put_f32_le(*weight);
|
||||
}
|
||||
buf.put_u16(*act);
|
||||
buf.put_u16(*sub_act);
|
||||
buf.put_u16_le(*act);
|
||||
buf.put_u16_le(*sub_act);
|
||||
}
|
||||
PacketData::Cap {
|
||||
pos,
|
||||
@@ -312,7 +348,7 @@ where
|
||||
pos.encode(buf)?;
|
||||
rot.encode(buf)?;
|
||||
buf.put_u8((*cap_out).into());
|
||||
buf.put_slice(&cap_anim.as_bytes()[..COSTUME_NAME_SIZE])
|
||||
buf.put_slice(&str_to_sized_array::<CAP_ANIM_SIZE>(cap_anim));
|
||||
}
|
||||
PacketData::Game {
|
||||
is_2d,
|
||||
@@ -321,7 +357,7 @@ where
|
||||
} => {
|
||||
buf.put_u8((*is_2d).into());
|
||||
buf.put_u8(*scenario_num);
|
||||
buf.put_slice(&stage.as_bytes()[..COSTUME_NAME_SIZE])
|
||||
buf.put_slice(&str_to_sized_array::<STAGE_GAME_NAME_SIZE>(stage));
|
||||
}
|
||||
PacketData::Tag {
|
||||
update_type,
|
||||
@@ -330,13 +366,13 @@ where
|
||||
minutes,
|
||||
} => {
|
||||
let tag = match update_type {
|
||||
TagUpdate::Time => 0,
|
||||
TagUpdate::State => 1,
|
||||
TagUpdate::Time => 1,
|
||||
TagUpdate::State => 2,
|
||||
};
|
||||
buf.put_u8(tag);
|
||||
buf.put_u8((*is_it).into());
|
||||
buf.put_u8(*seconds);
|
||||
buf.put_u16(*minutes);
|
||||
buf.put_u16_le(*seconds);
|
||||
buf.put_u16_le(*minutes);
|
||||
}
|
||||
PacketData::Connect {
|
||||
c_type,
|
||||
@@ -347,33 +383,93 @@ where
|
||||
ConnectionType::FirstConnection => 0,
|
||||
ConnectionType::Reconnecting => 1,
|
||||
};
|
||||
buf.put_u8(tag);
|
||||
buf.put_u16(*max_player);
|
||||
buf.put_slice(&client_name.as_bytes()[..COSTUME_NAME_SIZE])
|
||||
buf.put_u32_le(tag);
|
||||
buf.put_u16_le(*max_player);
|
||||
buf.put_slice(&str_to_sized_array::<CLIENT_NAME_SIZE>(client_name));
|
||||
}
|
||||
PacketData::Disconnect => {}
|
||||
PacketData::Costume(Costume {
|
||||
body_name,
|
||||
cap_name,
|
||||
}) => {
|
||||
buf.put_slice(&body_name.as_bytes()[..COSTUME_NAME_SIZE]);
|
||||
buf.put_slice(&cap_name.as_bytes()[..COSTUME_NAME_SIZE]);
|
||||
buf.put_slice(&str_to_sized_array::<COSTUME_NAME_SIZE>(body_name));
|
||||
buf.put_slice(&str_to_sized_array::<COSTUME_NAME_SIZE>(cap_name));
|
||||
}
|
||||
PacketData::Shine { shine_id } => buf.put_i32_le(*shine_id),
|
||||
PacketData::Capture { model } => {
|
||||
buf.put_slice(&str_to_sized_array::<COSTUME_NAME_SIZE>(model))
|
||||
}
|
||||
PacketData::Shine { shine_id } => buf.put_i32(*shine_id),
|
||||
PacketData::Capture { model } => buf.put_slice(&model.as_bytes()[..COSTUME_NAME_SIZE]),
|
||||
PacketData::ChangeStage {
|
||||
stage,
|
||||
id,
|
||||
scenerio,
|
||||
sub_scenario,
|
||||
} => {
|
||||
buf.put_slice(&stage.as_bytes()[..COSTUME_NAME_SIZE]);
|
||||
buf.put_slice(&id.as_bytes()[..COSTUME_NAME_SIZE]);
|
||||
buf.put_slice(&str_to_sized_array::<STAGE_CHANGE_NAME_SIZE>(stage));
|
||||
buf.put_slice(&str_to_sized_array::<STAGE_ID_SIZE>(id));
|
||||
buf.put_i8(*scenerio);
|
||||
buf.put_u8(*sub_scenario);
|
||||
}
|
||||
PacketData::Command => {}
|
||||
}
|
||||
|
||||
let excess_padding = self.data_size as usize - self.data.get_size();
|
||||
if excess_padding > 0 {
|
||||
tracing::debug!("Adding extra padding to struct: {} bytes", excess_padding);
|
||||
for _ in 0..excess_padding {
|
||||
buf.put_u8(0);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn str_to_sized_array<const N: usize>(s: &str) -> [u8; N] {
|
||||
let mut bytes = [0; N];
|
||||
for (b, c) in bytes.iter_mut().zip(s.as_bytes()) {
|
||||
*b = *c;
|
||||
}
|
||||
bytes
|
||||
}
|
||||
|
||||
fn buf_size_to_string(buf: &mut impl Buf, size: usize) -> Result<String> {
|
||||
Ok(std::str::from_utf8(&buf.copy_to_bytes(size)[..])?
|
||||
.trim_matches(char::from(0))
|
||||
.to_string())
|
||||
}
|
||||
|
||||
impl Arbitrary for Packet {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
let mut buff = BytesMut::with_capacity(MAX_PACKET_SIZE);
|
||||
|
||||
let enum_num = g.choose(&options).unwrap();
|
||||
let size = match enum_num {
|
||||
1 => 2,
|
||||
2 => 0x38,
|
||||
3 => 0x50,
|
||||
4 => 0x42,
|
||||
5 => 6,
|
||||
6 => 6 + CLIENT_NAME_SIZE + 2,
|
||||
7 => 0,
|
||||
8 => COSTUME_NAME_SIZE * 2,
|
||||
9 => 4,
|
||||
10 => COSTUME_NAME_SIZE,
|
||||
11 => STAGE_ID_SIZE + STAGE_CHANGE_NAME_SIZE + 2,
|
||||
12 => 0,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
for _ in 0..16 {
|
||||
buff.put_u8(u8::arbitrary(g));
|
||||
}
|
||||
buff.put_u16_le(*enum_num);
|
||||
buff.put_u16_le(size as u16);
|
||||
for _ in 0..size {
|
||||
buff.put_u8(u8::arbitrary(g) % 128);
|
||||
}
|
||||
|
||||
Packet::decode(&mut Cursor::new(buff)).unwrap()
|
||||
}
|
||||
}
|
||||
|
@@ -20,13 +20,13 @@ impl Server {
|
||||
|
||||
let to_coord = self.to_coord.clone();
|
||||
let settings = self.settings.clone();
|
||||
log::info!("New client attempting to connect");
|
||||
tracing::info!("New client attempting to connect");
|
||||
|
||||
tokio::spawn(async move {
|
||||
let cli_result = Client::initialize_client(socket, to_coord, settings).await;
|
||||
|
||||
if let Err(e) = cli_result {
|
||||
log::warn!("Client failed to begin: {}", e)
|
||||
tracing::warn!("Client failed to begin: {}", e)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
1
src/test/mockclient.rs
Normal file
1
src/test/mockclient.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub struct MockClient {}
|
@@ -1,5 +1,14 @@
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Costume {
|
||||
pub body_name: String,
|
||||
pub cap_name: String,
|
||||
}
|
||||
|
||||
impl Default for Costume {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
body_name: "Mario".to_string(),
|
||||
cap_name: "Mario".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
tests/serialization.rs
Normal file
31
tests/serialization.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
use quickcheck::quickcheck;
|
||||
use smoo::cmds::TagCommand;
|
||||
use smoo::guid::Guid;
|
||||
use smoo::net::encoding::{Decodable, Encodable};
|
||||
use smoo::net::{Packet, TagUpdate};
|
||||
|
||||
// quickcheck! {
|
||||
// fn round_trip(p: Packet) -> bool {
|
||||
// let mut buff = BytesMut::with_capacity(1000);
|
||||
// p.encode(&mut buff).map(|_| Packet::decode(&mut buff).map(|de_p| de_p == p).unwrap_or(false)).unwrap_or(false)
|
||||
// }
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn bad_tag_packet() {
|
||||
let bad_data = b"~\x80W4\xba-\0\x10\xaf\xed_\xea\xc5h\x15K\x03\0P\00v\xa5E\0\0\xf0B\xa1R\x9fE\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01FlyingWaitR\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xccL>";
|
||||
|
||||
let mut bytes = BytesMut::with_capacity(150);
|
||||
bytes.put(&bad_data[..]);
|
||||
|
||||
println!("Buff len {}", bytes.len());
|
||||
|
||||
let bad_packet = Packet::decode(&mut bytes).unwrap();
|
||||
|
||||
let mut buff = BytesMut::with_capacity(300);
|
||||
println!("Buff len {}", buff.len());
|
||||
bad_packet.encode(&mut buff).unwrap();
|
||||
let decode = Packet::decode(&mut buff).unwrap();
|
||||
assert_eq!(bad_packet, decode)
|
||||
}
|
Reference in New Issue
Block a user