mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] ConnectionTypes.SERVER deprecated
This commit is contained in:
parent
cfc140d47c
commit
a3800958db
6 changed files with 18 additions and 11 deletions
|
@ -14,7 +14,6 @@
|
||||||
public class SessionManager implements NeedGarbageCollection {
|
public class SessionManager implements NeedGarbageCollection {
|
||||||
|
|
||||||
public static final long SESSION_TIMEOUT = 3 * 60 * 60 * 1000; // 3 часа
|
public static final long SESSION_TIMEOUT = 3 * 60 * 60 * 1000; // 3 часа
|
||||||
public static final boolean GARBAGE_SERVER = Boolean.parseBoolean(System.getProperty("launcher.garbageSessionsServer", "false"));
|
|
||||||
private final Map<Long, Client> clientSet = new HashMap<>(128);
|
private final Map<Long, Client> clientSet = new HashMap<>(128);
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ public void garbageCollection() {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
clientSet.entrySet().removeIf(entry -> {
|
clientSet.entrySet().removeIf(entry -> {
|
||||||
Client c = entry.getValue();
|
Client c = entry.getValue();
|
||||||
return (c.timestamp + SESSION_TIMEOUT < time) && ((c.type == AuthResponse.ConnectTypes.CLIENT) || ((c.type == AuthResponse.ConnectTypes.SERVER) && GARBAGE_SERVER));
|
return (c.timestamp + SESSION_TIMEOUT < time);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,10 @@ public class AuthResponse extends SimpleResponse {
|
||||||
public HWID hwid;
|
public HWID hwid;
|
||||||
|
|
||||||
public enum ConnectTypes {
|
public enum ConnectTypes {
|
||||||
SERVER, CLIENT, API
|
@Deprecated
|
||||||
|
SERVER,
|
||||||
|
CLIENT,
|
||||||
|
API
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,10 +112,6 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
|
||||||
clientData.username = login;
|
clientData.username = login;
|
||||||
result.accessToken = aresult.accessToken;
|
result.accessToken = aresult.accessToken;
|
||||||
result.permissions = clientData.permissions;
|
result.permissions = clientData.permissions;
|
||||||
if (authType == ConnectTypes.SERVER && !clientData.permissions.canServer) {
|
|
||||||
AuthProvider.authError("authType: SERVER not allowed for this account");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getSession) {
|
if (getSession) {
|
||||||
if (clientData.session == 0) {
|
if (clientData.session == 0) {
|
||||||
clientData.session = random.nextLong();
|
clientData.session = random.nextLong();
|
||||||
|
|
|
@ -21,6 +21,11 @@ public String getType() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client pClient) {
|
public void execute(ChannelHandlerContext ctx, Client pClient) {
|
||||||
|
if(!pClient.isAuth || pClient.type == AuthResponse.ConnectTypes.CLIENT)
|
||||||
|
{
|
||||||
|
sendError("Permissions denied");
|
||||||
|
return;
|
||||||
|
}
|
||||||
CheckServerRequestEvent result = new CheckServerRequestEvent();
|
CheckServerRequestEvent result = new CheckServerRequestEvent();
|
||||||
try {
|
try {
|
||||||
server.authHookManager.checkServerHook.hook(this, pClient);
|
server.authHookManager.checkServerHook.hook(this, pClient);
|
||||||
|
|
|
@ -20,6 +20,11 @@ public String getType() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
|
if(!client.isAuth || client.type != AuthResponse.ConnectTypes.CLIENT)
|
||||||
|
{
|
||||||
|
sendError("Permissions denied");
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean success;
|
boolean success;
|
||||||
try {
|
try {
|
||||||
server.authHookManager.joinServerHook.hook(this, client);
|
server.authHookManager.joinServerHook.hook(this, client);
|
||||||
|
|
|
@ -35,14 +35,13 @@ public interface AuthPasswordInterface {
|
||||||
public boolean initProxy;
|
public boolean initProxy;
|
||||||
|
|
||||||
public enum ConnectTypes {
|
public enum ConnectTypes {
|
||||||
|
@Deprecated
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
SERVER,
|
SERVER,
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
CLIENT,
|
CLIENT,
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
BOT,
|
API
|
||||||
@LauncherNetworkAPI
|
|
||||||
PROXY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public ServerWrapper(Type type, Path configPath) {
|
||||||
public boolean auth() {
|
public boolean auth() {
|
||||||
try {
|
try {
|
||||||
Launcher.getConfig();
|
Launcher.getConfig();
|
||||||
AuthRequest request = new AuthRequest(config.login, config.password, config.auth_id, AuthRequest.ConnectTypes.SERVER);
|
AuthRequest request = new AuthRequest(config.login, config.password, config.auth_id, AuthRequest.ConnectTypes.API);
|
||||||
permissions = request.request().permissions;
|
permissions = request.request().permissions;
|
||||||
ProfilesRequestEvent result = new ProfilesRequest().request();
|
ProfilesRequestEvent result = new ProfilesRequest().request();
|
||||||
for (ClientProfile p : result.profiles) {
|
for (ClientProfile p : result.profiles) {
|
||||||
|
|
Loading…
Reference in a new issue