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 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);
|
||||
|
||||
|
||||
|
@ -28,7 +27,7 @@ public void garbageCollection() {
|
|||
long time = System.currentTimeMillis();
|
||||
clientSet.entrySet().removeIf(entry -> {
|
||||
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 enum ConnectTypes {
|
||||
SERVER, CLIENT, API
|
||||
@Deprecated
|
||||
SERVER,
|
||||
CLIENT,
|
||||
API
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,10 +112,6 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
|
|||
clientData.username = login;
|
||||
result.accessToken = aresult.accessToken;
|
||||
result.permissions = clientData.permissions;
|
||||
if (authType == ConnectTypes.SERVER && !clientData.permissions.canServer) {
|
||||
AuthProvider.authError("authType: SERVER not allowed for this account");
|
||||
return;
|
||||
}
|
||||
if (getSession) {
|
||||
if (clientData.session == 0) {
|
||||
clientData.session = random.nextLong();
|
||||
|
|
|
@ -21,6 +21,11 @@ public String getType() {
|
|||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client pClient) {
|
||||
if(!pClient.isAuth || pClient.type == AuthResponse.ConnectTypes.CLIENT)
|
||||
{
|
||||
sendError("Permissions denied");
|
||||
return;
|
||||
}
|
||||
CheckServerRequestEvent result = new CheckServerRequestEvent();
|
||||
try {
|
||||
server.authHookManager.checkServerHook.hook(this, pClient);
|
||||
|
|
|
@ -20,6 +20,11 @@ public String getType() {
|
|||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
if(!client.isAuth || client.type != AuthResponse.ConnectTypes.CLIENT)
|
||||
{
|
||||
sendError("Permissions denied");
|
||||
return;
|
||||
}
|
||||
boolean success;
|
||||
try {
|
||||
server.authHookManager.joinServerHook.hook(this, client);
|
||||
|
|
|
@ -35,14 +35,13 @@ public interface AuthPasswordInterface {
|
|||
public boolean initProxy;
|
||||
|
||||
public enum ConnectTypes {
|
||||
@Deprecated
|
||||
@LauncherNetworkAPI
|
||||
SERVER,
|
||||
@LauncherNetworkAPI
|
||||
CLIENT,
|
||||
@LauncherNetworkAPI
|
||||
BOT,
|
||||
@LauncherNetworkAPI
|
||||
PROXY
|
||||
API
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public ServerWrapper(Type type, Path configPath) {
|
|||
public boolean auth() {
|
||||
try {
|
||||
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;
|
||||
ProfilesRequestEvent result = new ProfilesRequest().request();
|
||||
for (ClientProfile p : result.profiles) {
|
||||
|
|
Loading…
Reference in a new issue