13
0
geforkt von Mirrors/Velocity

Add prevent-proxy-connections option to make sending client IP to Mojang toggleable

Dieser Commit ist enthalten in:
Mark Vainomaa 2020-05-08 03:03:49 +03:00
Ursprung 5424c55f09
Commit 21f03d5d50
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1B3F9523B542D315
3 geänderte Dateien mit 28 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -62,6 +62,15 @@ public interface ProxyConfig {
*/ */
boolean isOnlineMode(); boolean isOnlineMode();
/**
* If client's ISP/AS sent from this proxy is different from the one from Mojang's
* authentication server, the player is kicked. This disallows some VPN and proxy
* connections but is a weak form of protection.
*
* @return whether to prevent client proxy connections by checking the IP with Mojang servers
*/
boolean shouldPreventClientProxyConnections();
/** /**
* Get a Map of all servers registered in <code>velocity.toml</code>. This method does * Get a Map of all servers registered in <code>velocity.toml</code>. This method does
* <strong>not</strong> return all the servers currently in memory, although in most cases it * <strong>not</strong> return all the servers currently in memory, although in most cases it

Datei anzeigen

@ -54,6 +54,14 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
@ConfigKey("online-mode") @ConfigKey("online-mode")
private boolean onlineMode = true; private boolean onlineMode = true;
@Comment({
"If client's ISP/AS sent from this proxy is different from the one from Mojang's",
"authentication server, the player is kicked. This disallows some VPN and proxy",
"connections but is a weak form of protection."
})
@ConfigKey("prevent-client-proxy-connections")
private boolean preventClientProxyConnections = false;
@Comment({ @Comment({
"Should we forward IP addresses and other data to backend servers?", "Should we forward IP addresses and other data to backend servers?",
"Available options:", "Available options:",
@ -328,6 +336,11 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
return onlineMode; return onlineMode;
} }
@Override
public boolean shouldPreventClientProxyConnections() {
return preventClientProxyConnections;
}
public PlayerInfoForwarding getPlayerInfoForwardingMode() { public PlayerInfoForwarding getPlayerInfoForwardingMode() {
return playerInfoForwardingMode; return playerInfoForwardingMode;
} }

Datei anzeigen

@ -50,7 +50,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
private static final Logger logger = LogManager.getLogger(LoginSessionHandler.class); private static final Logger logger = LogManager.getLogger(LoginSessionHandler.class);
private static final String MOJANG_HASJOINED_URL = private static final String MOJANG_HASJOINED_URL =
"https://sessionserver.mojang.com/session/minecraft/hasJoined?username=%s&serverId=%s&ip=%s"; "https://sessionserver.mojang.com/session/minecraft/hasJoined?username=%s&serverId=%s";
private final VelocityServer server; private final VelocityServer server;
private final MinecraftConnection mcConnection; private final MinecraftConnection mcConnection;
@ -96,8 +96,11 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
String playerIp = ((InetSocketAddress) mcConnection.getRemoteAddress()).getHostString(); String playerIp = ((InetSocketAddress) mcConnection.getRemoteAddress()).getHostString();
String url = String.format(MOJANG_HASJOINED_URL, String url = String.format(MOJANG_HASJOINED_URL,
urlFormParameterEscaper().escape(login.getUsername()), serverId, urlFormParameterEscaper().escape(login.getUsername()), serverId);
urlFormParameterEscaper().escape(playerIp));
if (server.getConfiguration().shouldPreventClientProxyConnections()) {
url += "&ip=" + urlFormParameterEscaper().escape(playerIp);
}
ListenableFuture<Response> hasJoinedResponse = server.getAsyncHttpClient().prepareGet(url) ListenableFuture<Response> hasJoinedResponse = server.getAsyncHttpClient().prepareGet(url)
.execute(); .execute();