From 2c6de937b3a93281e7c850b9a8a9fdd89dcb9d2e Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 14 Mar 2024 21:36:38 +0100 Subject: [PATCH 1/2] src/de/steamwar/bungeecore/mods/Hostname.java aktualisiert Signed-off-by: Chaoscaot --- src/de/steamwar/bungeecore/mods/Hostname.java | 124 +++++++++--------- 1 file changed, 63 insertions(+), 61 deletions(-) diff --git a/src/de/steamwar/bungeecore/mods/Hostname.java b/src/de/steamwar/bungeecore/mods/Hostname.java index e316c553..0025a409 100644 --- a/src/de/steamwar/bungeecore/mods/Hostname.java +++ b/src/de/steamwar/bungeecore/mods/Hostname.java @@ -1,61 +1,63 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2024 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bungeecore.mods; - -import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.listeners.BasicListener; -import net.md_5.bungee.api.event.PlayerHandshakeEvent; -import net.md_5.bungee.connection.InitialHandler; -import net.md_5.bungee.event.EventHandler; - -import java.util.HashSet; -import java.util.Set; -import java.util.logging.Level; - -public class Hostname extends BasicListener { - - private final Set knownHostnames = new HashSet<>(); - private final Set knownExtraData = new HashSet<>(); - - public Hostname() { - knownHostnames.add("steamwar.de"); - knownHostnames.add("78.31.71.136"); - knownHostnames.add("@mat:matdoes.dev"); //https://github.com/mat-1/matscan - knownHostnames.add("wtf.mynx.lol"); //https://discord.com/invite/serverseeker - knownHostnames.add("127.0.0.1"); // Geyser - - knownExtraData.add(""); - knownExtraData.add("\0FML\0"); - knownExtraData.add("\0FML2\0"); - knownExtraData.add("\0FML3\0"); - knownExtraData.add("\0FORGE"); - } - - @EventHandler - public void onHandshake(PlayerHandshakeEvent event) { - String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake(); - if (!knownHostnames.contains(event.getHandshake().getHost().toLowerCase())) { - BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown hostname " + event.getHandshake() + " " + extraDataInHandshake); - } else if (!knownExtraData.contains(extraDataInHandshake)) { - BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown extra data " + event.getHandshake() + " " + extraDataInHandshake); - - } - } -} +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bungeecore.mods; + +import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.listeners.BasicListener; +import net.md_5.bungee.api.event.PlayerHandshakeEvent; +import net.md_5.bungee.connection.InitialHandler; +import net.md_5.bungee.event.EventHandler; + +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Level; + +public class Hostname extends BasicListener { + + private final Set knownHostnames = new HashSet<>(); + private final Set knownExtraData = new HashSet<>(); + + public Hostname() { + knownHostnames.add("steamwar.de"); + knownHostnames.add("78.31.71.136"); + knownHostnames.add("@mat:matdoes.dev"); //https://github.com/mat-1/matscan + knownHostnames.add("wtf.mynx.lol"); //https://discord.com/invite/serverseeker + knownHostnames.add("127.0.0.1"); // Geyser + knownHostnames.add("memewar.de"); + knownHostnames.add("dampfkrieg.de"); + + knownExtraData.add(""); + knownExtraData.add("\0FML\0"); + knownExtraData.add("\0FML2\0"); + knownExtraData.add("\0FML3\0"); + knownExtraData.add("\0FORGE"); + } + + @EventHandler + public void onHandshake(PlayerHandshakeEvent event) { + String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake(); + if (!knownHostnames.contains(event.getHandshake().getHost().toLowerCase())) { + BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown hostname " + event.getHandshake() + " " + extraDataInHandshake); + } else if (!knownExtraData.contains(extraDataInHandshake)) { + BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown extra data " + event.getHandshake() + " " + extraDataInHandshake); + + } + } +} From 8f3422dce6d218f52c2af63445a3ff82173c0c3b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 14 Mar 2024 21:39:22 +0100 Subject: [PATCH 2/2] Fix --- src/de/steamwar/bungeecore/mods/Hostname.java | 126 +++++++++--------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/de/steamwar/bungeecore/mods/Hostname.java b/src/de/steamwar/bungeecore/mods/Hostname.java index 0025a409..ed4575c2 100644 --- a/src/de/steamwar/bungeecore/mods/Hostname.java +++ b/src/de/steamwar/bungeecore/mods/Hostname.java @@ -1,63 +1,63 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2024 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bungeecore.mods; - -import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.listeners.BasicListener; -import net.md_5.bungee.api.event.PlayerHandshakeEvent; -import net.md_5.bungee.connection.InitialHandler; -import net.md_5.bungee.event.EventHandler; - -import java.util.HashSet; -import java.util.Set; -import java.util.logging.Level; - -public class Hostname extends BasicListener { - - private final Set knownHostnames = new HashSet<>(); - private final Set knownExtraData = new HashSet<>(); - - public Hostname() { - knownHostnames.add("steamwar.de"); - knownHostnames.add("78.31.71.136"); - knownHostnames.add("@mat:matdoes.dev"); //https://github.com/mat-1/matscan - knownHostnames.add("wtf.mynx.lol"); //https://discord.com/invite/serverseeker - knownHostnames.add("127.0.0.1"); // Geyser - knownHostnames.add("memewar.de"); - knownHostnames.add("dampfkrieg.de"); - - knownExtraData.add(""); - knownExtraData.add("\0FML\0"); - knownExtraData.add("\0FML2\0"); - knownExtraData.add("\0FML3\0"); - knownExtraData.add("\0FORGE"); - } - - @EventHandler - public void onHandshake(PlayerHandshakeEvent event) { - String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake(); - if (!knownHostnames.contains(event.getHandshake().getHost().toLowerCase())) { - BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown hostname " + event.getHandshake() + " " + extraDataInHandshake); - } else if (!knownExtraData.contains(extraDataInHandshake)) { - BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown extra data " + event.getHandshake() + " " + extraDataInHandshake); - - } - } -} +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bungeecore.mods; + +import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.listeners.BasicListener; +import net.md_5.bungee.api.event.PlayerHandshakeEvent; +import net.md_5.bungee.connection.InitialHandler; +import net.md_5.bungee.event.EventHandler; + +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Level; + +public class Hostname extends BasicListener { + + private final Set knownHostnames = new HashSet<>(); + private final Set knownExtraData = new HashSet<>(); + + public Hostname() { + knownHostnames.add("steamwar.de"); + knownHostnames.add("78.31.71.136"); + knownHostnames.add("@mat:matdoes.dev"); //https://github.com/mat-1/matscan + knownHostnames.add("wtf.mynx.lol"); //https://discord.com/invite/serverseeker + knownHostnames.add("127.0.0.1"); // Geyser + knownHostnames.add("memewar.de"); + knownHostnames.add("dampfkrieg.de"); + + knownExtraData.add(""); + knownExtraData.add("\0FML\0"); + knownExtraData.add("\0FML2\0"); + knownExtraData.add("\0FML3\0"); + knownExtraData.add("\0FORGE"); + } + + @EventHandler + public void onHandshake(PlayerHandshakeEvent event) { + String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake(); + if (!knownHostnames.contains(event.getHandshake().getHost().toLowerCase())) { + BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown hostname " + event.getHandshake() + " " + extraDataInHandshake); + } else if (!knownExtraData.contains(extraDataInHandshake)) { + BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown extra data " + event.getHandshake() + " " + extraDataInHandshake); + + } + } +}