Add option to allow Forge clients through host keys.

Setting "security.host-keys-allow-forge-clients" will accept the "\0FML\0" identifier that Forge clients add to their host name when connecting to a server.
Fixes WORLDGUARD-3537, WORLDGUARD-3596.
This commit is contained in:
wizjany 2016-12-22 19:42:19 -05:00
parent 46cca2b950
commit 67ece5c5d7
2 changed files with 4 additions and 1 deletions

View File

@ -91,6 +91,7 @@ public class ConfigurationManager {
public boolean keepUnresolvedNames; public boolean keepUnresolvedNames;
@Unreported public Map<String, String> hostKeys = new HashMap<String, String>(); @Unreported public Map<String, String> hostKeys = new HashMap<String, String>();
public boolean hostKeysAllowFMLClients;
/** /**
* Region Storage Configuration method, and config values * Region Storage Configuration method, and config values
@ -169,6 +170,7 @@ public void load() {
hostKeys.put(key.toLowerCase(), value); hostKeys.put(key.toLowerCase(), value);
} }
} }
hostKeysAllowFMLClients = config.getBoolean("security.host-keys-allow-forge-clients", false);
// ==================================================================== // ====================================================================
// Region store drivers // Region store drivers

View File

@ -183,7 +183,8 @@ public void onPlayerLogin(PlayerLoginEvent event) {
hostname = hostname.substring(0, colonIndex); hostname = hostname.substring(0, colonIndex);
} }
if (!hostname.equals(hostKey)) { if (!hostname.equals(hostKey)
&& !(cfg.hostKeysAllowFMLClients && hostname.equals(hostKey + "\u0000FML\u0000"))) {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
"You did not join with the valid host key!"); "You did not join with the valid host key!");
log.warning("WorldGuard host key check: " + log.warning("WorldGuard host key check: " +