diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java index f835a5d3..d0a9b9dc 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java @@ -10,6 +10,7 @@ public class SessionManager implements NeedGarbageCollection { @LauncherAPI public static final long SESSION_TIMEOUT = 10 * 60 * 1000; // 10 минут + public static final boolean NON_GARBAGE_SERVER = true; private Set clientSet = new HashSet<>(128); @LauncherAPI @@ -22,7 +23,7 @@ public boolean addClient(Client client) { @LauncherAPI public void garbageCollection() { long time = System.currentTimeMillis(); - clientSet.removeIf(c -> c.timestamp + SESSION_TIMEOUT < time); + clientSet.removeIf(c -> (c.timestamp + SESSION_TIMEOUT < time) && ((c.type == Client.Type.USER) || ((c.type == Client.Type.SERVER) && !NON_GARBAGE_SERVER ) )); } @LauncherAPI @@ -43,10 +44,13 @@ public Client getOrNewClient(long session) { @LauncherAPI public void updateClient(long session) { - for (Client c : clientSet) + for (Client c : clientSet) { if (c.session == session) { c.up(); return; } + } + Client newClient = new Client(session); + clientSet.add(newClient); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java index c6150374..f991d833 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.util.Collection; +import ru.gravit.launchserver.socket.Client; import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.HInput; @@ -20,7 +21,13 @@ public ProfilesResponse(LaunchServer server, long session, HInput input, HOutput @Override public void reply() throws IOException { // Resolve launcher binary + Client client = server.sessionManager.getClient(session); input.readBoolean(); + if(client.type == Client.Type.USER) { + LogHelper.warning("User session: %d ip %s try get profiles",session,ip); + requestError("Assess denied"); + return; + } writeNoError(output); Collection> profiles = server.getProfiles(); output.writeLength(profiles.size(), 0);