Fix: 修复逻辑错误,自动移除错误代理

This commit is contained in:
SerendipityR 2024-02-03 02:39:32 +08:00 committed by GitHub
parent 0605c8f355
commit 85f3f7948d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 11 deletions

View File

@ -99,7 +99,7 @@ AdvancedSettings:
# 自动重连设置
Rejoin:
# 重新加入前模拟刷新服务器列表
GetMotdBeforeRejoin: true
GetMotdBeforeRejoin: false
GetMotdCount: 5
GetMotdDelay: 500
# 自动重连次数/间隔

View File

@ -198,15 +198,6 @@ public class BotManager {
botHandler.setClientTimeout(client, ConfigUtil.ConnectTimeout);
// 连接到服务器
if (!doubleAttack && ConfigUtil.GetMotdBeforeRejoin) {
for (int i = 0; i < ConfigUtil.GetMotdCount; i++) {
try {
new UniverseMethods().getMotd(proxy, ConfigUtil.AttackAddress, ConfigUtil.AttackPort);
} catch (Throwable ignored) {
}
OtherUtils.doSleep(ConfigUtil.GetMotdDelay);
}
}
botHandler.connect(client, proxy);
while (botHandler.checkClientStatus(client)) {
@ -455,6 +446,17 @@ public class BotManager {
Object client = botHandler.createClient(proxy, userName);
BotManager.clientList.put(client, userName);
botHandler.setClientTimeout(client, ConfigUtil.ConnectTimeout);
if (ConfigUtil.GetMotdBeforeRejoin) {
for (int a = 0; a < ConfigUtil.GetMotdCount; a++) {
try {
new UniverseMethods().getMotd(proxy, ConfigUtil.AttackAddress, ConfigUtil.AttackPort);
} catch (Throwable ignored) {
}
OtherUtils.doSleep(ConfigUtil.GetMotdDelay);
}
}
botHandler.connect(client, proxy);
while (botHandler.checkClientStatus(client)) {

View File

@ -47,7 +47,12 @@ public class UniverseMethods {
int size = ProxyUtil.proxies.size();
String p = ProxyUtil.proxies.get(BotManager.clientList.size() % size);
String[] _p = p.split(":");
try {
return new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1])));
} catch (Exception e) {
ProxyUtil.proxies.remove(p);
}
return getProxy(proxyType);
}
public static Proxy.Type getProxyType(int type) {