修复了上一个推送导致的bug

This commit is contained in:
Zihaoxu2008
2025-01-25 19:36:53 +08:00
parent 0766ebeeb5
commit 7021969b27
3 changed files with 32 additions and 16 deletions

View File

@@ -1,8 +1,8 @@
{ {
"server_ip": "m.earthvillage.top", "server_ip": "127.0.0.1",
"server_port": "33009", "server_port": "25565",
"proxy_url": "http://uu-proxy.com/api/get_proxies?id=RZ7GS5ZYTA&size=1&schemes=socks5&support_https=false&format=json", "proxy_url": "",
"username_prefix": "我叫猪好燃", "username_prefix": "test",
"count": 300, "count": 300,
"reco_words": ["验证程序已启用","AntiAttack"], "reco_words": ["验证程序已启用","AntiAttack"],
"login_commands": ["reg helloa helloa"], "login_commands": ["reg helloa helloa"],

View File

@@ -315,7 +315,7 @@ impl<T: StreamType> Bot<T> {
} }
(*var.spam_cursor.lock().await) = reader.stream_position().await.unwrap(); (*var.spam_cursor.lock().await) = reader.stream_position().await.unwrap();
} }
self.send_message(msg).await.unwrap(); self.send_message(msg).await.unwrap_or(());
} }
iter += 1; iter += 1;
} }

View File

@@ -7,8 +7,9 @@ mod configuration;
use bot_socks5::BotVariable; use bot_socks5::BotVariable;
use reqwest; use reqwest;
use serde_json::Value; use serde_json::Value;
use tokio::task; // use tokio::task;
use std::sync::Arc; use std::sync::Arc;
use std::thread;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use crate::utils::generate_username; use crate::utils::generate_username;
use crate::configuration::Configuration; use crate::configuration::Configuration;
@@ -27,13 +28,6 @@ use crate::configuration::Configuration;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
// let rt = tokio::runtime::Builder::new_multi_thread()
// .enable_all()
// .thread_stack_size(8 * 1024 * 1024)
// .worker_threads(30)
// .build()
// .unwrap();
// 一个互斥锁,防止有多个线程同时请求uuproxy // 一个互斥锁,防止有多个线程同时请求uuproxy
let thread_lock = Arc::new(Mutex::new(())); let thread_lock = Arc::new(Mutex::new(()));
@@ -48,6 +42,13 @@ async fn main() {
spam_file: Arc::new(Mutex::new(spam_file)), spam_file: Arc::new(Mutex::new(spam_file)),
spam_cursor: Arc::new(Mutex::new(0)) spam_cursor: Arc::new(Mutex::new(0))
}); });
// let rt = tokio::runtime::Builder::new_multi_thread()
// .enable_all()
// .thread_stack_size(8 * 1024 * 1024)
// .worker_threads((configuration_rc.count()-1) as usize)
// .build()
// .unwrap();
for _ in 0..configuration_rc.count() -1 { for _ in 0..configuration_rc.count() -1 {
let lock_clone = thread_lock.clone(); let lock_clone = thread_lock.clone();
@@ -58,7 +59,18 @@ async fn main() {
// println!("[MAIN] Thread {} created", i); // println!("[MAIN] Thread {} created", i);
// }); // });
// 生成一个线程 // 生成一个线程
let handle = task::spawn(attack_thread(lock_clone, configuration_rc_clone,variables_clone)); // let handle = rt.spawn(attack_thread(lock_clone,configuration_rc_clone,variables_clone));
let handle = thread::spawn(move || {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.thread_stack_size(8 * 1024 * 1024)
.build()
.unwrap()
.block_on(async move {
attack_thread(lock_clone,configuration_rc_clone,variables_clone).await;
// println!("[MAIN] Thread {} created", i);
});
});
handles.push(handle); handles.push(handle);
// println!("[MAIN] Thread {} created", i) // 这个太吵了( // println!("[MAIN] Thread {} created", i) // 这个太吵了(
} }
@@ -96,7 +108,7 @@ async fn attack_thread(lock: Arc<Mutex<()>>, config: Arc<Configuration>, variabl
Some(t) => &t[0], Some(t) => &t[0],
None => &Value::Null None => &Value::Null
}; };
if proxy.as_str() == None { if !proxy.is_object() {
flag = true; flag = true;
eprintln!("[{}] Unable to get proxy,retrying...",username) eprintln!("[{}] Unable to get proxy,retrying...",username)
} }
@@ -106,13 +118,17 @@ async fn attack_thread(lock: Arc<Mutex<()>>, config: Arc<Configuration>, variabl
while flag { while flag {
flag = false; flag = false;
// 创建一个bot // 创建一个bot
let addr:String; // 为了规避生命周期问题
let bot_result = bot_socks5::create_new_bot( let bot_result = bot_socks5::create_new_bot(
username.to_string(), username.to_string(),
{ {
if proxy.is_null() { // 如果不使用proxy if proxy.is_null() { // 如果不使用proxy
"" ""
}else{ }else{
proxy.as_str().unwrap() let ip = proxy["ip"].as_str().unwrap();
let port = proxy["port"].as_i64().unwrap();
addr = format!("{}:{}",ip,port);
addr.as_str()
} }
}.to_string(), }.to_string(),
format!("{}:{}",config.server_ip(),config.server_port()), format!("{}:{}",config.server_ip(),config.server_port()),