[FIX] ConnectionTypes.SERVER deprecated

This commit is contained in:
Gravit 2020-02-17 08:51:59 +07:00
parent cfc140d47c
commit a3800958db
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
6 changed files with 18 additions and 11 deletions

View file

@ -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);
});
}

View file

@ -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();

View file

@ -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);

View file

@ -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);

View file

@ -35,14 +35,13 @@ public interface AuthPasswordInterface {
public boolean initProxy;
public enum ConnectTypes {
@Deprecated
@LauncherNetworkAPI
SERVER,
@LauncherNetworkAPI
CLIENT,
@LauncherNetworkAPI
BOT,
@LauncherNetworkAPI
PROXY
API
}

View file

@ -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) {