From 46e5fdb7dc57edab3a3098f2dc3a90072390ba1c Mon Sep 17 00:00:00 2001 From: lulin <602814112@qq.com> Date: Wed, 31 Jul 2024 20:54:28 +0800 Subject: [PATCH] add --- .vscode/settings.json | 3 + Cargo.lock | 233 +++++++++- Cargo.toml | 6 +- all_proxy.txt | 0 all_server.json | 612 ++++++++++++++++++++++++++ output.json | 742 ++++++++++++++++++++++++++++++++ run.py | 70 +++ src/bin/conn_num_test_client.rs | 59 +++ src/bin/conn_num_test_server.rs | 32 ++ src/bin/get_all_proxy/main.rs | 84 ++++ src/main.rs | 44 +- 11 files changed, 1855 insertions(+), 30 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 all_proxy.txt create mode 100644 all_server.json create mode 100644 output.json create mode 100644 run.py create mode 100644 src/bin/conn_num_test_client.rs create mode 100644 src/bin/conn_num_test_server.rs create mode 100644 src/bin/get_all_proxy/main.rs diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..14f6030 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.inlineSuggest.showToolbar": "onHover" +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 026c6f5..db4c608 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + [[package]] name = "autocfg" version = "1.1.0" @@ -99,6 +105,12 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + [[package]] name = "encoding_rs" version = "0.8.33" @@ -380,6 +392,16 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.20" @@ -505,6 +527,29 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.3", + "smallvec", + "windows-targets 0.52.6", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -531,18 +576,18 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -556,6 +601,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.4.0", +] + [[package]] name = "reqwest" version = "0.11.20" @@ -585,6 +639,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", + "tokio-socks", "tower-service", "url", "wasm-bindgen", @@ -627,6 +682,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "security-framework" version = "2.9.2" @@ -652,18 +713,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.188" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -672,11 +733,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -693,6 +755,15 @@ dependencies = [ "serde", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + [[package]] name = "slab" version = "0.4.9" @@ -702,6 +773,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "socket2" version = "0.4.9" @@ -724,9 +801,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -741,11 +818,31 @@ checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "redox_syscall 0.3.5", "rustix", "windows-sys", ] +[[package]] +name = "thiserror" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3de26b0965292219b4287ff031fcba86837900fe9cd2b34ea8ad893c0953d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "268026685b2be38d7103e9e507c938a1fcb3d7e6eb15e87870b617bf37b6d581" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -772,11 +869,25 @@ dependencies = [ "libc", "mio", "num_cpus", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2 0.5.3", + "tokio-macros", "windows-sys", ] +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tokio-native-tls" version = "0.3.1" @@ -787,6 +898,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-socks" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.8" @@ -966,7 +1089,11 @@ dependencies = [ name = "web_test" version = "0.1.0" dependencies = [ + "anyhow", "reqwest", + "serde", + "serde_json", + "tokio", ] [[package]] @@ -997,7 +1124,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1006,13 +1133,29 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -1021,42 +1164,90 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winreg" version = "0.50.0" diff --git a/Cargo.toml b/Cargo.toml index cb4a977..d15a713 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,4 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -reqwest = { version = "0.11", features = ["blocking", "json"] } \ No newline at end of file +tokio = {version = "1", features = ["full"]} +reqwest = { version = "0.11", features = ["blocking", "json", "socks"] } +anyhow = "1" +serde = {version = "1.0.204", features = ["derive"]} +serde_json = "1.0.121" diff --git a/all_proxy.txt b/all_proxy.txt new file mode 100644 index 0000000..e69de29 diff --git a/all_server.json b/all_server.json new file mode 100644 index 0000000..52f0d9d --- /dev/null +++ b/all_server.json @@ -0,0 +1,612 @@ +[ + { + "name": "bv-kr-24.json", + "bind": "127.0.0.1:19426", + "file": "bv-kr-24.json" + }, + { + "name": "28kvm-hk-1.json", + "bind": "127.0.0.1:19418", + "file": "28kvm-hk-1.json" + }, + { + "name": "coal_gz.json", + "bind": "127.0.0.1:9301", + "file": "coal_gz.json" + }, + { + "name": "bv-sg-opt.json", + "bind": "127.0.0.1:19420", + "file": "bv-sg-opt.json" + }, + { + "name": "pnac666.json", + "bind": "127.0.0.1:9201", + "file": "pnac666.json" + }, + { + "name": "sharon-jp-1", + "bind": "127.0.0.1:19444", + "file": "jp-ha.json" + }, + { + "name": "yxvm-jp-5d", + "bind": "127.0.0.1:19446", + "file": "jp-ha.json" + }, + { + "name": "coal_gz_nat.json", + "bind": "127.0.0.1:9302", + "file": "coal_gz_nat.json" + }, + { + "name": "bv-kr-12.json", + "bind": "127.0.0.1:19425", + "file": "bv-kr-12.json" + }, + { + "name": "gcp-hk.json", + "bind": "127.0.0.1:19421", + "file": "gcp-hk.json" + }, + { + "name": "ggy-gg", + "bind": "127.0.0.1:9205", + "file": "ggy_gg.json" + }, + { + "name": "wawo-us.json", + "bind": "127.0.0.1:19435", + "file": "wawo-us.json" + }, + { + "name": "ipraft-hk-pnac", + "bind": "127.0.0.1:9500", + "file": "hk-ha.json" + }, + { + "name": "yxvm-hk-vol-5d", + "bind": "127.0.0.1:19443", + "file": "hk-ha.json" + }, + { + "name": "hostyun-hk", + "bind": "127.0.0.1:19429", + "file": "hk-ha.json" + }, + { + "name": "dog-hk-300", + "bind": "127.0.0.1:19427", + "file": "hk-ha.json" + }, + { + "name": "yxvm_hk_hybird_5d", + "bind": "127.0.0.1:19316", + "file": "hk-ha.json" + }, + { + "name": "yxvm_hk_vol", + "bind": "127.0.0.1:19312", + "file": "hk-ha.json" + }, + { + "name": "coal_hk_pro_year", + "bind": "127.0.0.1:19611", + "file": "hk-ha.json" + }, + { + "name": "dv-hk-plus", + "bind": "127.0.0.1:19416", + "file": "hk-ha.json" + }, + { + "name": "bestvm_hk_pnac", + "bind": "127.0.0.1:9489", + "file": "hk-ha.json" + }, + { + "name": "vmshell_hk_36", + "bind": "127.0.0.1:9308", + "file": "hk-ha.json" + }, + { + "name": "yxvm-hybird-10d", + "bind": "127.0.0.1:9518", + "file": "hk-ha.json" + }, + { + "name": "ak-szhk", + "bind": "127.0.0.1:10630", + "file": "hk-ha.json" + }, + { + "name": "coal-iplc-hk2", + "bind": "127.0.0.1:19442", + "file": "hk-ha.json" + }, + { + "name": "coal-iplc-hk1", + "bind": "127.0.0.1:19441", + "file": "hk-ha.json" + }, + { + "name": "28kvm-hk-1_cd", + "bind": "127.0.0.1:20418", + "file": "hk-ha.json" + }, + { + "name": "28kvm-hk-1", + "bind": "127.0.0.1:19418", + "file": "hk-ha.json" + }, + { + "name": "28kvm-hk-0_cd", + "bind": "127.0.0.1:20417", + "file": "hk-ha.json" + }, + { + "name": "28kvm-hk-0", + "bind": "127.0.0.1:19417", + "file": "hk-ha.json" + }, + { + "name": "pnac-333", + "bind": "127.0.0.1:9413", + "file": "hk-ha.json" + }, + { + "name": "ggy-gg-old", + "bind": "127.0.0.1:9205", + "file": "hk-ha.json" + }, + { + "name": "ggy-gg-old-cd", + "bind": "127.0.0.1:9209", + "file": "hk-ha.json" + }, + { + "name": "pnac-800", + "bind": "127.0.0.1:9202", + "file": "hk-ha.json" + }, + { + "name": "yxvm-sg-hybird", + "bind": "127.0.0.1:19434", + "file": "sg-ha.json" + }, + { + "name": "yxvm-sg-vol", + "bind": "127.0.0.1:19412", + "file": "sg-ha.json" + }, + { + "name": "bv-sg-opt", + "bind": "127.0.0.1:19420", + "file": "sg-ha.json" + }, + { + "name": "miao-sg-v6", + "bind": "127.0.0.1:20132", + "file": "sg-ha.json" + }, + { + "name": "lisa-sg-hk-vol-3刀", + "bind": "127.0.0.1:20133", + "file": "sg-ha.json" + }, + { + "name": "pnac333.json", + "bind": "127.0.0.1:9413", + "file": "pnac333.json" + }, + { + "name": "coal-ah.json", + "bind": "127.0.0.1:19438", + "file": "coal-ah.json" + }, + { + "name": "bestvm_jp_mk.json", + "bind": "127.0.0.1:19617", + "file": "bestvm_jp_mk.json" + }, + { + "name": "28kvm-hk-0.json", + "bind": "127.0.0.1:19417", + "file": "28kvm-hk-0.json" + }, + { + "name": "coal-hk-v2-36.json", + "bind": "127.0.0.1:19440", + "file": "coal-hk-v2-36.json" + }, + { + "name": "bigchick_228.json", + "bind": "127.0.0.1:9310", + "file": "bigchick_228.json" + }, + { + "name": "coal_hk_pro.json", + "bind": "127.0.0.1:19311", + "file": "coal_hk_pro.json" + }, + { + "name": "bv_hk.json", + "bind": "127.0.0.1:9208", + "file": "bv_hk.json" + }, + { + "name": "pnac450.json", + "bind": "127.0.0.1:9208", + "file": "pnac450.json" + }, + { + "name": "ak-mo.json", + "bind": "127.0.0.1:19423", + "file": "ak-mo.json" + }, + { + "name": "coal_sz_v6_60.json", + "bind": "127.0.0.1:9419", + "file": "coal_sz_v6_60.json" + }, + { + "name": "coal_zs_nat.json", + "bind": "127.0.0.1:9501", + "file": "coal_zs_nat.json" + }, + { + "name": "sharon-jp.json", + "bind": "127.0.0.1:19424", + "file": "sharon-jp.json" + }, + { + "name": "pnac800.json", + "bind": "127.0.0.1:9202", + "file": "pnac800.json" + }, + { + "name": "happy-eb", + "bind": "127.0.0.1:9411", + "file": "hk-yd.json" + }, + { + "name": "miao-hk-br", + "bind": "127.0.0.1:19317", + "file": "hk-yd.json" + }, + { + "name": "gcp-hk", + "bind": "127.0.0.1:19421", + "file": "hk-yd.json" + }, + { + "name": "bage-hk", + "bind": "127.0.0.1:19430", + "file": "hk-yd.json" + }, + { + "name": "wawo-hk-one", + "bind": "127.0.0.1:19432", + "file": "hk-yd.json" + }, + { + "name": "ak-hk-v2", + "bind": "127.0.0.1:19436", + "file": "hk-yd.json" + }, + { + "name": "coal-hk-v2-36", + "bind": "127.0.0.1:19440", + "file": "hk-yd.json" + }, + { + "name": "coal-hk-v2-72", + "bind": "127.0.0.1:19439", + "file": "hk-yd.json" + }, + { + "name": "bage-hk.json", + "bind": "127.0.0.1:19430", + "file": "bage-hk.json" + }, + { + "name": "28kvm-hk-0_cd.json", + "bind": "127.0.0.1:20417", + "file": "28kvm-hk-0_cd.json" + }, + { + "name": "yxvm_vol.json", + "bind": "127.0.0.1:19412", + "file": "yxvm_vol.json" + }, + { + "name": "yxvm-hk-vol-5d.json", + "bind": "127.0.0.1:19443", + "file": "yxvm-hk-vol-5d.json" + }, + { + "name": "28kvm-hk-1_cd.json", + "bind": "127.0.0.1:20418", + "file": "28kvm-hk-1_cd.json" + }, + { + "name": "vmshell_hk_120.json", + "bind": "127.0.0.1:9309", + "file": "vmshell_hk_120.json" + }, + { + "name": "bestvm_hk_pnac.json", + "bind": "127.0.0.1:9489", + "file": "bestvm_hk_pnac.json" + }, + { + "name": "炭云-广州独立", + "bind": "127.0.0.1:9301", + "file": "gy-ha.json" + }, + { + "name": "炭云-广州nat", + "bind": "127.0.0.1:9302", + "file": "gy-ha.json" + }, + { + "name": "炭云-深圳nat", + "bind": "127.0.0.1:9418", + "file": "gy-ha.json" + }, + { + "name": "炭云-深圳nat-60", + "bind": "127.0.0.1:9419", + "file": "gy-ha.json" + }, + { + "name": "coal-iplc-hk2.json", + "bind": "127.0.0.1:19442", + "file": "coal-iplc-hk2.json" + }, + { + "name": "peng_eb_big.json", + "bind": "127.0.0.1:9411", + "file": "peng_eb_big.json" + }, + { + "name": "sharon-jp-1.json", + "bind": "127.0.0.1:19444", + "file": "sharon-jp-1.json" + }, + { + "name": "bwg-hk.json", + "bind": "127.0.0.1:19431", + "file": "bwg-hk.json" + }, + { + "name": "yxvm-sg-hybird", + "bind": "127.0.0.1:19434", + "file": "sg-netflix.json" + }, + { + "name": "miao-sg-v6", + "bind": "127.0.0.1:20142", + "file": "sg-netflix.json" + }, + { + "name": "lisa-sg-hk-vol-3刀", + "bind": "127.0.0.1:20143", + "file": "sg-netflix.json" + }, + { + "name": "bv-sg-opt", + "bind": "127.0.0.1:19420", + "file": "sg-netflix.json" + }, + { + "name": "coal-iplc-hk1.json", + "bind": "127.0.0.1:19441", + "file": "coal-iplc-hk1.json" + }, + { + "name": "ak-hkv2-5.json", + "bind": "127.0.0.1:19436", + "file": "ak-hkv2-5.json" + }, + { + "name": "ggy-gg-cd", + "bind": "127.0.0.1:19437", + "file": "ggy-cd.json" + }, + { + "name": "pqs_hinet_55.json", + "bind": "127.0.0.1:19419", + "file": "pqs_hinet_55.json" + }, + { + "name": "yxvm-hybird.json", + "bind": "127.0.0.1:9518", + "file": "yxvm-hybird.json" + }, + { + "name": "coal-hk-v2-72.json", + "bind": "127.0.0.1:19439", + "file": "coal-hk-v2-72.json" + }, + { + "name": "bwg-us-36.json", + "bind": "127.0.0.1:19428", + "file": "bwg-us-36.json" + }, + { + "name": "yxvm_hk_vol.json", + "bind": "127.0.0.1:19312", + "file": "yxvm_hk_vol.json" + }, + { + "name": "pnac666", + "bind": "127.0.0.1:9201", + "file": "jp-zx.json" + }, + { + "name": "pnac450", + "bind": "127.0.0.1:9208", + "file": "jp-zx.json" + }, + { + "name": "yxvm_hk_hybird_5d.json", + "bind": "127.0.0.1:19316", + "file": "yxvm_hk_hybird_5d.json" + }, + { + "name": "miao_sg.json", + "bind": "127.0.0.1:19414", + "file": "miao_sg.json" + }, + { + "name": "pnac-800", + "bind": "127.0.0.1:9202", + "file": "hk-zx.json" + }, + { + "name": "coal-iplc-hk2", + "bind": "127.0.0.1:19442", + "file": "hk-zx.json" + }, + { + "name": "coal-iplc-hk1", + "bind": "127.0.0.1:19441", + "file": "hk-zx.json" + }, + { + "name": "28kvm-hk-1_cd", + "bind": "127.0.0.1:20418", + "file": "hk-zx.json" + }, + { + "name": "28kvm-hk-1", + "bind": "127.0.0.1:19418", + "file": "hk-zx.json" + }, + { + "name": "28kvm-hk-0_cd", + "bind": "127.0.0.1:20417", + "file": "hk-zx.json" + }, + { + "name": "28kvm-hk-0", + "bind": "127.0.0.1:19417", + "file": "hk-zx.json" + }, + { + "name": "pnac-333", + "bind": "127.0.0.1:9413", + "file": "hk-zx.json" + }, + { + "name": "ggy-gg-old", + "bind": "127.0.0.1:9205", + "file": "hk-zx.json" + }, + { + "name": "ggy-gg-old-cd", + "bind": "127.0.0.1:9209", + "file": "hk-zx.json" + }, + { + "name": "coal_sz.json", + "bind": "127.0.0.1:9412", + "file": "coal_sz.json" + }, + { + "name": "wuyu_cm.json", + "bind": "127.0.0.1:9311", + "file": "wuyu_cm.json" + }, + { + "name": "miao_hk.json", + "bind": "127.0.0.1:19317", + "file": "miao_hk.json" + }, + { + "name": "vmshell_hk_36.json", + "bind": "127.0.0.1:9308", + "file": "vmshell_hk_36.json" + }, + { + "name": "dv_273.json", + "bind": "127.0.0.1:9411", + "file": "dv_273.json" + }, + { + "name": "wepc-jp.json", + "bind": "127.0.0.1:19433", + "file": "wepc-jp.json" + }, + { + "name": "dv-hk-plus.json", + "bind": "127.0.0.1:19416", + "file": "dv-hk-plus.json" + }, + { + "name": "bigchick_long.json", + "bind": "127.0.0.1:10581", + "file": "bigchick_long.json" + }, + { + "name": "coal_sz_v6.json", + "bind": "127.0.0.1:9418", + "file": "coal_sz_v6.json" + }, + { + "name": "coal_hk_pro_year.json", + "bind": "127.0.0.1:19611", + "file": "coal_hk_pro_year.json" + }, + { + "name": "wawo-hk-one.json", + "bind": "127.0.0.1:19432", + "file": "wawo-hk-one.json" + }, + { + "name": "hostyun-hk.json", + "bind": "127.0.0.1:19429", + "file": "hostyun-hk.json" + }, + { + "name": "ipraft_hk_pnac.json", + "bind": "127.0.0.1:9500", + "file": "ipraft_hk_pnac.json" + }, + { + "name": "yxvm-sg-hybird.json", + "bind": "127.0.0.1:19434", + "file": "yxvm-sg-hybird.json" + }, + { + "name": "wawo-tw.json", + "bind": "127.0.0.1:19108", + "file": "wawo-tw.json" + }, + { + "name": "ak-gz-nat-iepl.json", + "bind": "127.0.0.1:10630", + "file": "ak-gz-nat-iepl.json" + }, + { + "name": "bage-jp", + "bind": "127.0.0.1:19422", + "file": "bage_jp.json" + }, + { + "name": "pqs_hinet_static.json", + "bind": "127.0.0.1:19415", + "file": "pqs_hinet_static.json" + }, + { + "name": "dog-hk-300.json", + "bind": "127.0.0.1:19427", + "file": "dog-hk-300.json" + }, + { + "name": "coal_zx.json", + "bind": "127.0.0.1:9503", + "file": "coal_zx.json" + } +] \ No newline at end of file diff --git a/output.json b/output.json new file mode 100644 index 0000000..d049626 --- /dev/null +++ b/output.json @@ -0,0 +1,742 @@ +[ + [ + "bestvm_hk_pnac", + { + "name": "bestvm_hk_pnac", + "latency": 159.2, + "variance": 34.360000000000014, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "bestvm_hk_pnac.json", + { + "name": "bestvm_hk_pnac.json", + "latency": 162.4, + "variance": 42.44000000000001, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ipraft-hk-pnac", + { + "name": "ipraft-hk-pnac", + "latency": 170.2, + "variance": 20.360000000000024, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "28kvm-hk-1.json", + { + "name": "28kvm-hk-1.json", + "latency": 171.89999999999998, + "variance": 29.089999999999986, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "28kvm-hk-0", + { + "name": "28kvm-hk-0", + "latency": 172.7, + "variance": 56.40999999999999, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ak-szhk", + { + "name": "ak-szhk", + "latency": 174.79999999999998, + "variance": 18.560000000000006, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ak-gz-nat-iepl.json", + { + "name": "ak-gz-nat-iepl.json", + "latency": 175.4, + "variance": 13.64, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "28kvm-hk-1", + { + "name": "28kvm-hk-1", + "latency": 176.9, + "variance": 49.690000000000055, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ipraft_hk_pnac.json", + { + "name": "ipraft_hk_pnac.json", + "latency": 178.1, + "variance": 37.489999999999995, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "pnac800.json", + { + "name": "pnac800.json", + "latency": 179.00000000000003, + "variance": 219.79999999999995, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "28kvm-hk-0.json", + { + "name": "28kvm-hk-0.json", + "latency": 181.9, + "variance": 78.89000000000001, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "pnac333.json", + { + "name": "pnac333.json", + "latency": 182.9, + "variance": 27.890000000000004, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "pnac-333", + { + "name": "pnac-333", + "latency": 185.3, + "variance": 103.41000000000004, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "pnac-800", + { + "name": "pnac-800", + "latency": 189.9, + "variance": 33.49000000000002, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "coal-hk-v2-72.json", + { + "name": "coal-hk-v2-72.json", + "latency": 202.2, + "variance": 20.159999999999965, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "miao_hk.json", + { + "name": "miao_hk.json", + "latency": 205.79999999999998, + "variance": 70.16000000000001, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "dog-hk-300", + { + "name": "dog-hk-300", + "latency": 209.3, + "variance": 59.209999999999965, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ak-hkv2-5.json", + { + "name": "ak-hkv2-5.json", + "latency": 209.6, + "variance": 21.639999999999993, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "bage-hk.json", + { + "name": "bage-hk.json", + "latency": 209.89999999999998, + "variance": 103.68999999999997, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ak-hk-v2", + { + "name": "ak-hk-v2", + "latency": 211.29999999999998, + "variance": 29.410000000000025, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "hostyun-hk", + { + "name": "hostyun-hk", + "latency": 213.8, + "variance": 175.16000000000003, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "bage-hk", + { + "name": "bage-hk", + "latency": 213.8, + "variance": 87.75999999999999, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "dv_273.json", + { + "name": "dv_273.json", + "latency": 214.60000000000002, + "variance": 61.44000000000001, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "hostyun-hk.json", + { + "name": "hostyun-hk.json", + "latency": 215.2, + "variance": 200.56000000000003, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "dog-hk-300.json", + { + "name": "dog-hk-300.json", + "latency": 215.7, + "variance": 46.809999999999995, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "peng_eb_big.json", + { + "name": "peng_eb_big.json", + "latency": 216.3, + "variance": 73.20999999999998, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "coal-iplc-hk2.json", + { + "name": "coal-iplc-hk2.json", + "latency": 216.9, + "variance": 59.69, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "coal-iplc-hk2", + { + "name": "coal-iplc-hk2", + "latency": 217.4, + "variance": 147.44, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "coal-hk-v2-72", + { + "name": "coal-hk-v2-72", + "latency": 218.3, + "variance": 1300.4100000000003, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "28kvm-hk-1_cd", + { + "name": "28kvm-hk-1_cd", + "latency": 218.5, + "variance": 124.85000000000002, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "gcp-hk.json", + { + "name": "gcp-hk.json", + "latency": 219.10000000000002, + "variance": 318.68999999999994, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "vmshell_hk_36", + { + "name": "vmshell_hk_36", + "latency": 224.79999999999998, + "variance": 77.76000000000003, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "vmshell_hk_36.json", + { + "name": "vmshell_hk_36.json", + "latency": 226.5, + "variance": 214.85, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "28kvm-hk-1_cd.json", + { + "name": "28kvm-hk-1_cd.json", + "latency": 226.79999999999998, + "variance": 87.35999999999999, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "gcp-hk", + { + "name": "gcp-hk", + "latency": 230.10000000000002, + "variance": 463.28999999999996, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "28kvm-hk-0_cd", + { + "name": "28kvm-hk-0_cd", + "latency": 233.9, + "variance": 272.68999999999994, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "coal-iplc-hk1", + { + "name": "coal-iplc-hk1", + "latency": 235.4, + "variance": 289.43999999999994, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "happy-eb", + { + "name": "happy-eb", + "latency": 236.9, + "variance": 2641.8900000000003, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "wawo-hk-one", + { + "name": "wawo-hk-one", + "latency": 242.49999999999997, + "variance": 934.2499999999994, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ggy-gg-old-cd", + { + "name": "ggy-gg-old-cd", + "latency": 245.2, + "variance": 589.3600000000001, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "28kvm-hk-0_cd.json", + { + "name": "28kvm-hk-0_cd.json", + "latency": 253.9, + "variance": 1118.2900000000002, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "coal-iplc-hk1.json", + { + "name": "coal-iplc-hk1.json", + "latency": 260.0, + "variance": 1190.4, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "wawo-hk-one.json", + { + "name": "wawo-hk-one.json", + "latency": 268.6, + "variance": 6902.640000000004, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "bv-kr-24.json", + { + "name": "bv-kr-24.json", + "latency": 304.4, + "variance": 2964.8399999999997, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm_vol.json", + { + "name": "yxvm_vol.json", + "latency": 307.5, + "variance": 114.04999999999995, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "bv-kr-12.json", + { + "name": "bv-kr-12.json", + "latency": 308.0, + "variance": 3030.8, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "coal_hk_pro_year.json", + { + "name": "coal_hk_pro_year.json", + "latency": 309.1, + "variance": 292.8900000000002, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm-sg-vol", + { + "name": "yxvm-sg-vol", + "latency": 309.3, + "variance": 108.61000000000006, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm-sg-hybird.json", + { + "name": "yxvm-sg-hybird.json", + "latency": 317.3, + "variance": 63.81000000000002, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm-sg-hybird", + { + "name": "yxvm-sg-hybird", + "latency": 323.59999999999997, + "variance": 486.84, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ggy-gg", + { + "name": "ggy-gg", + "latency": 335.0, + "variance": 380.19999999999993, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm-hk-vol-5d.json", + { + "name": "yxvm-hk-vol-5d.json", + "latency": 349.2, + "variance": 418.56000000000006, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "dv-hk-plus.json", + { + "name": "dv-hk-plus.json", + "latency": 359.6, + "variance": 343.8399999999996, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm-jp-5d", + { + "name": "yxvm-jp-5d", + "latency": 364.8, + "variance": 3556.7599999999998, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm-hk-vol-5d", + { + "name": "yxvm-hk-vol-5d", + "latency": 400.9, + "variance": 329.4900000000001, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ggy-gg-old", + { + "name": "ggy-gg-old", + "latency": 403.59999999999997, + "variance": 578.2399999999994, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "pqs_hinet_55.json", + { + "name": "pqs_hinet_55.json", + "latency": 438.6, + "variance": 20685.84, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm_hk_vol", + { + "name": "yxvm_hk_vol", + "latency": 469.69999999999993, + "variance": 1291.6099999999976, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "wepc-jp.json", + { + "name": "wepc-jp.json", + "latency": 476.0, + "variance": 9849.8, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm-hybird-10d", + { + "name": "yxvm-hybird-10d", + "latency": 477.2, + "variance": 1277.7599999999998, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm_hk_vol.json", + { + "name": "yxvm_hk_vol.json", + "latency": 480.50000000000006, + "variance": 1186.8499999999985, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "dv-hk-plus", + { + "name": "dv-hk-plus", + "latency": 494.69999999999993, + "variance": 499.6099999999997, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm-hybird.json", + { + "name": "yxvm-hybird.json", + "latency": 495.1, + "variance": 9437.489999999998, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "coal_hk_pro_year", + { + "name": "coal_hk_pro_year", + "latency": 496.8, + "variance": 9906.759999999998, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm_hk_hybird_5d", + { + "name": "yxvm_hk_hybird_5d", + "latency": 506.9, + "variance": 188.28999999999988, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "yxvm_hk_hybird_5d.json", + { + "name": "yxvm_hk_hybird_5d.json", + "latency": 511.9, + "variance": 298.89, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "bv-sg-opt.json", + { + "name": "bv-sg-opt.json", + "latency": 553.0999999999999, + "variance": 243.49000000000038, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "bv-sg-opt", + { + "name": "bv-sg-opt", + "latency": 559.0999999999999, + "variance": 448.0900000000009, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "lisa-sg-hk-vol-3\u5200", + { + "name": "lisa-sg-hk-vol-3\u5200", + "latency": 575.3, + "variance": 358.6099999999999, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "sharon-jp-1.json", + { + "name": "sharon-jp-1.json", + "latency": 582.5, + "variance": 637.05, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "sharon-jp-1", + { + "name": "sharon-jp-1", + "latency": 591.1999999999999, + "variance": 344.1600000000002, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "bage-jp", + { + "name": "bage-jp", + "latency": 593.4000000000001, + "variance": 13866.240000000002, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "ak-mo.json", + { + "name": "ak-mo.json", + "latency": 599.6, + "variance": 55695.240000000005, + "success_count": 10, + "failure_count": 0 + } + ], + [ + "miao-sg-v6", + { + "name": "miao-sg-v6", + "latency": 610.5999999999999, + "variance": 11288.439999999999, + "success_count": 10, + "failure_count": 0 + } + ] +] \ No newline at end of file diff --git a/run.py b/run.py new file mode 100644 index 0000000..488ac87 --- /dev/null +++ b/run.py @@ -0,0 +1,70 @@ +import json +import subprocess + +def run_web_test(url, count, bind, name): + command = ["./target/release/web_test", url, count, f"socks5h://{bind}", name] + result = subprocess.run(command, capture_output=True, text=True) + print(result) + return result.stdout.strip() + +def sort_by_field(input_dict): + # 提取字典中的键值对,并根据值中的 'field' 进行排序 + sorted_items = sorted(input_dict.items(), key=lambda item: item[1]['latency']) + + # 将排序后的键值对转换为包含二元组的数组 + result = [(key, value) for key, value in sorted_items] + + return result +def main(json_file, url, count): + # 读取JSON文件 + with open(json_file, 'r') as file: + data = json.load(file) + + results = {} + + # 针对每一个name和bind运行程序 + for entry in data: + name = entry['name'] + bind = entry['bind'] + result = run_web_test(url, count, bind, name) + if result.find("error") == -1: + data = process_string(result) + results[name] = data + results = sort_by_field(results) + + return results + +def process_string(input_string): + # 将字符串按逗号分割 + parts = input_string.split(',') + + # 确保字符串有5个部分 + if len(parts) != 5: + raise ValueError("输入字符串必须由5部分组成") + + # 提取并转换各部分数据 + name = parts[0].strip() + latency = float(parts[1].strip()) + variance = float(parts[2].strip()) + success_count = int(parts[3].strip()) + failure_count = int(parts[4].strip()) + + # 返回提取的信息 + return { + 'name': name, + 'latency': latency, + 'variance': variance, + 'success_count': success_count, + 'failure_count': failure_count + } +if __name__ == "__main__": + json_file = "all_server.json" # 替换为你的JSON文件名 + url = "https://cp.cloudflare.com/generate_204" # 替换为你的url + count = "10" # 替换为你的count + results = main(json_file, url, count) + + # 打印或保存结果 + print(json.dumps(results, indent=4)) + # 如果你想保存到文件,可以取消以下注释 + with open('output.json', 'w') as outfile: + json.dump(results, outfile, indent=4) \ No newline at end of file diff --git a/src/bin/conn_num_test_client.rs b/src/bin/conn_num_test_client.rs new file mode 100644 index 0000000..06a22b0 --- /dev/null +++ b/src/bin/conn_num_test_client.rs @@ -0,0 +1,59 @@ +use std::{ + env, + sync::{ + atomic::{AtomicBool, AtomicU32, Ordering}, + Arc, + }, +}; + +use tokio::{ + io::{AsyncReadExt, AsyncWriteExt}, + select, +}; + +async fn run_forever(remote: &str, stop: Arc) -> anyhow::Result<()> { + let mut i = 0; + loop { + let r = remote.to_owned(); + i += 1; + if stop.load(Ordering::SeqCst) { + return Ok(()); + } + tokio::time::sleep(std::time::Duration::from_millis(200)).await; + tokio::spawn(async move { + println!("start {i}"); + match tokio::net::TcpStream::connect(&r).await { + Err(e) => { + println!("connect error at: {i}"); + return; + } + Ok(mut s) => { + for i in 0..100 { + tokio::time::sleep(std::time::Duration::from_secs(1)).await; + match s.write_all("Hello World".as_bytes()).await { + Ok(_) => {} + Err(e) => {} + } + } + let _ = s.shutdown().await; + } + } + }); + } +} +#[tokio::main] +async fn main() -> anyhow::Result<()> { + let remote = std::env::args().nth(1).unwrap(); + let stop = Arc::new(AtomicBool::new(false)); + select! { + _ = run_forever(&remote, stop.clone()) => { + + } + _ = tokio::signal::ctrl_c() => { + stop.store(true, Ordering::SeqCst); + tokio::time::sleep(std::time::Duration::from_secs(120)).await; + } + } + + Ok(()) +} diff --git a/src/bin/conn_num_test_server.rs b/src/bin/conn_num_test_server.rs new file mode 100644 index 0000000..c2767b5 --- /dev/null +++ b/src/bin/conn_num_test_server.rs @@ -0,0 +1,32 @@ +use std::sync::{ + atomic::{AtomicU32, Ordering}, + Arc, +}; + +use tokio::io::AsyncReadExt; + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + let bind = std::env::args().nth(1).unwrap(); + let l = tokio::net::TcpListener::bind(bind).await?; + let succ_count = Arc::new(AtomicU32::new(0)); + let err_count = Arc::new(AtomicU32::new(0)); + while let Ok((mut stream, _)) = l.accept().await { + let succ = succ_count.clone(); + let err = err_count.clone(); + tokio::spawn(async move { + let mut rst = String::new(); + match stream.read_to_string(&mut rst).await { + Ok(_n) => { + succ.fetch_add(1, Ordering::SeqCst); + } + Err(e) => { + err.fetch_add(1, Ordering::SeqCst); + } + } + println!("current succ: {}", succ.load(Ordering::SeqCst)); + println!("current err: {}", err.load(Ordering::SeqCst)); + }); + } + Ok(()) +} diff --git a/src/bin/get_all_proxy/main.rs b/src/bin/get_all_proxy/main.rs new file mode 100644 index 0000000..5c5564e --- /dev/null +++ b/src/bin/get_all_proxy/main.rs @@ -0,0 +1,84 @@ +use std::net::SocketAddr; + +use serde::{Deserialize, Serialize}; +use tokio::io::AsyncWriteExt; + +#[derive(Debug, Serialize, Deserialize)] +pub struct ClientConfig { + pub name: Option, + pub local_bind: SocketAddr, + pub multi_server_config: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct MultiServerConfig { + pub back_servers: Vec, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct ServerEndPoint { + pub local_bind: Option, + pub name: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +struct Server { + name: String, + bind: SocketAddr, + file: String, +} +#[tokio::main] +async fn main() -> anyhow::Result<()> { + let p = std::env::args().nth(1).unwrap(); + let mut entries = tokio::fs::read_dir(&p).await?; + let mut all_servers = vec![]; + while let Some(entry) = entries.next_entry().await? { + if entry.path().is_file() { + let file_name = entry + .path() + .file_name() + .unwrap() + .to_string_lossy() + .into_owned(); + if let Ok(r) = async { + let c = tokio::fs::read_to_string(entry.path()).await?; + let data: ClientConfig = serde_json::from_str(&c)?; + let mut rst = vec![]; + let main_bind = data.local_bind.clone(); + let main_name = data + .name + .as_ref() + .map(|x| x.clone()) + .unwrap_or_else(|| format!("{file_name}")); + rst.push(Server { + name: main_name, + bind: main_bind, + file: file_name.clone(), + }); + for b in data + .multi_server_config + .map(|x| x.back_servers) + .into_iter() + .flatten() + { + if let Some(bind) = b.local_bind { + rst.push(Server { + name: b.name.unwrap_or_else(|| format!("ukn:{}", bind.port())), + bind, + file: file_name.clone(), + }) + } + } + Ok::<_, anyhow::Error>(rst) + } + .await + { + all_servers.extend(r); + } + } + } + let mut out = tokio::fs::File::create("all_server.json").await?; + let d = serde_json::to_string(&all_servers).unwrap(); + out.write_all(&d.as_bytes()).await?; + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index b9c1eb9..c42885f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,19 +47,32 @@ fn main() { .unwrap_or_else(|| "20".to_owned()) .parse() .expect("second parameter should interger"); - - let fmt = std::env::args().nth(3); + let proxy = std::env::args().nth(3); + let fmt = std::env::args().nth(4); let mut stats = IncrementalStats::new(); + let mut succ = 0; + let mut err = 0; for i in 0..iter_num { let start = Instant::now(); - match reqwest::blocking::get(&url) { + let builder = + reqwest::blocking::ClientBuilder::new().timeout(std::time::Duration::from_secs(1)); + let c = if let Some(p) = proxy.as_ref() { + builder + .proxy(reqwest::Proxy::all(p.as_str()).unwrap()) + .build() + .unwrap() + } else { + builder.build().unwrap() + }; + match c.get(&url).send() { Ok(response) => { if response.status().is_success() { - let duration = start.elapsed(); + let mut duration = start.elapsed(); let _r = response.bytes().unwrap(); if let Some(_name) = fmt.as_ref() { // println!("{name}, {i},{}", duration.as_millis()) + // duration /= 2; } else { println!( "第{i}次测试, 访问 {} 花费了 {:?} 毫秒", @@ -67,30 +80,45 @@ fn main() { duration.as_millis() ); } - + succ += 1; // time_rec.push(duration); stats.add(duration.as_millis() as f64); } else { + let mut duration = start.elapsed(); println!( "第{i}次测试, 访问 {} 失败,状态码:{}", url, response.status() ); + stats.add(duration.as_millis() as f64); + err += 1; } } Err(error) => { + err += 1; println!("第{i}次测试, 请求错误:{}", error); + if let Some(_name) = fmt.as_ref() { + return; + } } } } if let Some(name) = fmt.as_ref() { - println!("{name}, {},{}", stats.average(), stats.variance()) + println!( + "{name}, {},{},{},{}", + stats.average(), + stats.variance(), + succ, + err + ); } else { println!( - "平均: {:?}ms, 方差: {:?}", + "平均: {:?}ms, 方差: {:?} 成功:{} 失败: {}", stats.average(), - stats.variance() + stats.variance(), + succ, + err ); } }