Skip to content

Commit

Permalink
Fix: 修复逻辑错误,自动移除错误代理
Browse files Browse the repository at this point in the history
  • Loading branch information
SerendipityR-2022 authored Feb 2, 2024
1 parent 0605c8f commit 85f3f79
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Main/src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ AdvancedSettings:
# 自动重连设置
Rejoin:
# 重新加入前模拟刷新服务器列表
GetMotdBeforeRejoin: true
GetMotdBeforeRejoin: false
GetMotdCount: 5
GetMotdDelay: 500
# 自动重连次数/间隔
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,6 @@ public void run() {
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)) {
Expand Down Expand Up @@ -455,6 +446,17 @@ public void run() {
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ public static Proxy getProxy(Proxy.Type proxyType) {
int size = ProxyUtil.proxies.size();
String p = ProxyUtil.proxies.get(BotManager.clientList.size() % size);
String[] _p = p.split(":");
return new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1])));
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) {
Expand Down

0 comments on commit 85f3f79

Please sign in to comment.