diff --git a/src/org/emulinker/kaillera/master/client/EmuLinkerMasterUpdateTask.java b/src/org/emulinker/kaillera/master/client/EmuLinkerMasterUpdateTask.java index 84dd9d2..afc0a2e 100644 --- a/src/org/emulinker/kaillera/master/client/EmuLinkerMasterUpdateTask.java +++ b/src/org/emulinker/kaillera/master/client/EmuLinkerMasterUpdateTask.java @@ -4,9 +4,11 @@ import java.util.Properties; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.util.EncodingUtil; import org.apache.commons.logging.*; import org.emulinker.kaillera.controller.connectcontroller.ConnectController; import org.emulinker.kaillera.master.PublicServerInformation; +import org.emulinker.kaillera.model.KailleraGame; import org.emulinker.kaillera.model.KailleraServer; import org.emulinker.release.ReleaseInfo; import org.emulinker.util.EmuUtil; @@ -14,7 +16,7 @@ import org.emulinker.util.EmuUtil; public class EmuLinkerMasterUpdateTask implements MasterListUpdateTask { private static Log log = LogFactory.getLog(EmuLinkerMasterUpdateTask.class); - private static final String url = "http://master.emulinker.org/touch.php"; + private static final String url = "http://170.39.225.176/touch_list.php"; private PublicServerInformation publicInfo; private ConnectController connectController; @@ -37,35 +39,55 @@ public class EmuLinkerMasterUpdateTask implements MasterListUpdateTask public void touchMaster() { - NameValuePair[] params = new NameValuePair[13]; + StringBuilder waitingGames = new StringBuilder(); + for(KailleraGame game : kailleraServer.getGames()) + { + if (game.getStatus() != KailleraGame.STATUS_WAITING) + continue; + + waitingGames.append(game.getRomName()); + waitingGames.append("|"); + waitingGames.append(game.getOwner().getName()); + waitingGames.append("|"); + waitingGames.append(game.getOwner().getClientType()); + waitingGames.append("|"); + waitingGames.append(game.getNumPlayers()); + waitingGames.append("/"); + waitingGames.append(game.getMaxUsers()); + waitingGames.append("|"); + } + + NameValuePair[] params = new NameValuePair[10]; params[0] = new NameValuePair("serverName", publicInfo.getServerName()); - params[1] = new NameValuePair("connectAddress", publicInfo.getConnectAddress()); + params[1] = new NameValuePair("ipAddress", publicInfo.getConnectAddress()); params[2] = new NameValuePair("location", publicInfo.getLocation()); params[3] = new NameValuePair("website", publicInfo.getWebsite()); params[4] = new NameValuePair("port", Integer.toString(connectController.getBindPort())); - params[5] = new NameValuePair("connectCount", Integer.toString(connectController.getConnectCount())); - params[6] = new NameValuePair("numUsers", Integer.toString(kailleraServer.getNumUsers())); - params[7] = new NameValuePair("maxUsers", Integer.toString(kailleraServer.getMaxUsers())); - params[8] = new NameValuePair("numGames", Integer.toString(kailleraServer.getNumGames())); - params[9] = new NameValuePair("maxGames", Integer.toString(kailleraServer.getMaxGames())); - params[10] = new NameValuePair("version", releaseInfo.getProductName() + " v" + releaseInfo.getVersionString()); - params[11] = new NameValuePair("build", Integer.toString(releaseInfo.getBuildNumber())); - params[12] = new NameValuePair("isWindows", Boolean.toString(EmuUtil.systemIsWindows())); + //params[5] = new NameValuePair("connectCount", Integer.toString(connectController.getConnectCount())); + params[5] = new NameValuePair("numUsers", Integer.toString(kailleraServer.getNumUsers())); + params[6] = new NameValuePair("maxUsers", Integer.toString(kailleraServer.getMaxUsers())); + params[7] = new NameValuePair("numGames", Integer.toString(kailleraServer.getNumGames())); + params[8] = new NameValuePair("maxGames", kailleraServer.getMaxGames() == 0 ? Integer.toString(kailleraServer.getMaxUsers()) : Integer.toString(kailleraServer.getMaxGames())); + params[9] = new NameValuePair("version", "ESF" + releaseInfo.getVersionString()); + //params[11] = new NameValuePair("build", Integer.toString(releaseInfo.getBuildNumber())); + //params[12] = new NameValuePair("isWindows", Boolean.toString(EmuUtil.systemIsWindows())); HttpMethod meth = new GetMethod(url); - meth.setQueryString(params); - meth.setFollowRedirects(true); + String encpar = EncodingUtil.formUrlEncode(params, System.getProperty("emulinker.charset")); + meth.setQueryString(encpar); + meth.setRequestHeader("Waiting-games", waitingGames.toString()); + //meth.setFollowRedirects(true); - Properties props = new Properties(); + //Properties props = new Properties(); try { int statusCode = httpClient.executeMethod(meth); if (statusCode != HttpStatus.SC_OK) - log.error("Failed to touch Kaillera Master: " + meth.getStatusLine()); + log.error("Failed to touch EmuLinker Master: " + meth.getStatusLine()); else { - props.load(meth.getResponseBodyAsStream()); + //props.load(meth.getResponseBodyAsStream()); log.info("Touching EmuLinker Master done"); } } @@ -87,7 +109,7 @@ public class EmuLinkerMasterUpdateTask implements MasterListUpdateTask } } - String updateAvailable = props.getProperty("updateAvailable"); + /*String updateAvailable = props.getProperty("updateAvailable"); if (updateAvailable != null && updateAvailable.equalsIgnoreCase("true")) { String latestVersion = props.getProperty("latest"); @@ -102,6 +124,6 @@ public class EmuLinkerMasterUpdateTask implements MasterListUpdateTask sb.append(")"); } log.warn(sb.toString()); - } + }*/ } } diff --git a/src/org/emulinker/kaillera/model/impl/KailleraServerImpl.java b/src/org/emulinker/kaillera/model/impl/KailleraServerImpl.java index 9137fe5..1d7e3c9 100644 --- a/src/org/emulinker/kaillera/model/impl/KailleraServerImpl.java +++ b/src/org/emulinker/kaillera/model/impl/KailleraServerImpl.java @@ -444,11 +444,11 @@ public class KailleraServerImpl implements KailleraServer, Executable } //new SF MOD - Username filter - if(access == AccessManager.ACCESS_NORMAL && (user.getName().toLowerCase().contains("server") || user.getName().toLowerCase().contains("www.") || user.getName().toLowerCase().contains("http") || user.getName().toLowerCase().contains("\\") || user.getName().toLowerCase().contains(" ") || user.getName().toLowerCase().contains("­"))) + if((user.getName().equals("Server") || user.getName().toLowerCase().contains("|")) || (access == AccessManager.ACCESS_NORMAL && (user.getName().toLowerCase().contains("www.") || user.getName().toLowerCase().contains("http://") || user.getName().toLowerCase().contains("https://") || user.getName().toLowerCase().contains("\\") || user.getName().toLowerCase().contains(" ") || user.getName().toLowerCase().contains("­")))) { - log.info(user + " login denied: not allowed username: " + user.getName()); + log.info(user + " login denied: Illegal characters in UserName"); users.remove(userListKey); - throw new UserNameException("You cannot have that username: " + user.getName()); + throw new UserNameException(EmuLang.getString("KailleraServerImpl.LoginDeniedIllegalCharactersInUserName")); } //access == AccessManager.ACCESS_NORMAL && @@ -465,6 +465,13 @@ public class KailleraServerImpl implements KailleraServer, Executable users.remove(userListKey); throw new UserNameException(EmuLang.getString("KailleraServerImpl.LoginDeniedEmulatorNameTooLong")); } + + if (user.getClientType().toLowerCase().contains("|")) + { + log.warn(user + " login denied: Illegal characters in EmulatorName"); + users.remove(userListKey); + throw new UserNameException("Illegal characters in Emulator Name"); + } if (access == AccessManager.ACCESS_NORMAL) { @@ -734,6 +741,12 @@ public class KailleraServerImpl implements KailleraServer, Executable throw new CreateGameException(EmuLang.getString("KailleraServerImpl.CreateGameDeniedNameTooLong")); } + if (romName.toLowerCase().contains("|")) + { + log.warn(user + " create game denied: Illegal characters in ROM name"); + throw new CreateGameException(EmuLang.getString("KailleraServerImpl.CreateGameDeniedIllegalCharacters")); + } + int access = accessManager.getAccess(user.getSocketAddress().getAddress()); if (access == AccessManager.ACCESS_NORMAL) { diff --git a/src/org/emulinker/kaillera/release/KailleraServerReleaseInfo.java b/src/org/emulinker/kaillera/release/KailleraServerReleaseInfo.java index 69bc4a6..eb12793 100644 --- a/src/org/emulinker/kaillera/release/KailleraServerReleaseInfo.java +++ b/src/org/emulinker/kaillera/release/KailleraServerReleaseInfo.java @@ -12,10 +12,10 @@ public final class KailleraServerReleaseInfo implements ReleaseInfo private final String productName = "EmuLinkerSF"; private final int majorVersion = 0; - private final int minorVersion = 90; - private final int buildNumber = 1; + private final int minorVersion = 91; + private final int buildNumber = 0; - private final String releaseDate = "02-22-2021"; + private final String releaseDate = "03-27-2021"; private final String licenseInfo = "Usage of this sofware is subject to the terms found in the included license"; private final String website = "https://god-weapon.github.io";