Revert "54 adjust the sender so that the random name is output to the user" #85
12 changed files with 11 additions and 547 deletions
324
Cargo.lock
generated
324
Cargo.lock
generated
|
|
@ -419,7 +419,6 @@ dependencies = [
|
|||
"flume",
|
||||
"futures-util",
|
||||
"headers",
|
||||
"hex",
|
||||
"hmac",
|
||||
"local-ip-address",
|
||||
"p256",
|
||||
|
|
@ -428,7 +427,6 @@ dependencies = [
|
|||
"prost-types",
|
||||
"qr2term",
|
||||
"rand",
|
||||
"reqwest",
|
||||
"sanitize-filename",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
@ -576,16 +574,6 @@ version = "0.9.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.6"
|
||||
|
|
@ -790,15 +778,6 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
|
|
@ -854,21 +833,6 @@ version = "1.0.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
dependencies = [
|
||||
"foreign-types-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.1"
|
||||
|
|
@ -895,7 +859,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -915,12 +878,6 @@ dependencies = [
|
|||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.30"
|
||||
|
|
@ -951,11 +908,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-macro",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
|
|
@ -1037,25 +992,6 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"http 1.1.0",
|
||||
"indexmap 2.2.6",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
|
|
@ -1119,12 +1055,6 @@ version = "0.3.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "hkdf"
|
||||
version = "0.12.4"
|
||||
|
|
@ -1227,7 +1157,7 @@ dependencies = [
|
|||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2 0.3.26",
|
||||
"h2",
|
||||
"http 0.2.12",
|
||||
"http-body 0.4.6",
|
||||
"httparse",
|
||||
|
|
@ -1250,7 +1180,6 @@ dependencies = [
|
|||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"h2 0.4.4",
|
||||
"http 1.1.0",
|
||||
"http-body 1.0.0",
|
||||
"httparse",
|
||||
|
|
@ -1259,7 +1188,6 @@ dependencies = [
|
|||
"pin-project-lite",
|
||||
"smallvec",
|
||||
"tokio",
|
||||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1274,22 +1202,6 @@ dependencies = [
|
|||
"tokio-io-timeout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-tls"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http-body-util",
|
||||
"hyper 1.3.1",
|
||||
"hyper-util",
|
||||
"native-tls",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-util"
|
||||
version = "0.1.3"
|
||||
|
|
@ -1297,7 +1209,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"http 1.1.0",
|
||||
"http-body 1.0.0",
|
||||
|
|
@ -1305,9 +1216,6 @@ dependencies = [
|
|||
"pin-project-lite",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1372,12 +1280,6 @@ dependencies = [
|
|||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
|
|
@ -1521,24 +1423,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"openssl",
|
||||
"openssl-probe",
|
||||
"openssl-sys",
|
||||
"schannel",
|
||||
"security-framework",
|
||||
"security-framework-sys",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "neli"
|
||||
version = "0.6.4"
|
||||
|
|
@ -1620,50 +1504,6 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"cfg-if",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"openssl-macros",
|
||||
"openssl-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-probe"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.102"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "opentelemetry"
|
||||
version = "0.21.0"
|
||||
|
|
@ -1829,12 +1669,6 @@ dependencies = [
|
|||
"spki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
||||
|
||||
[[package]]
|
||||
name = "polyval"
|
||||
version = "0.6.2"
|
||||
|
|
@ -2069,49 +1903,6 @@ version = "0.8.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10"
|
||||
dependencies = [
|
||||
"base64 0.22.0",
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2 0.4.4",
|
||||
"http 1.1.0",
|
||||
"http-body 1.0.0",
|
||||
"http-body-util",
|
||||
"hyper 1.3.1",
|
||||
"hyper-tls",
|
||||
"hyper-util",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
"log",
|
||||
"mime",
|
||||
"native-tls",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rustls-pemfile",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"sync_wrapper 0.1.2",
|
||||
"system-configuration",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tower-service",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"winreg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rfc6979"
|
||||
version = "0.4.0"
|
||||
|
|
@ -2170,16 +1961,6 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pemfile"
|
||||
version = "2.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d"
|
||||
dependencies = [
|
||||
"base64 0.22.0",
|
||||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.5.0"
|
||||
|
|
@ -2219,15 +2000,6 @@ dependencies = [
|
|||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "schannel"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
|
|
@ -2248,29 +2020,6 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"core-foundation",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"security-framework-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "security-framework-sys"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.22"
|
||||
|
|
@ -2645,27 +2394,6 @@ version = "1.0.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
|
||||
|
||||
[[package]]
|
||||
name = "system-configuration"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"core-foundation",
|
||||
"system-configuration-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-configuration-sys"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.10.1"
|
||||
|
|
@ -2772,16 +2500,6 @@ dependencies = [
|
|||
"syn 2.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-native-tls"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
|
||||
dependencies = [
|
||||
"native-tls",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-rustls"
|
||||
version = "0.25.0"
|
||||
|
|
@ -2845,7 +2563,7 @@ dependencies = [
|
|||
"axum 0.6.20",
|
||||
"base64 0.21.7",
|
||||
"bytes",
|
||||
"h2 0.3.26",
|
||||
"h2",
|
||||
"http 0.2.12",
|
||||
"http-body 0.4.6",
|
||||
"hyper 0.14.28",
|
||||
|
|
@ -3142,12 +2860,6 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
|
|
@ -3200,18 +2912,6 @@ dependencies = [
|
|||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.92"
|
||||
|
|
@ -3241,16 +2941,6 @@ version = "0.2.92"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-time"
|
||||
version = "0.2.4"
|
||||
|
|
@ -3440,16 +3130,6 @@ version = "0.52.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.7.0"
|
||||
|
|
|
|||
|
|
@ -47,8 +47,6 @@ tower = { version = "0.4", features = ["util"] }
|
|||
shuttle-axum = { version = "0.44.0" }
|
||||
shuttle-runtime = { version = "0.44.0" }
|
||||
dotenvy = "0.15.7"
|
||||
hex = "0.4.3"
|
||||
reqwest = { version = "0.12.4", features = ["json", "blocking"] }
|
||||
|
||||
[build-dependencies]
|
||||
prost-build = "0.12.4"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use std::{collections::HashMap, sync::Arc};
|
|||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::relay::room::Room;
|
||||
use crate::relay::transfer::Transfer;
|
||||
|
||||
/// A struct that holds all of the rooms that the server knows about.
|
||||
///
|
||||
|
|
@ -12,7 +11,6 @@ use crate::relay::transfer::Transfer;
|
|||
#[derive(Debug)]
|
||||
pub struct AppState {
|
||||
pub rooms: HashMap<String, Room>,
|
||||
pub transfers: Vec<Transfer>,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
|
|
@ -46,15 +44,15 @@ impl AppState {
|
|||
Arc::new(RwLock::new(AppState {
|
||||
// Initialize the list of rooms to be empty.
|
||||
rooms: HashMap::new(),
|
||||
transfers: Vec::new(),
|
||||
}))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc};
|
||||
|
||||
#[test]
|
||||
fn test_new() {
|
||||
|
|
@ -62,4 +60,4 @@ mod tests {
|
|||
|
||||
assert!(Arc::ptr_eq(&app_state, &app_state.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -491,5 +491,6 @@ impl Client {
|
|||
// TODO: Add tests
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// use super::*;
|
||||
}
|
||||
use super::*;
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ pub mod appstate;
|
|||
pub mod client;
|
||||
pub mod room;
|
||||
pub mod server;
|
||||
pub mod transfer;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,15 +16,13 @@
|
|||
/// and running the application. If the server fails to bind to the specified
|
||||
/// host and port, it logs an error and exits.
|
||||
use axum::{
|
||||
extract::{ws::WebSocket, Json, Path, State, WebSocketUpgrade},
|
||||
http::StatusCode,
|
||||
extract::{ws::WebSocket, State, WebSocketUpgrade},
|
||||
response::IntoResponse,
|
||||
routing::{get, post},
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
|
||||
use futures_util::StreamExt;
|
||||
use serde_json::json;
|
||||
use std::{env, net::SocketAddr, sync::Arc};
|
||||
use tokio::{
|
||||
net::TcpListener,
|
||||
|
|
@ -36,7 +34,6 @@ use tracing::{debug, error, info, warn};
|
|||
|
||||
use crate::relay::appstate::AppState;
|
||||
use crate::relay::client::Client;
|
||||
use crate::relay::transfer::Transfer;
|
||||
|
||||
/// This function starts the WebSocket server.
|
||||
///
|
||||
|
|
@ -98,9 +95,6 @@ pub async fn start_ws(port: Option<&i32>, listen_addr: Option<&String>) {
|
|||
// Set up the application routes.
|
||||
let app = Router::new()
|
||||
.route("/ws", get(ws_handler))
|
||||
.route("/upload", post(upload_info))
|
||||
.route("/download/:name", get(download_info))
|
||||
.route("/download_success/:name", post(download_success))
|
||||
.with_state(server)
|
||||
.layer(
|
||||
TraceLayer::new_for_http()
|
||||
|
|
@ -278,77 +272,3 @@ async fn shutdown_signal() {
|
|||
_ = terminate => {},
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn upload_info(
|
||||
State(shared_state): State<Arc<RwLock<AppState>>>,
|
||||
// ConnectInfo(addr): ConnectInfo<SocketAddr>,
|
||||
Json(payload): Json<Transfer>,
|
||||
) -> impl IntoResponse {
|
||||
// debug!("Got upload request from {}", addr.ip().to_string());
|
||||
let mut data = shared_state.write().await;
|
||||
let t_request = Transfer {
|
||||
name: payload.name,
|
||||
ip: payload.ip,
|
||||
room_id: payload.room_id,
|
||||
};
|
||||
data.transfers.push(t_request.clone());
|
||||
|
||||
debug!("New TransferRequest created");
|
||||
debug!("Actual AppState is {:#?}", *data);
|
||||
|
||||
(StatusCode::CREATED, Json(t_request))
|
||||
}
|
||||
|
||||
pub async fn download_info(
|
||||
State(shared_state): State<Arc<RwLock<AppState>>>,
|
||||
Path(name): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
let data = shared_state.write().await;
|
||||
match data.transfers.iter().find(|request| request.name == name) {
|
||||
Some(request) => {
|
||||
debug!("Found transfer name.");
|
||||
(StatusCode::OK, Json(request.clone()))
|
||||
}
|
||||
None => {
|
||||
warn!("couldn't find transfer-name: {}", name);
|
||||
(
|
||||
StatusCode::NOT_FOUND,
|
||||
Json(Transfer {
|
||||
name: String::from(""),
|
||||
ip: String::from(""),
|
||||
room_id: String::from(""),
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn download_success(
|
||||
State(shared_state): State<Arc<RwLock<AppState>>>,
|
||||
Path(name): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
let mut data = shared_state.write().await;
|
||||
if let Some(index) = data
|
||||
.transfers
|
||||
.iter()
|
||||
.position(|request| request.name == name)
|
||||
{
|
||||
debug!("Found Transfer by name '{name}'");
|
||||
data.transfers.remove(index);
|
||||
debug!("Transfer deleted");
|
||||
(
|
||||
StatusCode::OK,
|
||||
Json(json!({
|
||||
"message": "transfer deleted"
|
||||
})),
|
||||
)
|
||||
} else {
|
||||
warn!("couldn't find transfer-name: {}", name);
|
||||
(
|
||||
StatusCode::NOT_FOUND,
|
||||
Json(json!({
|
||||
"message": "transfer not found"
|
||||
})),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct Transfer {
|
||||
pub name: String,
|
||||
pub ip: String,
|
||||
pub room_id: String,
|
||||
}
|
||||
|
||||
impl Transfer {
|
||||
pub fn new(name: String, ip: String, room_id: String) -> Self {
|
||||
Self { name, ip, room_id }
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_new() {
|
||||
let transfer = Transfer {
|
||||
name: "Test".to_string(),
|
||||
ip: "127.0.0.1".to_string(),
|
||||
room_id: "This_is_a_test_room_id".to_string(),
|
||||
};
|
||||
assert_eq!(
|
||||
Transfer::new(
|
||||
"Test".to_string(),
|
||||
"127.0.0.1".to_string(),
|
||||
"This_is_a_test_room_id".to_string()
|
||||
),
|
||||
transfer
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
use crate::sender::http_client::send_info;
|
||||
use crate::sender::util::{generate_random_name, hash_random_name};
|
||||
use crate::shared::{
|
||||
packets::{
|
||||
list_packet, packet::Value, ChunkPacket, HandshakePacket, HandshakeResponsePacket,
|
||||
|
|
@ -123,11 +121,6 @@ fn on_create_room(context: &Context, id: String) -> Status {
|
|||
let base64 = general_purpose::STANDARD.encode(&context.hmac);
|
||||
let url = format!("{}-{}", id, base64);
|
||||
|
||||
let rand_name = generate_random_name();
|
||||
let hash_name = hash_random_name(rand_name.clone());
|
||||
|
||||
let res = send_info("http://localhost:8000", &hash_name, url.as_str());
|
||||
debug!("Got Result: {:#?}", res);
|
||||
// Print a newline to the console to separate the output from the command
|
||||
// line.
|
||||
println!();
|
||||
|
|
@ -144,7 +137,6 @@ fn on_create_room(context: &Context, id: String) -> Status {
|
|||
|
||||
// Print a message to the console with the URL.
|
||||
println!("Created room: {}", url);
|
||||
println!("Transfername is: {}", rand_name);
|
||||
|
||||
// Continue the event loop.
|
||||
Status::Continue()
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
use std::collections::HashMap;
|
||||
use tracing::error;
|
||||
|
||||
use local_ip_address::{local_ip, local_ipv6};
|
||||
use reqwest::blocking::Client;
|
||||
|
||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
pub fn send_info(relay: &str, name: &str, room_id: &str) -> Result<String> {
|
||||
let sender_ip = match local_ipv6() {
|
||||
Ok(ip) => ip,
|
||||
Err(_) => match local_ip() {
|
||||
Ok(ip) => ip,
|
||||
Err(e) => {
|
||||
error!("Error getting local ip: {e:?}");
|
||||
return Err(Box::new(e));
|
||||
}
|
||||
},
|
||||
};
|
||||
let ip_str = sender_ip.to_owned().to_string();
|
||||
let mut map = HashMap::new();
|
||||
map.insert("name", String::from(name));
|
||||
map.insert("ip", ip_str);
|
||||
map.insert("room_id", String::from(room_id));
|
||||
let client = Client::new();
|
||||
let _ = match client.post(format!("{}/upload", relay)).json(&map).send() {
|
||||
Ok(_) => Ok(room_id.to_string()),
|
||||
Err(e) => Err(Box::new(e)),
|
||||
};
|
||||
Ok("".to_string())
|
||||
}
|
||||
|
|
@ -39,8 +39,6 @@
|
|||
/// The `start` function takes ownership of the `WebSocketStream` and the file
|
||||
/// paths, so we pass it the `paths` vector by value.
|
||||
pub mod client;
|
||||
pub mod http_client;
|
||||
pub mod util;
|
||||
|
||||
use crate::sender::client as sender;
|
||||
use tokio_tungstenite::{
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
use hex;
|
||||
use rand::{seq::SliceRandom, thread_rng};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
pub fn generate_random_name() -> String {
|
||||
let mut rng = thread_rng();
|
||||
let adjective = adjectives().choose(&mut rng).unwrap();
|
||||
// let adjective = adjectives().sample(&mut rng).unwrap();
|
||||
let noun1 = nouns1().choose(&mut rng).unwrap();
|
||||
let noun2 = nouns2().choose(&mut rng).unwrap();
|
||||
|
||||
format!("{adjective}-{noun1}-{noun2}")
|
||||
}
|
||||
|
||||
fn adjectives() -> &'static [&'static str] {
|
||||
static ADJECTIVES: &[&str] = &["funny", "smart", "creative", "friendly", "great"];
|
||||
ADJECTIVES
|
||||
}
|
||||
|
||||
fn nouns1() -> &'static [&'static str] {
|
||||
static NOUNS1: &[&str] = &["dog", "cat", "flower", "tree", "house"];
|
||||
NOUNS1
|
||||
}
|
||||
|
||||
fn nouns2() -> &'static [&'static str] {
|
||||
static NOUNS2: &[&str] = &["cookie", "cake", "frosting"];
|
||||
NOUNS2
|
||||
}
|
||||
|
||||
pub fn hash_random_name(name: String) -> String {
|
||||
let hashed_name = Sha256::digest(name.as_bytes());
|
||||
return hex::encode(hashed_name);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_generate_random_name() {
|
||||
let name = generate_random_name();
|
||||
|
||||
assert!(name.contains('-'));
|
||||
assert!(name.split('-').count() == 3);
|
||||
assert!(name.len() > 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,6 @@
|
|||
use crate::relay::appstate::AppState;
|
||||
use crate::relay::server::download_info;
|
||||
use crate::relay::server::download_success;
|
||||
use crate::relay::server::upload_info;
|
||||
use crate::relay::server::ws_handler;
|
||||
use axum::{
|
||||
routing::{get, post},
|
||||
Router,
|
||||
};
|
||||
use axum::{routing::get, Router};
|
||||
use axum_client_ip::SecureClientIpSource;
|
||||
use shuttle_axum::ShuttleAxum;
|
||||
|
||||
|
|
@ -23,9 +17,6 @@ async fn axum() -> ShuttleAxum {
|
|||
// Set up the application routes.
|
||||
let app = Router::new()
|
||||
.route("/ws", get(ws_handler))
|
||||
.route("/upload", post(upload_info))
|
||||
.route("/download/:name", get(download_info))
|
||||
.route("/download_success/:name", post(download_success))
|
||||
.with_state(appstate)
|
||||
.layer(SecureClientIpSource::ConnectInfo.into_extension());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue