Lots of networking work

This commit is contained in:
Kirill Shakirov
2026-03-01 20:16:02 +01:00
parent 0e318415a7
commit 5409c3597a
6 changed files with 1084 additions and 34 deletions
+734
View File
@@ -2,12 +2,278 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 4 version = 4
[[package]]
name = "anstream"
version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
[[package]]
name = "anstyle-parse"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys 0.61.2",
]
[[package]]
name = "bitflags"
version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "bytes"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.4" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "clap"
version = "4.5.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63be97961acde393029492ce0be7a1af7e323e6bae9511ebfac33751be5e6806"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f13174bda5dfd69d7e947827e5af4b0f2f94a4a3ee92912fba07a66150f21e2"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831"
[[package]]
name = "colorchoice"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
[[package]]
name = "cpufeatures"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
dependencies = [
"libc",
]
[[package]]
name = "crypto-common"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "data-encoding"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea"
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "errno"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.61.2",
]
[[package]]
name = "futures"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
name = "futures-core"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
[[package]]
name = "futures-executor"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-io"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718"
[[package]]
name = "futures-macro"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "futures-sink"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893"
[[package]]
name = "futures-task"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
[[package]]
name = "futures-util"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"slab",
]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.3.4" version = "0.3.4"
@@ -20,20 +286,144 @@ dependencies = [
"wasip2", "wasip2",
] ]
[[package]]
name = "hashbrown"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "http"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a"
dependencies = [
"bytes",
"itoa",
]
[[package]]
name = "httparse"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
[[package]]
name = "indexmap"
version = "2.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "itoa"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.180" version = "0.2.180"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
[[package]]
name = "lock_api"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "memchr"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]]
name = "mio"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc"
dependencies = [
"libc",
"wasi",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "nyash_server" name = "nyash_server"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"clap",
"futures",
"log",
"rand", "rand",
"redb", "redb",
"serde",
"tokio",
"tokio-tungstenite",
"toml",
] ]
[[package]]
name = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "parking_lot"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-link",
]
[[package]]
name = "pin-project-lite"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.21" version = "0.2.21"
@@ -105,6 +495,109 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "redox_syscall"
version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
dependencies = [
"bitflags",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_spanned"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776"
dependencies = [
"serde_core",
]
[[package]]
name = "sha1"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
dependencies = [
"errno",
"libc",
]
[[package]]
name = "slab"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
[[package]]
name = "smallvec"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "socket2"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0"
dependencies = [
"libc",
"windows-sys 0.60.2",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.114" version = "2.0.114"
@@ -116,12 +609,158 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "thiserror"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tokio"
version = "1.49.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86"
dependencies = [
"bytes",
"libc",
"mio",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys 0.61.2",
]
[[package]]
name = "tokio-macros"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tokio-tungstenite"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d25a406cddcc431a75d3d9afc6a7c0f7428d4891dd973e4d54c56b46127bf857"
dependencies = [
"futures-util",
"log",
"tokio",
"tungstenite",
]
[[package]]
name = "toml"
version = "1.0.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbe30f93627849fa362d4a602212d41bb237dc2bd0f8ba0b2ce785012e124220"
dependencies = [
"indexmap",
"serde_core",
"serde_spanned",
"toml_datetime",
"toml_parser",
"toml_writer",
"winnow",
]
[[package]]
name = "toml_datetime"
version = "1.0.0+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32c2555c699578a4f59f0cc68e5116c8d7cabbd45e1409b989d4be085b53f13e"
dependencies = [
"serde_core",
]
[[package]]
name = "toml_parser"
version = "1.0.8+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0742ff5ff03ea7e67c8ae6c93cac239e0d9784833362da3f9a9c1da8dfefcbdc"
dependencies = [
"winnow",
]
[[package]]
name = "toml_writer"
version = "1.0.6+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607"
[[package]]
name = "tungstenite"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8628dcc84e5a09eb3d8423d6cb682965dea9133204e8fb3efee74c2a0c259442"
dependencies = [
"bytes",
"data-encoding",
"http",
"httparse",
"log",
"rand",
"sha1",
"thiserror",
"utf-8",
]
[[package]]
name = "typenum"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.22" version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
[[package]]
name = "utf-8"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "wasi"
version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]] [[package]]
name = "wasip2" name = "wasip2"
version = "1.0.2+wasi-0.2.9" version = "1.0.2+wasi-0.2.9"
@@ -131,6 +770,101 @@ dependencies = [
"wit-bindgen", "wit-bindgen",
] ]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.60.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[[package]]
name = "windows-targets"
version = "0.53.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
dependencies = [
"windows-link",
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
[[package]]
name = "windows_aarch64_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
[[package]]
name = "windows_i686_gnu"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
[[package]]
name = "windows_i686_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
[[package]]
name = "windows_i686_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
[[package]]
name = "windows_x86_64_gnu"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
[[package]]
name = "windows_x86_64_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
[[package]]
name = "winnow"
version = "0.7.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829"
[[package]] [[package]]
name = "wit-bindgen" name = "wit-bindgen"
version = "0.51.0" version = "0.51.0"
+7
View File
@@ -4,5 +4,12 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
clap = { version = "4.5.58", features = ["derive"] }
futures = "0.3.32"
log = "0.4.29"
rand = "0.9.2" rand = "0.9.2"
redb = "3.1.0" redb = "3.1.0"
serde = { version = "1.0.228", features = ["derive"] }
tokio = { version = "1.49.0", features = ["full"] }
tokio-tungstenite = "0.28.0"
toml = "1.0.1"
+31
View File
@@ -0,0 +1,31 @@
use std::{ops::Not, path::Path, u64, u128};
use serde::Deserialize;
const DB_DIR: &str = "/var/lib/nyash-aes-xts256-plain64/";
#[derive(Deserialize, Debug)]
pub struct ServerConfig {
pub bind_addr: String,
pub listen_port: u16,
pub db_dir: Option<String>,
//keys: Keys,
}
// #[derive(Deserialize, Debug)]
// struct Keys {
// github: String,
// travis: Option<String>,
// }
pub fn read_config(file_path: &Path) -> Result<ServerConfig, Box<dyn std::error::Error>> {
let config_str = std::fs::read_to_string(file_path)?;
let mut serer_config: ServerConfig = toml::from_str(&config_str)?;
serer_config.db_dir = serer_config.db_dir.or_else(|| Some(DB_DIR.to_string()));
println!("IP: {}", serer_config.bind_addr);
println!("Listen port: {:?}", serer_config.listen_port);
Ok(serer_config)
}
+12 -12
View File
@@ -4,7 +4,7 @@ use redb::{
Database, ReadableDatabase, ReadableTable, ReadableTableMetadata, TableDefinition Database, ReadableDatabase, ReadableTable, ReadableTableMetadata, TableDefinition
}; };
// use std::collections::HashMap; // use std::collections::HashMap;
use std::{ops::Not,path::Path, u64, u128}; use std::{ops::Not, path::Path, u64, u128};
//tables defenition //tables defenition
const DB_FILE: &str = "./data"; const DB_FILE: &str = "./data";
@@ -24,13 +24,13 @@ fn get_timestump() -> u64 {
} }
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
struct JobRecord { pub struct JobRecord {
id: u64, pub id: u64,
range_id: u16, pub range_id: u16,
tweak_key: u128, pub tweak_key: u128,
start_key: u128, pub start_key: u128,
len: u64, pub len: u64,
start_time: u64, pub start_time: u64,
} }
impl JobRecord { impl JobRecord {
@@ -344,7 +344,7 @@ impl<'a> RangesTable<'a> {
} }
fn db_create_job(db: &Database, pref_job_size: u64) -> Result<Option<JobRecord>, redb::Error> { pub fn db_create_job(db: &Database, pref_job_size: u64) -> Result<Option<JobRecord>, redb::Error> {
let transct = db.begin_write()?; let transct = db.begin_write()?;
// 1. look for abandonent jobs // 1. look for abandonent jobs
@@ -410,7 +410,7 @@ fn db_create_job(db: &Database, pref_job_size: u64) -> Result<Option<JobRecord>,
// returns false if no such job found in DB // returns false if no such job found in DB
fn db_commit_job(db: &Database, job_id: u64) -> Result<bool, redb::Error> { pub fn db_commit_job(db: &Database, job_id: u64) -> Result<bool, redb::Error> {
let transct: redb::WriteTransaction = db.begin_write()?; let transct: redb::WriteTransaction = db.begin_write()?;
let job_found = { let job_found = {
@@ -444,7 +444,7 @@ fn db_commit_job(db: &Database, job_id: u64) -> Result<bool, redb::Error> {
} }
fn db_get_progress(db: &Database) -> Result<f64, redb::Error> { pub fn db_get_progress(db: &Database) -> Result<f64, redb::Error> {
let trx: redb::ReadTransaction = db.begin_read()?; let trx: redb::ReadTransaction = db.begin_read()?;
let progress = { let progress = {
let ranges_t = trx.open_table(RANGES)?; let ranges_t = trx.open_table(RANGES)?;
@@ -479,7 +479,7 @@ fn db_init(db: &Database) -> Result<(), redb::Error> {
Ok(()) Ok(())
} }
fn db_open(db_file_path: &Path) -> Result<Database, redb::Error> { pub fn db_open(db_file_path: &Path) -> Result<Database, redb::Error> {
let db = Database::create(db_file_path)?; let db = Database::create(db_file_path)?;
let trx = db.begin_read()?; let trx = db.begin_read()?;
let ranges_len = { let ranges_len = {
+296 -22
View File
@@ -1,35 +1,309 @@
use clap::Parser;
use tokio_tungstenite::tungstenite::Utf8Bytes;
use std::str::FromStr;
use std::{path::PathBuf};
use log;
use redb;
use tokio::net::{TcpListener, TcpStream};
use tokio_tungstenite::{accept_async, tungstenite::protocol::Message};
use futures::{StreamExt, SinkExt};
use std::env;
use std::net::SocketAddr;
mod config;
mod num_utils; mod num_utils;
mod database; mod database;
fn read_config() -> (){ /// Server for AES-XTS distributed bruteforce
#[derive(clap::Parser, Debug)]
#[command(version, about, long_about = None)]
struct ProgArgs {
/// Config file name
#[arg(short, long, default_value = "/etc/nyash_aes_d.conf")]
config: PathBuf,
} }
fn main() {
println!("Hello, world!");
let a = 1855454745u128.to_le_bytes();
let b = 1u32.to_le_bytes();
//let c = u32::from_le_bytes(a[0..4].try_into().unwrap());
println!("{:?}", a);
println!("{:?}", b);
let (c,r) = a.as_chunks::<4>();
println!("{:?}", c);
println!("{:?}", r);
let a1 = 128u32;
let e = a1.min(u32::MAX);
println!("e = {}",e);
for i in 0..=u16::MAX { #[derive(Debug)]
println!("{}", i); enum ProtocolParseError {
ParseIntError(std::num::ParseIntError),
WrongFormat(usize),
}
impl From<std::num::ParseIntError> for ProtocolParseError {
fn from(err: std::num::ParseIntError) -> Self {
ProtocolParseError::ParseIntError(err)
}
}
impl From<usize> for ProtocolParseError {
fn from(err: usize) -> Self {
ProtocolParseError::WrongFormat(err)
}
}
#[derive(Copy, Clone, Debug)]
struct NyashWorkRequest {
pref_job_size: u64,
}
impl NyashWorkRequest {
pub const HEADER: &str = "WORK_REQUEST";
pub fn to_msg(&self) -> String {
return format!("{} {}", Self::HEADER, self.pref_job_size);
}
pub fn from_msg(mut it: std::str::Split<'_, &str>) -> Result<Self, ProtocolParseError> {
Ok(Self {
pref_job_size: it.next().ok_or(0)?.parse()?,
})
}
}
#[derive(Copy, Clone, Debug)]
struct NyashWorkDone {
job_id: u64,
}
impl NyashWorkDone {
pub const HEADER: &str = "WORK_DONE";
pub fn to_msg(&self) -> String {
return format!("{} {}", Self::HEADER, self.job_id);
}
pub fn from_msg(mut it: std::str::Split<'_, &str>) -> Result<Self, ProtocolParseError> {
Ok(Self {
job_id: it.next().ok_or(0)?.parse()?,
})
}
}
enum NyashReq {
NyashWorkRequest(NyashWorkRequest),
NyashWorkDone(NyashWorkDone),
}
#[derive(Copy, Clone, Debug)]
struct NyashWorkResp {
job_id: u64,
tweak_key: u128,
start_key: u128,
len: u64,
}
impl NyashWorkResp {
pub const HEADER: &str = "WORK_RESP";
pub fn from_job_record(jr: &database::JobRecord) -> Self {
Self {
job_id: jr.id,
tweak_key: jr.tweak_key,
start_key: jr.start_key,
len: jr.len,
}
}
pub fn to_msg(&self) -> String {
return format!("{} {} {} {} {}", Self::HEADER, self.job_id, self.tweak_key, self.start_key, self.len);
}
pub fn from_msg(mut it: std::str::Split<'_, &str>) -> Result<Self, ProtocolParseError> {
Ok(Self {
job_id: it.next().ok_or(0)?.parse()?,
tweak_key: it.next().ok_or(0)?.parse()?,
start_key: it.next().ok_or(0)?.parse()?,
len: it.next().ok_or(0)?.parse()?,
})
}
}
#[derive(Copy, Clone, Debug)]
struct NyashErrorResp {
code: u32,
}
impl NyashErrorResp {
pub const HEADER: &str = "ERROR";
pub fn to_msg(&self) -> String {
return format!("{} {}", Self::HEADER, self.code);
}
pub fn from_msg(mut it: std::str::Split<'_, &str>) -> Result<Self, ProtocolParseError> {
Ok(Self {
code: it.next().ok_or(0)?.parse()?,
})
}
}
#[derive(Copy, Clone, Debug)]
struct NyashOkResp {}
impl NyashOkResp {
pub const HEADER: &str = "OK";
pub fn to_msg(&self) -> String {
return format!("{}", Self::HEADER);
}
}
#[derive(Copy, Clone, Debug)]
struct NyashNoWorkResp {
code: u32,
}
impl NyashNoWorkResp {
pub const HEADER: &str = "NO_WORK";
pub fn to_msg(&self) -> String {
return format!("{} {}", Self::HEADER, self.code);
}
pub fn from_msg(mut it: std::str::Split<'_, &str>) -> Result<Self, ProtocolParseError> {
Ok(Self {
code: it.next().ok_or(0)?.parse()?,
})
}
}
enum NyashResp {
NyashWorkResp(NyashWorkResp),
NyashErrorResp(NyashErrorResp),
NyashNoWorkResp(NyashNoWorkResp),
}
fn parse_message(mut it: std::str::Split<'_, &str>) -> Result<NyashReq, ProtocolParseError> {
let code: &str = it.next().ok_or(0)?;
match code {
NyashWorkRequest::HEADER => Ok(NyashReq::NyashWorkRequest(NyashWorkRequest::from_msg(it)?)),
NyashWorkDone::HEADER => Ok(NyashReq::NyashWorkDone(NyashWorkDone::from_msg(it)?)),
_ => Err(ProtocolParseError::WrongFormat(0))
}
}
async fn handle_connection(stream: TcpStream, db: &redb::Database) {
// Accept the WebSocket connection
let ws_stream = match accept_async(stream).await {
Ok(ws) => ws,
Err(e) => {
println!("Error during the websocket handshake: {}", e);
return;
}
};
// Split the WebSocket stream into a sender and receiver
let (mut sender, mut receiver) = ws_stream.split();
// Handle incoming messages
while let Some(msg) = receiver.next().await {
match msg {
Ok(Message::Text(text)) => {
// Reverse the received string and send it back
let str_text = text.to_string();
println!("Got text: {}", str_text);
//let mesg = parse_message(str_text.split(" "));
match parse_message(str_text.split(" ")) {
Ok(NyashReq::NyashWorkDone(wrk_done)) => {
let res = database::db_commit_job(db, wrk_done.job_id);
match res {
Ok(_) => {
if let Err(e) = sender.send(Message::Text(NyashOkResp::HEADER.into())).await {
println!("Error sending message: {}", e);
}
},
Err(ex) => {
println!("Error comiting work: {}", ex);
let rest_str = NyashErrorResp{code: 0}.to_msg();
if let Err(e) = sender.send(Message::Text(rest_str.into())).await {
println!("Error sending message: {}", e);
}
}
}
},
Ok(NyashReq::NyashWorkRequest(wrk_req)) => {
let res = database::db_create_job(db, wrk_req.pref_job_size);
match res {
Ok(Some(job_record)) => {
let rest_str = NyashWorkResp::from_job_record(&job_record).to_msg();
if let Err(e) = sender.send(Message::Text(rest_str.into())).await {
println!("Error sending message: {}", e);
}
},
Ok(None) => {
let rest_str = NyashNoWorkResp{code: 0}.to_msg();
if let Err(e) = sender.send(Message::Text(rest_str.into())).await {
println!("Error sending message: {}", e);
}
},
Err(ex) => {
println!("Error creating job: {}", ex);
let rest_str = NyashErrorResp{code: 0}.to_msg();
if let Err(e) = sender.send(Message::Text(rest_str.into())).await {
println!("Error sending message: {}", e);
}
}
}
},
Err(ex) => println!("Error sending message: {:?}", ex)
}
},
Ok(Message::Close(_)) => break,
Ok(_) => (),
Err(e) => {
println!("Error processing message: {}", e);
break;
}
}
}
}
async fn accept_loop(listener: TcpListener, db: redb::Database) {
while let Ok((stream, _)) = listener.accept().await {
// Spawn a new task for each connection
handle_connection(stream, &db).await;
}
}
// Так. Нам нужно база данныъ с дипазонами всей фигни. И сервить её через tls или что-то типо того.
#[tokio::main]
async fn main() {
let args = ProgArgs::parse();
log::error!("Arguments parsed: {:?}", args.config);
println!("Path: {:?}", args.config);
let server_config: config::ServerConfig = config::read_config(&args.config).unwrap();
let db_dir = server_config.db_dir.unwrap();
let db_file = format!("{}data.rdb",db_dir);
let db_path = PathBuf::from_str(db_file.as_str()).unwrap();
let db = database::db_open(&db_path).expect("Error Opening database");
// Get the address to bind to
let addr = format!("{}:{}",server_config.bind_addr, server_config.listen_port);
let addr: SocketAddr = addr.parse().expect("Invalid address");
// Create the TCP listener
let listener = TcpListener::bind(&addr).await.expect("Failed to bind");
println!("Listening on: {}", addr);
let res = tokio::spawn(accept_loop(listener, db)).await;
if res.is_err() {
print!("Something gone wrong! {:?}", res.unwrap_err());
} }
} }
// Так. Нам нужно база данныъ с дипазонами всей фигни. И сервить её через tls или что-то типо того.
+4
View File
@@ -0,0 +1,4 @@
# Nya
bind_addr = "127.0.0.1"
listen_port = 37939