修复了上一个推送导致的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

@@ -315,7 +315,7 @@ impl<T: StreamType> Bot<T> {
}
(*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;
}

View File

@@ -7,8 +7,9 @@ mod configuration;
use bot_socks5::BotVariable;
use reqwest;
use serde_json::Value;
use tokio::task;
// use tokio::task;
use std::sync::Arc;
use std::thread;
use tokio::sync::Mutex;
use crate::utils::generate_username;
use crate::configuration::Configuration;
@@ -27,13 +28,6 @@ use crate::configuration::Configuration;
#[tokio::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
let thread_lock = Arc::new(Mutex::new(()));
@@ -48,6 +42,13 @@ async fn main() {
spam_file: Arc::new(Mutex::new(spam_file)),
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 {
let lock_clone = thread_lock.clone();
@@ -58,7 +59,18 @@ async fn main() {
// 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);
// println!("[MAIN] Thread {} created", i) // 这个太吵了(
}
@@ -96,7 +108,7 @@ async fn attack_thread(lock: Arc<Mutex<()>>, config: Arc<Configuration>, variabl
Some(t) => &t[0],
None => &Value::Null
};
if proxy.as_str() == None {
if !proxy.is_object() {
flag = true;
eprintln!("[{}] Unable to get proxy,retrying...",username)
}
@@ -106,13 +118,17 @@ async fn attack_thread(lock: Arc<Mutex<()>>, config: Arc<Configuration>, variabl
while flag {
flag = false;
// 创建一个bot
let addr:String; // 为了规避生命周期问题
let bot_result = bot_socks5::create_new_bot(
username.to_string(),
{
if proxy.is_null() { // 如果不使用proxy
""
}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(),
format!("{}:{}",config.server_ip(),config.server_port()),