Ursprung
2c6de937b3
Commit
8f3422dce6
@ -1,63 +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");
|
knownHostnames.add("memewar.de");
|
||||||
knownHostnames.add("dampfkrieg.de");
|
knownHostnames.add("dampfkrieg.de");
|
||||||
|
|
||||||
knownExtraData.add("");
|
knownExtraData.add("");
|
||||||
knownExtraData.add("\0FML\0");
|
knownExtraData.add("\0FML\0");
|
||||||
knownExtraData.add("\0FML2\0");
|
knownExtraData.add("\0FML2\0");
|
||||||
knownExtraData.add("\0FML3\0");
|
knownExtraData.add("\0FML3\0");
|
||||||
knownExtraData.add("\0FORGE");
|
knownExtraData.add("\0FORGE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onHandshake(PlayerHandshakeEvent event) {
|
public void onHandshake(PlayerHandshakeEvent event) {
|
||||||
String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake();
|
String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake();
|
||||||
if (!knownHostnames.contains(event.getHandshake().getHost().toLowerCase())) {
|
if (!knownHostnames.contains(event.getHandshake().getHost().toLowerCase())) {
|
||||||
BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown hostname " + event.getHandshake() + " " + extraDataInHandshake);
|
BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown hostname " + event.getHandshake() + " " + extraDataInHandshake);
|
||||||
} else if (!knownExtraData.contains(extraDataInHandshake)) {
|
} else if (!knownExtraData.contains(extraDataInHandshake)) {
|
||||||
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 extra data " + event.getHandshake() + " " + extraDataInHandshake);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren