Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-24 15:20:35 +01:00
Merge pull request #307 from mikroskeem/feature/prevent-proxy-connections
Add prevent-proxy-connections option
Dieser Commit ist enthalten in:
Commit
2418cc271a
@ -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
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren