Skip to content

Commit

Permalink
渣翻
Browse files Browse the repository at this point in the history
  • Loading branch information
Loyisa committed Dec 19, 2022
1 parent ff2d5df commit d812735
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 153 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
BungeeCord with built in AntiBot protection. (English lang)
BungeeCord, 但是内置反假人. (Simplified Chinese)
==========

Videos
视频演示
--------
Captcha+Falling check:
验证码+重力检查:
[![Only captcha](https://i.ytimg.com/vi/S27EbttIG-8/1.jpg)](https://youtu.be/S27EbttIG-8)
Falling check:
重力检查:
[![Only captcha](https://i.ytimg.com/vi/23O16oJyvl8/1.jpg)](https://youtu.be/23O16oJyvl8)

Download
下载
--------
You can download this protection at [Releases](https://github.com/LoyisaSUS/BungeeCord-BotFilter-ENG/releases/)
你可以在[Releases](https://github.com/LoyisaSUS/BungeeCord-BotFilter-ZHCN/releases/) 下载

Credit
特别鸣谢
--------
[Leymooo](https://github.com/Leymooo) (Original BotFilter developer)<br>
[koloslolya](https://github.com/SleepyKolosLolya) (Help me translate BotFilter)<br>
[Maxsimuss](https://github.com/Maxsimuss) (Help me translate BotFilter)
[Leymooo](https://github.com/Leymooo) (BotFilter 开发者)<br>
[koloslolya](https://github.com/SleepyKolosLolya) (帮助了我翻译 BotFilter (俄->英))<br>
[Maxsimuss](https://github.com/Maxsimuss) (帮助了我翻译 BotFilter (俄->英))<br>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception

BungeeCord bungee = new BungeeCord();
ProxyServer.setInstance( bungee );
bungee.getLogger().log( Level.WARNING, "Enabled BungeeCord BotFilter-ENG {0} from https://github.com/LoyisaSUS/BungeeCord-BotFilter-ENG", bungee.getGameVersion() ); //BotFilter
bungee.getLogger().log( Level.WARNING, "Enabled BungeeCord BotFilter-ZHCN {0} from https://github.com/LoyisaSUS/BungeeCord-BotFilter-ZHCN", bungee.getGameVersion() ); //BotFilter
bungee.start();

if ( !options.has( "noconsole" ) )
Expand Down
22 changes: 11 additions & 11 deletions proxy/src/main/java/ru/leymooo/botfilter/BotFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void disable()
{
if ( connector.getUserConnection() != null )
{
connector.getUserConnection().disconnect( "§c[BotFilter] §aFilter reloading..." );
connector.getUserConnection().disconnect( "§c[BotFilter] §a重载反假人模块中..." );
}
connector.setState( CheckState.FAILED );
}
Expand Down Expand Up @@ -351,15 +351,15 @@ public void checkAsyncIfNeeded(InitialHandler handler)
if ( !Settings.IMP.PROTECTION.ALWAYS_CHECK && ManyChecksUtils.isManyChecks( address ) )
{
PacketUtils.kickPlayer( KickType.MANYCHECKS, Protocol.LOGIN, ch, version );
bungee.getLogger().log( Level.INFO, "(BF) [{0}] disconnected: Too many checks in 10 min", address );
bungee.getLogger().log( Level.INFO, "(BF) [{0}] 已断开: 玩家在10分钟之内数次未通过验证", address );
return;
}

ServerPingUtils ping = getServerPingUtils();
if ( ping.needCheck() && ping.needKickOrRemove( address ) )
{
PacketUtils.kickPlayer( KickType.PING, Protocol.LOGIN, ch, version );
bungee.getLogger().log( Level.INFO, "(BF) [{0}] disconnected: The player did not ping the server", address.getHostAddress() );
bungee.getLogger().log( Level.INFO, "(BF) [{0}] 已断开: 玩家没有ping过服务器", address.getHostAddress() );
return;
}

Expand All @@ -377,7 +377,7 @@ public void checkAsyncIfNeeded(InitialHandler handler)
if ( checkGeoIp( address ) )
{
PacketUtils.kickPlayer( KickType.COUNTRY, Protocol.LOGIN, ch, version );
bungee.getLogger().log( Level.INFO, "(BF) [{0}] disconnected: Country is not allowed",
bungee.getLogger().log( Level.INFO, "(BF) [{0}] 已断开: 不允许的国家",
address.getHostAddress() );
return;
}
Expand Down Expand Up @@ -414,8 +414,8 @@ private void checkForUpdates(boolean startup)
Logger logger = BungeeCord.getInstance().getLogger();
try
{
logger.log( Level.INFO, "[BotFilter] Checking for updates..." );
URL url = new URL( "https://raw.githubusercontent.com/LoyisaSUS/BungeeCord-BotFilter-ENG/master/version.txt" );
logger.log( Level.INFO, "[BotFilter] 检查更新中..." );
URL url = new URL( "https://raw.githubusercontent.com/LoyisaSUS/BungeeCord-BotFilter-ZHCN/master/version.txt" );
URLConnection conn = url.openConnection();
conn.setConnectTimeout( 1200 );
conn.setReadTimeout( 1200 );
Expand All @@ -425,21 +425,21 @@ private void checkForUpdates(boolean startup)
if ( !in.readLine().trim().equalsIgnoreCase( Settings.IMP.BOT_FILTER_VERSION ) )
{

logger.log( Level.INFO, "§c[BotFilter] §aNew update available!" );
logger.log( Level.INFO, "§c[BotFilter] §aPlease update to latest version!" );
logger.log( Level.INFO, "§c[BotFilter] §ahttps://github.com/LoyisaSUS/BungeeCord-BotFilter-ENG/releases/" );
logger.log( Level.INFO, "§c[BotFilter] §a有新的更新可用!" );
logger.log( Level.INFO, "§c[BotFilter] §a请更新到最新版本!" );
logger.log( Level.INFO, "§c[BotFilter] §ahttps://github.com/LoyisaSUS/BungeeCord-BotFilter-ZHCN/releases/" );
if ( startup )
{
Thread.sleep( 3500L );
}
} else
{
logger.log( Level.INFO, "[BotFilter] You are using the latest version!" );
logger.log( Level.INFO, "[BotFilter] 你正在使用最新的版本!" );
}
}
} catch ( IOException | InterruptedException ex )
{
logger.log( Level.WARNING, "[BotFilter] Can't check the update", ex );
logger.log( Level.WARNING, "[BotFilter] 无法检查更新", ex );
}
}

Expand Down
23 changes: 12 additions & 11 deletions proxy/src/main/java/ru/leymooo/botfilter/BotFilterCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ public void execute(CommandSender sender, String[] args)
if ( args.length == 0 )
{
sender.sendMessage( "§r--------------- §bBotFilter §cv" + Settings.IMP.BOT_FILTER_VERSION + "§r-----------------" );
sender.sendMessage( "§r> §lbotfilter reload §6- §aReload the configuration" );
sender.sendMessage( "§r> §lbotfilter stat §6- §aShow statistics" );
sender.sendMessage( "§r> §lbotfilter export §6- §aExport player list what passed the bot filter" );
sender.sendMessage( "§r> §lbotfilter protection on/off §6- §aEnable or disable manual mode 'under attack'" );
sender.sendMessage( "§r> §lbotfilter reload §6- §a重载配置文件" );
sender.sendMessage( "§r> §lbotfilter stat §6- §a显示统计数据" );
sender.sendMessage( "§r> §lbotfilter export §6- §a导出通过假人验证的玩家列表" );
sender.sendMessage( "§r> §lbotfilter protection on/off §6- §a手动启用或禁用'受到攻击'模式" );
sender.sendMessage( "§r--------------- §bBotFilter §r-----------------" );
} else if ( args[0].equalsIgnoreCase( "reload" ) )
{
BungeeCord.getInstance().getBotFilter().disable();
BungeeCord.getInstance().setBotFilter( new BotFilter( false ) );
sender.sendMessage( aCommand executed" );
sender.sendMessage( a指令已执行" );
} else if ( args[0].equalsIgnoreCase( "stat" ) || args[0].equalsIgnoreCase( "stats" ) || args[0].equalsIgnoreCase( "info" ) )
{
sendStat( sender );
} else if ( args[0].equalsIgnoreCase( "export" ) )
{
export( sender, args );
sender.sendMessage( aCommand executed" );
sender.sendMessage( a指令已执行" );
} else if ( args[0].equalsIgnoreCase( "protection" ) )
{
if ( args.length >= 2 )
{
boolean enable = args[1].equalsIgnoreCase( "on" );
BungeeCord.getInstance().getBotFilter().setForceProtectionEnabled( enable );
sender.sendMessage( aProtection " + ( enable ? "enabled" : cdisabled" ) );
sender.sendMessage( a保护已 " + ( enable ? "启用" : c禁用" ) );
}
}
}
Expand All @@ -67,11 +67,12 @@ private void sendStat(CommandSender sender)
{
BotFilter botFilter = BungeeCord.getInstance().getBotFilter();
sender.sendMessage( "§r----------------- §bBotFilter §cv" + Settings.IMP.BOT_FILTER_VERSION + " §r-----------------" );
sender.sendMessage( "§r> §lUnder attack: " + ( botFilter.isUnderAttack() ? "§cYes" : "§aNo" ) );
sender.sendMessage( "§r> §lBots on checking: " + botFilter.getOnlineOnFilter() );
sender.sendMessage( "§r> §lVerified player(s): " + botFilter.getUsersCount() );
sender.sendMessage( "§r> §l受到攻击: " + ( botFilter.isUnderAttack() ? "§cYes" : "§aNo" ) );
sender.sendMessage( "§r> §l验证中的玩家/假人: " + botFilter.getOnlineOnFilter() );
sender.sendMessage( "§r> §l已通过验证的玩家: " + botFilter.getUsersCount() );
sender.sendMessage( "§r> §lDownload BotFilter(RUS): http://www.rubukkit.org/threads/137038/" );
sender.sendMessage( "§r> §lDownload BotFilter(ENG): https://github.com/LoyisaSUS/BungeeCord/" );
sender.sendMessage( "§r> §lDownload BotFilter(ENG): https://github.com/LoyisaSUS/BungeeCord-BotFilter-ENG" );
sender.sendMessage( "§r> §l下载 BotFilter(简体中文): https://github.com/LoyisaSUS/BungeeCord-BotFilter-ZHCN" );
}

private void export(CommandSender sender, String[] args)
Expand Down
4 changes: 2 additions & 2 deletions proxy/src/main/java/ru/leymooo/botfilter/BotFilterThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void start()
if ( ( currTime - connector.getJoinTime() ) >= Settings.IMP.TIME_OUT )
{
connector.failed( KickType.TIMED_OUT, state == BotFilter.CheckState.CAPTCHA_ON_POSITION_FAILED
? "Too long fall check" : "Captcha not entered" );
? "重力检查超时" : "未输入验证码" );
TO_REMOVE_SET.add( entryset.getKey() );
continue;
} else if ( state == BotFilter.CheckState.CAPTCHA_ON_POSITION_FAILED || state == BotFilter.CheckState.ONLY_POSITION )
Expand All @@ -66,7 +66,7 @@ public static void start()

} catch ( Exception e )
{
bungee.getLogger().log( Level.WARNING, "[BotFilter] Unknown error. Please report it to the developer!", e );
bungee.getLogger().log( Level.WARNING, "[BotFilter] 未知错误. 请向开发者报告!", e );
} finally
{
if ( !TO_REMOVE_SET.isEmpty() )
Expand Down
24 changes: 12 additions & 12 deletions proxy/src/main/java/ru/leymooo/botfilter/Connector.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void spawn()
PacketUtils.titles[1].writeTitle( channel, version );
}
sendPing();
LOGGER.log( Level.INFO, toString() + " has connected" );
LOGGER.log( Level.INFO, toString() + " 已连接" );

}

Expand All @@ -128,7 +128,7 @@ public void handle(PacketWrapper packet) throws Exception
//There are no unknown packets which player will send and will be longer than 2048 bytes during check
if ( packet.packet == null && packet.buf.readableBytes() > 2048 )
{
failed( KickType.BIG_PACKET, "Sent packet larger than 2048 bytes (" + packet.buf.readableBytes() + ")" );
failed( KickType.BIG_PACKET, "发送的数据包大于2048字节 (" + packet.buf.readableBytes() + ")" );
}
}

Expand All @@ -140,7 +140,7 @@ public void disconnected(ChannelWrapper channel) throws Exception
case ONLY_CAPTCHA:
case ONLY_POSITION:
case CAPTCHA_POSITION:
String info = "(BF) [" + name + "|" + ip + "] left from server during check";
String info = "(BF) [" + name + "|" + ip + "] 在验证时退出了服务器";
LOGGER.log( Level.INFO, info );
FailedUtils.addIpToQueue( ip, KickType.LEAVED );
break;
Expand Down Expand Up @@ -176,15 +176,15 @@ public void completeCheck()
changeStateToCaptcha();
} else
{
failed( KickType.FAILED_FALLING, "Too fast check passed" );
failed( KickType.FAILED_FALLING, "过快的通过验证" );
}
}
return;
}
int devide = lastSend == 0 ? sentPings : sentPings - 1;
if ( botFilter.checkBigPing( totalping / ( devide <= 0 ? 1 : devide ) ) )
{
failed( KickType.PING, "Big ping" );
failed( KickType.PING, "延迟过高" );
return;
}
state = CheckState.SUCCESSFULLY;
Expand All @@ -201,7 +201,7 @@ public void completeCheck()
userConnection.setNeedLogin( false );
userConnection.getPendingConnection().finishLogin( userConnection, true );
markDisconnected = true;
LOGGER.log( Level.INFO, "[BotFilter] Player (" + name + "|" + ip + ") passed verification successfully" );
LOGGER.log( Level.INFO, "[BotFilter] 玩家 (" + name + "|" + ip + ") 成功地通过了验证" );
}

@Override
Expand All @@ -227,7 +227,7 @@ public void onMove()
changeStateToCaptcha();
} else
{
failed( KickType.FAILED_FALLING, "Failed position check" );
failed( KickType.FAILED_FALLING, "重力检查失败" );
}
return;
}
Expand Down Expand Up @@ -281,7 +281,7 @@ private void handleChat(String message)
{
if ( message.length() > 256 )
{
failed( KickType.FAILED_CAPTCHA, "Too long message" );
failed( KickType.FAILED_CAPTCHA, "消息过长" );
return;
}
if ( message.replace( "/", "" ).equals( captchaAnswer ) )
Expand All @@ -293,7 +293,7 @@ private void handleChat(String message)
sendCaptcha();
} else
{
failed( KickType.FAILED_CAPTCHA, "Failed captcha check" );
failed( KickType.FAILED_CAPTCHA, "验证码检查失败" );
}
}
}
Expand All @@ -312,7 +312,7 @@ public void handle(KeepAlive keepAlive) throws Exception
{
if ( lastSend == 0 )
{
failed( KickType.PING, "Tried send fake ping" );
failed( KickType.PING, "尝试发送虚假的 keepAlive 包" );
return;
}
long ping = System.currentTimeMillis() - lastSend;
Expand All @@ -330,7 +330,7 @@ public void handle(PluginMessage pluginMessage) throws Exception

if ( pluginMessagesBytes > MAX_PLUGIN_MESSAGES_BYTES )
{
failed( KickType.BIG_PACKET, "Bad PluginMessage's" );
failed( KickType.BIG_PACKET, "错误的PluginMessage" );
return;
}

Expand Down Expand Up @@ -384,7 +384,7 @@ public void failed(KickType type, String kickMessage)
state = CheckState.FAILED;
PacketUtils.kickPlayer( type, Protocol.GAME, userConnection.getCh(), version );
markDisconnected = true;
LOGGER.log( Level.INFO, "(BF) [" + name + "|" + ip + "] check failed: " + kickMessage );
LOGGER.log( Level.INFO, "(BF) [" + name + "|" + ip + "] 验证失败: " + kickMessage );
if ( type != KickType.BIG_PACKET )
{
FailedUtils.addIpToQueue( ip, type );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public static void init()

messages = new CachedMessage[]
{
new CachedMessage( Settings.IMP.MESSAGES.CHECKING_CAPTCHA_WRONG.replaceFirst( "%s", "2" ).replaceFirst( "%s", "chances" ) ),
new CachedMessage( Settings.IMP.MESSAGES.CHECKING_CAPTCHA_WRONG.replaceFirst( "%s", "1" ).replaceFirst( "%s", "chances" ) ),
new CachedMessage( Settings.IMP.MESSAGES.CHECKING_CAPTCHA_WRONG.replaceFirst( "%s", "2" ).replaceFirst( "%s", "" ) ),
new CachedMessage( Settings.IMP.MESSAGES.CHECKING_CAPTCHA_WRONG.replaceFirst( "%s", "1" ).replaceFirst( "%s", "" ) ),
new CachedMessage( Settings.IMP.MESSAGES.CHECKING ),
new CachedMessage( Settings.IMP.MESSAGES.CHECKING_CAPTCHA ),
new CachedMessage( Settings.IMP.MESSAGES.SUCCESSFULLY )
Expand All @@ -152,7 +152,7 @@ public static void init()
kickMessagesGame.put( KickType.FAILED_FALLING, failedMessage );
kickMessagesGame.put( KickType.TIMED_OUT, failedMessage );
kickMessagesGame.put( KickType.COUNTRY, new CachedPacket( createKickPacket( Settings.IMP.MESSAGES.KICK_COUNTRY ), kickGame ) );
kickMessagesGame.put( KickType.BIG_PACKET, new CachedPacket( createKickPacket( cFailed while checking. Please report it to the administration. (Big packet was sent)" ), kickGame ) );
kickMessagesGame.put( KickType.BIG_PACKET, new CachedPacket( createKickPacket( c验证失败。请向服务器管理员报告。(数据包大小异常)" ), kickGame ) );
kickMessagesLogin.put( KickType.PING, new CachedPacket( createKickPacket( String.join( "", Settings.IMP.SERVER_PING_CHECK.KICK_MESSAGE ) ), kickLogin ) );
kickMessagesLogin.put( KickType.MANYCHECKS, new CachedPacket( createKickPacket( Settings.IMP.MESSAGES.KICK_MANY_CHECKS ), kickLogin ) );
kickMessagesLogin.put( KickType.COUNTRY, new CachedPacket( createKickPacket( Settings.IMP.MESSAGES.KICK_COUNTRY ), kickLogin ) );
Expand Down Expand Up @@ -253,7 +253,7 @@ public static int rewriteVersion(int version)
int rewritten = VERSION_REWRITE[version];
if ( rewritten == -1 )
{
throw new IllegalArgumentException( "Version is not supported" );
throw new IllegalArgumentException( "不支持的版本" );
}
return rewritten;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ public void generateImages()
ThreadPoolExecutor ex = (ThreadPoolExecutor) executor;
while ( ex.getActiveCount() != 0 )
{
BungeeCord.getInstance().getLogger().log( Level.INFO, "[BotFilter] Generating Captcha... [{0}/900]", 900 - ex.getQueue().size() - ex.getActiveCount() );
BungeeCord.getInstance().getLogger().log( Level.INFO, "[BotFilter] 生成验证码中... [{0}/900]", 900 - ex.getQueue().size() - ex.getActiveCount() );
try
{
Thread.sleep( 1000L );
} catch ( InterruptedException ex1 )
{
BungeeCord.getInstance().getLogger().log( Level.WARNING, "[BotFilter] Can't generate the Captcha. Shutting down...", ex1 );
BungeeCord.getInstance().getLogger().log( Level.WARNING, "[BotFilter] 生成验证码失败! 关闭中...", ex1 );
System.exit( 0 );
return;
}
}
CachedCaptcha.generated = true;
executor.shutdownNow();
System.gc();
BungeeCord.getInstance().getLogger().log( Level.INFO, "[BotFilter] Captcha was generated in {0} ms", System.currentTimeMillis() - start );
BungeeCord.getInstance().getLogger().log( Level.INFO, "[BotFilter] 验证码生成成功! 耗时: {0} ms", System.currentTimeMillis() - start );
}


Expand Down
Loading

0 comments on commit d812735

Please sign in to comment.