src/de/steamwar/bungeecore/mods/Hostname.java aktualisiert
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Chaoscaot <chaoscaot@zohomail.eu>
Dieser Commit ist enthalten in:
Ursprung
49238463a5
Commit
2c6de937b3
@ -1,61 +1,63 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.bungeecore.mods;
|
package de.steamwar.bungeecore.mods;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Hostname extends BasicListener {
|
public class Hostname extends BasicListener {
|
||||||
|
|
||||||
private final Set<String> knownHostnames = new HashSet<>();
|
private final Set<String> knownHostnames = new HashSet<>();
|
||||||
private final Set<String> knownExtraData = new HashSet<>();
|
private final Set<String> knownExtraData = new HashSet<>();
|
||||||
|
|
||||||
public Hostname() {
|
public Hostname() {
|
||||||
knownHostnames.add("steamwar.de");
|
knownHostnames.add("steamwar.de");
|
||||||
knownHostnames.add("78.31.71.136");
|
knownHostnames.add("78.31.71.136");
|
||||||
knownHostnames.add("@mat:matdoes.dev"); //https://github.com/mat-1/matscan
|
knownHostnames.add("@mat:matdoes.dev"); //https://github.com/mat-1/matscan
|
||||||
knownHostnames.add("wtf.mynx.lol"); //https://discord.com/invite/serverseeker
|
knownHostnames.add("wtf.mynx.lol"); //https://discord.com/invite/serverseeker
|
||||||
knownHostnames.add("127.0.0.1"); // Geyser
|
knownHostnames.add("127.0.0.1"); // Geyser
|
||||||
|
knownHostnames.add("memewar.de");
|
||||||
knownExtraData.add("");
|
knownHostnames.add("dampfkrieg.de");
|
||||||
knownExtraData.add("\0FML\0");
|
|
||||||
knownExtraData.add("\0FML2\0");
|
knownExtraData.add("");
|
||||||
knownExtraData.add("\0FML3\0");
|
knownExtraData.add("\0FML\0");
|
||||||
knownExtraData.add("\0FORGE");
|
knownExtraData.add("\0FML2\0");
|
||||||
}
|
knownExtraData.add("\0FML3\0");
|
||||||
|
knownExtraData.add("\0FORGE");
|
||||||
@EventHandler
|
}
|
||||||
public void onHandshake(PlayerHandshakeEvent event) {
|
|
||||||
String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake();
|
@EventHandler
|
||||||
if (!knownHostnames.contains(event.getHandshake().getHost().toLowerCase())) {
|
public void onHandshake(PlayerHandshakeEvent event) {
|
||||||
BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown hostname " + event.getHandshake() + " " + extraDataInHandshake);
|
String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake();
|
||||||
} else if (!knownExtraData.contains(extraDataInHandshake)) {
|
if (!knownHostnames.contains(event.getHandshake().getHost().toLowerCase())) {
|
||||||
BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown extra data " + event.getHandshake() + " " + extraDataInHandshake);
|
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);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren