再次修改了一些内容
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
/.idea
|
/.idea
|
||||||
/我是崩服小能手
|
/我是崩服小能手
|
||||||
|
/config.json
|
||||||
16
config.json
16
config.json
@@ -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
|
|
||||||
}
|
|
||||||
@@ -239,12 +239,14 @@ impl<T: StreamType> Bot<T> {
|
|||||||
0x1A => {// 断连包
|
0x1A => {// 断连包
|
||||||
// disconnect
|
// disconnect
|
||||||
self.handle_disconnect(&mut packet).await?;
|
self.handle_disconnect(&mut packet).await?;
|
||||||
|
status_tx.send(2).unwrap();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
0x00 => {// 版本不匹配啥的就会走这
|
0x00 => {// 版本不匹配啥的就会走这
|
||||||
if self.status == 0{
|
if self.status == 0{
|
||||||
let text = packet.read_string()?;
|
let text = packet.read_string()?;
|
||||||
println!("[{}] Failed to login: {}", self.username, utils::parse_json_component(text.as_str()));
|
println!("[{}] Failed to login: {}", self.username, utils::parse_json_component(text.as_str()));
|
||||||
|
status_tx.send(2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,7 +323,7 @@ impl<T: StreamType> Bot<T> {
|
|||||||
iter += 1;
|
iter += 1;
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(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);
|
println!("[{}/WORKER] Worker stopped.", self.username);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ pub struct Configuration {
|
|||||||
spam_delay_ms: i32,
|
spam_delay_ms: i32,
|
||||||
random_prefix: bool,
|
random_prefix: bool,
|
||||||
pub worker_threads: i32,
|
pub worker_threads: i32,
|
||||||
pub use_thread_pool: bool
|
pub use_thread_pool: bool,
|
||||||
|
pub update_worker_threads: i32
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Configuration {
|
impl Configuration {
|
||||||
@@ -65,6 +66,7 @@ impl Configuration {
|
|||||||
random_prefix: false,
|
random_prefix: false,
|
||||||
worker_threads: 100,
|
worker_threads: 100,
|
||||||
use_thread_pool: true,
|
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 bot_socks5::BotVariable;
|
||||||
use reqwest;
|
use reqwest;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
// use tokio::task;
|
// use tokio::task;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
@@ -53,11 +54,19 @@ async fn main() {
|
|||||||
.worker_threads(configuration_rc.worker_threads as usize)
|
.worker_threads(configuration_rc.worker_threads as usize)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.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 {
|
for _ in 0..configuration_rc.count() -1 {
|
||||||
let lock_clone = thread_lock.clone();
|
let lock_clone = thread_lock.clone();
|
||||||
let configuration_rc_clone = configuration_rc.clone();
|
let configuration_rc_clone = configuration_rc.clone();
|
||||||
let variables_clone = variables.clone();
|
let variables_clone = variables.clone();
|
||||||
|
let rt_update_clone = rt_update.clone();
|
||||||
// let handle = tokio::spawn(async move {
|
// let handle = tokio::spawn(async move {
|
||||||
// attack_thread(lock_clone).await;
|
// attack_thread(lock_clone).await;
|
||||||
// println!("[MAIN] Thread {} created", i);
|
// 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 = tokio::task::spawn(attack_thread(lock_clone,configuration_rc_clone,variables_clone));
|
||||||
// let handle;
|
// let handle;
|
||||||
if configuration_rc.use_thread_pool {
|
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{
|
}else{
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
tokio::runtime::Builder::new_current_thread()
|
tokio::runtime::Builder::new_current_thread()
|
||||||
@@ -75,7 +84,7 @@ async fn main() {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.block_on(async move {
|
.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);
|
// println!("[MAIN] Thread {} created", i);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -90,11 +99,12 @@ async fn main() {
|
|||||||
let lock_clone = thread_lock.clone();
|
let lock_clone = thread_lock.clone();
|
||||||
let configuration_rc_clone = configuration_rc.clone();
|
let configuration_rc_clone = configuration_rc.clone();
|
||||||
let variables_clone = variables.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 {
|
loop {
|
||||||
// 请求proxy(如果有)
|
// 请求proxy(如果有)
|
||||||
let username = generate_username(&config);
|
let username = generate_username(&config);
|
||||||
@@ -149,7 +159,7 @@ async fn attack_thread(lock: Arc<Mutex<()>>, config: Arc<Configuration>, variabl
|
|||||||
// 插入生成update_worker线程的代码
|
// 插入生成update_worker线程的代码
|
||||||
let mut bot_clone = bot.clone();
|
let mut bot_clone = bot.clone();
|
||||||
let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<u8>();
|
let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<u8>();
|
||||||
tokio::spawn(async move {
|
rt_update.spawn(async move {
|
||||||
bot_clone.update_worker(rx).await;
|
bot_clone.update_worker(rx).await;
|
||||||
});
|
});
|
||||||
match bot.run(tx).await {
|
match bot.run(tx).await {
|
||||||
|
|||||||
Reference in New Issue
Block a user