再次修改了一些内容
This commit is contained in:
@@ -239,12 +239,14 @@ impl<T: StreamType> Bot<T> {
|
||||
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<T: StreamType> Bot<T> {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
20
src/main.rs
20
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<Mutex<()>>, config: Arc<Configuration>, variables: Arc<BotVariable>) -> () {
|
||||
async fn attack_thread(lock: Arc<Mutex<()>>, config: Arc<Configuration>, variables: Arc<BotVariable>,rt_update: Arc<Runtime>) -> () {
|
||||
loop {
|
||||
// 请求proxy(如果有)
|
||||
let username = generate_username(&config);
|
||||
@@ -149,7 +159,7 @@ async fn attack_thread(lock: Arc<Mutex<()>>, config: Arc<Configuration>, variabl
|
||||
// 插入生成update_worker线程的代码
|
||||
let mut bot_clone = bot.clone();
|
||||
let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<u8>();
|
||||
tokio::spawn(async move {
|
||||
rt_update.spawn(async move {
|
||||
bot_clone.update_worker(rx).await;
|
||||
});
|
||||
match bot.run(tx).await {
|
||||
|
||||
Reference in New Issue
Block a user