v91.0 changes

This commit is contained in:
Jgunishka 2021-04-10 20:51:38 +03:00
parent 5425bcfa32
commit cffe93b1ea
3 changed files with 59 additions and 24 deletions

View File

@ -4,9 +4,11 @@ import java.util.Properties;
import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.util.EncodingUtil;
import org.apache.commons.logging.*; import org.apache.commons.logging.*;
import org.emulinker.kaillera.controller.connectcontroller.ConnectController; import org.emulinker.kaillera.controller.connectcontroller.ConnectController;
import org.emulinker.kaillera.master.PublicServerInformation; import org.emulinker.kaillera.master.PublicServerInformation;
import org.emulinker.kaillera.model.KailleraGame;
import org.emulinker.kaillera.model.KailleraServer; import org.emulinker.kaillera.model.KailleraServer;
import org.emulinker.release.ReleaseInfo; import org.emulinker.release.ReleaseInfo;
import org.emulinker.util.EmuUtil; import org.emulinker.util.EmuUtil;
@ -14,7 +16,7 @@ import org.emulinker.util.EmuUtil;
public class EmuLinkerMasterUpdateTask implements MasterListUpdateTask public class EmuLinkerMasterUpdateTask implements MasterListUpdateTask
{ {
private static Log log = LogFactory.getLog(EmuLinkerMasterUpdateTask.class); 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 PublicServerInformation publicInfo;
private ConnectController connectController; private ConnectController connectController;
@ -37,35 +39,55 @@ public class EmuLinkerMasterUpdateTask implements MasterListUpdateTask
public void touchMaster() 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[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[2] = new NameValuePair("location", publicInfo.getLocation());
params[3] = new NameValuePair("website", publicInfo.getWebsite()); params[3] = new NameValuePair("website", publicInfo.getWebsite());
params[4] = new NameValuePair("port", Integer.toString(connectController.getBindPort())); params[4] = new NameValuePair("port", Integer.toString(connectController.getBindPort()));
params[5] = new NameValuePair("connectCount", Integer.toString(connectController.getConnectCount())); //params[5] = new NameValuePair("connectCount", Integer.toString(connectController.getConnectCount()));
params[6] = new NameValuePair("numUsers", Integer.toString(kailleraServer.getNumUsers())); params[5] = new NameValuePair("numUsers", Integer.toString(kailleraServer.getNumUsers()));
params[7] = new NameValuePair("maxUsers", Integer.toString(kailleraServer.getMaxUsers())); params[6] = new NameValuePair("maxUsers", Integer.toString(kailleraServer.getMaxUsers()));
params[8] = new NameValuePair("numGames", Integer.toString(kailleraServer.getNumGames())); params[7] = new NameValuePair("numGames", Integer.toString(kailleraServer.getNumGames()));
params[9] = new NameValuePair("maxGames", Integer.toString(kailleraServer.getMaxGames())); params[8] = new NameValuePair("maxGames", kailleraServer.getMaxGames() == 0 ? Integer.toString(kailleraServer.getMaxUsers()) : Integer.toString(kailleraServer.getMaxGames()));
params[10] = new NameValuePair("version", releaseInfo.getProductName() + " v" + releaseInfo.getVersionString()); params[9] = new NameValuePair("version", "ESF" + releaseInfo.getVersionString());
params[11] = new NameValuePair("build", Integer.toString(releaseInfo.getBuildNumber())); //params[11] = new NameValuePair("build", Integer.toString(releaseInfo.getBuildNumber()));
params[12] = new NameValuePair("isWindows", Boolean.toString(EmuUtil.systemIsWindows())); //params[12] = new NameValuePair("isWindows", Boolean.toString(EmuUtil.systemIsWindows()));
HttpMethod meth = new GetMethod(url); HttpMethod meth = new GetMethod(url);
meth.setQueryString(params); String encpar = EncodingUtil.formUrlEncode(params, System.getProperty("emulinker.charset"));
meth.setFollowRedirects(true); meth.setQueryString(encpar);
meth.setRequestHeader("Waiting-games", waitingGames.toString());
//meth.setFollowRedirects(true);
Properties props = new Properties(); //Properties props = new Properties();
try try
{ {
int statusCode = httpClient.executeMethod(meth); int statusCode = httpClient.executeMethod(meth);
if (statusCode != HttpStatus.SC_OK) if (statusCode != HttpStatus.SC_OK)
log.error("Failed to touch Kaillera Master: " + meth.getStatusLine()); log.error("Failed to touch EmuLinker Master: " + meth.getStatusLine());
else else
{ {
props.load(meth.getResponseBodyAsStream()); //props.load(meth.getResponseBodyAsStream());
log.info("Touching EmuLinker Master done"); 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")) if (updateAvailable != null && updateAvailable.equalsIgnoreCase("true"))
{ {
String latestVersion = props.getProperty("latest"); String latestVersion = props.getProperty("latest");
@ -102,6 +124,6 @@ public class EmuLinkerMasterUpdateTask implements MasterListUpdateTask
sb.append(")"); sb.append(")");
} }
log.warn(sb.toString()); log.warn(sb.toString());
} }*/
} }
} }

View File

@ -444,11 +444,11 @@ public class KailleraServerImpl implements KailleraServer, Executable
} }
//new SF MOD - Username filter //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); users.remove(userListKey);
throw new UserNameException("You cannot have that username: " + user.getName()); throw new UserNameException(EmuLang.getString("KailleraServerImpl.LoginDeniedIllegalCharactersInUserName"));
} }
//access == AccessManager.ACCESS_NORMAL && //access == AccessManager.ACCESS_NORMAL &&
@ -465,6 +465,13 @@ public class KailleraServerImpl implements KailleraServer, Executable
users.remove(userListKey); users.remove(userListKey);
throw new UserNameException(EmuLang.getString("KailleraServerImpl.LoginDeniedEmulatorNameTooLong")); 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) if (access == AccessManager.ACCESS_NORMAL)
{ {
@ -734,6 +741,12 @@ public class KailleraServerImpl implements KailleraServer, Executable
throw new CreateGameException(EmuLang.getString("KailleraServerImpl.CreateGameDeniedNameTooLong")); 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()); int access = accessManager.getAccess(user.getSocketAddress().getAddress());
if (access == AccessManager.ACCESS_NORMAL) if (access == AccessManager.ACCESS_NORMAL)
{ {

View File

@ -12,10 +12,10 @@ public final class KailleraServerReleaseInfo implements ReleaseInfo
private final String productName = "EmuLinkerSF"; private final String productName = "EmuLinkerSF";
private final int majorVersion = 0; private final int majorVersion = 0;
private final int minorVersion = 90; private final int minorVersion = 91;
private final int buildNumber = 1; 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 licenseInfo = "Usage of this sofware is subject to the terms found in the included license";
private final String website = "https://god-weapon.github.io"; private final String website = "https://god-weapon.github.io";