[ANY] Remove deprecated

This commit is contained in:
Gravita 2022-04-11 19:28:47 +07:00
parent d128c643ae
commit 8a51c98df8
33 changed files with 22 additions and 624 deletions

View file

@ -100,8 +100,6 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
public final AuthManager authManager; public final AuthManager authManager;
public final ReconfigurableManager reconfigurableManager; public final ReconfigurableManager reconfigurableManager;
public final ConfigManager configManager; public final ConfigManager configManager;
@Deprecated
public final PingServerManager pingServerManager;
public final FeaturesManager featuresManager; public final FeaturesManager featuresManager;
public final KeyAgreementManager keyAgreementManager; public final KeyAgreementManager keyAgreementManager;
public final UpdatesManager updatesManager; public final UpdatesManager updatesManager;
@ -153,7 +151,6 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
reconfigurableManager = new ReconfigurableManager(); reconfigurableManager = new ReconfigurableManager();
authHookManager = new AuthHookManager(); authHookManager = new AuthHookManager();
configManager = new ConfigManager(); configManager = new ConfigManager();
pingServerManager = new PingServerManager(this);
featuresManager = new FeaturesManager(this); featuresManager = new FeaturesManager(this);
authManager = new AuthManager(this); authManager = new AuthManager(this);
updatesManager = new UpdatesManager(this); updatesManager = new UpdatesManager(this);
@ -377,8 +374,6 @@ public void syncProfilesDir() throws IOException {
// Sort and set new profiles // Sort and set new profiles
newProfies.sort(Comparator.comparing(a -> a)); newProfies.sort(Comparator.comparing(a -> a));
profilesList = Set.copyOf(newProfies); profilesList = Set.copyOf(newProfies);
if (pingServerManager != null)
pingServerManager.syncServers();
} }
public void syncUpdatesDir(Collection<String> dirs) throws IOException { public void syncUpdatesDir(Collection<String> dirs) throws IOException {

View file

@ -57,7 +57,6 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand
service.registerCommand("clients", new ClientsCommand(server)); service.registerCommand("clients", new ClientsCommand(server));
service.registerCommand("signJar", new SignJarCommand(server)); service.registerCommand("signJar", new SignJarCommand(server));
service.registerCommand("signDir", new SignDirCommand(server)); service.registerCommand("signDir", new SignDirCommand(server));
service.registerCommand("pingServers", new PingServersCommand(server));
service.registerCommand("securitycheck", new SecurityCheckCommand(server)); service.registerCommand("securitycheck", new SecurityCheckCommand(server));
service.registerCommand("token", new TokenCommand(server)); service.registerCommand("token", new TokenCommand(server));
Category serviceCategory = new Category(service, "service", "Managing LaunchServer Components"); Category serviceCategory = new Category(service, "service", "Managing LaunchServer Components");

View file

@ -43,8 +43,8 @@ public void invoke(String... args) {
logger.info("Channel {} | connectUUID {} | checkSign {}", ip, frameHandler.getConnectUUID(), client.checkSign ? "true" : "false"); logger.info("Channel {} | connectUUID {} | checkSign {}", ip, frameHandler.getConnectUUID(), client.checkSign ? "true" : "false");
else { else {
logger.info("Client name {} | ip {} | connectUUID {}", client.username == null ? "null" : client.username, ip, frameHandler.getConnectUUID()); logger.info("Client name {} | ip {} | connectUUID {}", client.username == null ? "null" : client.username, ip, frameHandler.getConnectUUID());
logger.info("userUUID: {} | session {}", client.uuid == null ? "null" : client.uuid.toString(), client.session == null ? "null" : client.session); logger.info("userUUID: {}", client.uuid == null ? "null" : client.uuid.toString());
logger.info("OAuth {} | session {}", client.useOAuth, client.sessionObject == null ? "null" : client.sessionObject); logger.info("OAuth session {}", client.sessionObject == null ? "null" : client.sessionObject);
logger.info("Data: checkSign {} | auth_id {}", client.checkSign ? "true" : "false", logger.info("Data: checkSign {} | auth_id {}", client.checkSign ? "true" : "false",
client.auth_id); client.auth_id);
} }

View file

@ -1,38 +0,0 @@
package pro.gravit.launchserver.command.service;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import pro.gravit.launcher.request.management.PingServerReportRequest;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
@Deprecated
public class PingServersCommand extends Command {
private transient final Logger logger = LogManager.getLogger();
public PingServersCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "[]";
}
@Override
public String getUsageDescription() {
return "show modern pings status";
}
@Override
public void invoke(String... args) {
server.pingServerManager.map.forEach((name, data) -> {
logger.info("[{}] online {} / {}", name, data.lastReport == null ? -1 : data.lastReport.playersOnline, data.lastReport == null ? -1 : data.lastReport.maxPlayers);
if (data.lastReport != null && data.lastReport.users != null) {
for (PingServerReportRequest.PingServerReport.UsernameInfo user : data.lastReport.users) {
logger.info("User {}", user.username == null ? "null" : user.username);
}
}
});
}
}

View file

@ -179,7 +179,6 @@ public void internalAuth(Client client, AuthResponse.ConnectTypes authType, Auth
client.username = username; client.username = username;
client.type = authType; client.type = authType;
client.uuid = uuid; client.uuid = uuid;
client.useOAuth = true;
} }
public CheckServerReport checkServer(Client client, String username, String serverID) throws IOException { public CheckServerReport checkServer(Client client, String username, String serverID) throws IOException {
@ -197,19 +196,17 @@ public boolean joinServer(Client client, String username, String accessToken, St
public PlayerProfile getPlayerProfile(Client client) { public PlayerProfile getPlayerProfile(Client client) {
if (client.auth == null) return null; if (client.auth == null) return null;
PlayerProfile playerProfile; PlayerProfile playerProfile;
if (client.useOAuth) {
User user = client.getUser(); User user = client.getUser();
if (user == null) { if (user == null) {
return null; return null;
} }
playerProfile = getPlayerProfile(client.auth, user); playerProfile = getPlayerProfile(client.auth, user);
if (playerProfile != null) return playerProfile; if (playerProfile != null) return playerProfile;
}
if (client.auth.textureProvider != null) { if (client.auth.textureProvider != null) {
return getPlayerProfile(client.uuid, client.username, client.profile == null ? null : client.profile.getTitle(), client.auth.textureProvider, new HashMap<>()); return getPlayerProfile(client.uuid, client.username, client.profile == null ? null : client.profile.getTitle(), client.auth.textureProvider, new HashMap<>());
} }
// Return combined profile // Return combined profile
return new PlayerProfile(client.uuid, client.username, null, null, new HashMap<>()); return new PlayerProfile(client.uuid, client.username, new HashMap<>(), new HashMap<>());
} }
public PlayerProfile getPlayerProfile(AuthProviderPair pair, String username) { public PlayerProfile getPlayerProfile(AuthProviderPair pair, String username) {
@ -231,7 +228,7 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, String username, Cl
if (pair.textureProvider != null) { if (pair.textureProvider != null) {
return getPlayerProfile(uuid, username, profile == null ? null : profile.getTitle(), pair.textureProvider, new HashMap<>()); return getPlayerProfile(uuid, username, profile == null ? null : profile.getTitle(), pair.textureProvider, new HashMap<>());
} }
return new PlayerProfile(uuid, username, null, null, new HashMap<>()); return new PlayerProfile(uuid, username, new HashMap<>(), new HashMap<>());
} }
public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid) { public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid) {
@ -253,7 +250,7 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid, ClientPr
if (pair.textureProvider != null) { if (pair.textureProvider != null) {
return getPlayerProfile(uuid, username, profile == null ? null : profile.getTitle(), pair.textureProvider, new HashMap<>()); return getPlayerProfile(uuid, username, profile == null ? null : profile.getTitle(), pair.textureProvider, new HashMap<>());
} }
return new PlayerProfile(uuid, username, null, null, new HashMap<>()); return new PlayerProfile(uuid, username, new HashMap<>(), new HashMap<>());
} }
public PlayerProfile getPlayerProfile(AuthProviderPair pair, User user) { public PlayerProfile getPlayerProfile(AuthProviderPair pair, User user) {

View file

@ -1,61 +0,0 @@
package pro.gravit.launchserver.manangers;
import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.launcher.request.management.PingServerReportRequest;
import pro.gravit.launchserver.LaunchServer;
import java.util.HashMap;
import java.util.Map;
@Deprecated
public class PingServerManager {
public static final long REPORT_EXPIRED_TIME = 20 * 1000;
public final Map<String, ServerInfoEntry> map = new HashMap<>();
private final LaunchServer server;
public PingServerManager(LaunchServer server) {
this.server = server;
}
public void syncServers() {
server.getProfiles().forEach((p) -> {
for (ClientProfile.ServerProfile sp : p.getServers()) {
ServerInfoEntry entry = map.get(sp.name);
if (entry == null) {
map.put(sp.name, new ServerInfoEntry(p));
}
}
});
}
public boolean updateServer(String name, PingServerReportRequest.PingServerReport report) {
ServerInfoEntry entry = map.get(name);
if (entry == null)
return false;
else {
entry.lastReportTime = System.currentTimeMillis();
entry.lastReport = report;
return true;
}
}
public static class ServerInfoEntry {
public final ClientProfile profile;
public PingServerReportRequest.PingServerReport lastReport;
public long lastReportTime;
public ServerInfoEntry(ClientProfile profile, PingServerReportRequest.PingServerReport lastReport) {
this.lastReport = lastReport;
this.profile = profile;
this.lastReportTime = System.currentTimeMillis();
}
public ServerInfoEntry(ClientProfile profile) {
this.profile = profile;
}
public boolean isExpired() {
return System.currentTimeMillis() - lastReportTime > REPORT_EXPIRED_TIME;
}
}
}

View file

@ -13,10 +13,6 @@
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class Client { public class Client {
@Deprecated
public UUID session;
@Deprecated
public boolean useOAuth; // Always true
public String auth_id; public String auth_id;
public long timestamp; public long timestamp;
public AuthResponse.ConnectTypes type; public AuthResponse.ConnectTypes type;
@ -38,16 +34,7 @@ public class Client {
public Map<String, String> serializableProperties; public Map<String, String> serializableProperties;
@Deprecated public Client() {
public transient AtomicInteger refCount;
public Client(UUID session) {
this(session, 1);
}
public Client(UUID session, int initialRefCount) {
refCount = new AtomicInteger(initialRefCount);
this.session = session;
timestamp = System.currentTimeMillis(); timestamp = System.currentTimeMillis();
type = null; type = null;
isAuth = false; isAuth = false;

View file

@ -10,7 +10,6 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import pro.gravit.launcher.Launcher; import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.events.ExceptionEvent;
import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.events.RequestEvent;
import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.events.request.ErrorRequestEvent;
import pro.gravit.launcher.events.request.ExitRequestEvent; import pro.gravit.launcher.events.request.ExitRequestEvent;
@ -21,8 +20,6 @@
import pro.gravit.launchserver.socket.response.WebSocketServerResponse; import pro.gravit.launchserver.socket.response.WebSocketServerResponse;
import pro.gravit.launchserver.socket.response.auth.*; import pro.gravit.launchserver.socket.response.auth.*;
import pro.gravit.launchserver.socket.response.management.FeaturesResponse; import pro.gravit.launchserver.socket.response.management.FeaturesResponse;
import pro.gravit.launchserver.socket.response.management.PingServerReportResponse;
import pro.gravit.launchserver.socket.response.management.PingServerResponse;
import pro.gravit.launchserver.socket.response.management.ServerStatusResponse; import pro.gravit.launchserver.socket.response.management.ServerStatusResponse;
import pro.gravit.launchserver.socket.response.profile.BatchProfileByUsername; import pro.gravit.launchserver.socket.response.profile.BatchProfileByUsername;
import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse;
@ -86,8 +83,6 @@ public static void registerResponses() {
providers.register("securityReport", SecurityReportResponse.class); providers.register("securityReport", SecurityReportResponse.class);
providers.register("hardwareReport", HardwareReportResponse.class); providers.register("hardwareReport", HardwareReportResponse.class);
providers.register("serverStatus", ServerStatusResponse.class); providers.register("serverStatus", ServerStatusResponse.class);
providers.register("pingServerReport", PingServerReportResponse.class);
providers.register("pingServer", PingServerResponse.class);
providers.register("currentUser", CurrentUserResponse.class); providers.register("currentUser", CurrentUserResponse.class);
providers.register("features", FeaturesResponse.class); providers.register("features", FeaturesResponse.class);
providers.register("refreshToken", RefreshTokenResponse.class); providers.register("refreshToken", RefreshTokenResponse.class);

View file

@ -39,9 +39,7 @@ public Client getClient() {
} }
public void setClient(Client client) { public void setClient(Client client) {
if (this.client != null) this.client.refCount.decrementAndGet();
this.client = client; this.client = client;
if (client != null) client.refCount.incrementAndGet();
} }
public final UUID getConnectUUID() { public final UUID getConnectUUID() {
@ -51,7 +49,7 @@ public final UUID getConnectUUID() {
@Override @Override
public void channelActive(ChannelHandlerContext ctx) { public void channelActive(ChannelHandlerContext ctx) {
logger.trace("New client {}", IOHelper.getIP(ctx.channel().remoteAddress())); logger.trace("New client {}", IOHelper.getIP(ctx.channel().remoteAddress()));
client = new Client(null); client = new Client();
Channel ch = ctx.channel(); Channel ch = ctx.channel();
service.registerClient(ch); service.registerClient(ch);
future = ctx.executor().scheduleAtFixedRate(() -> ch.writeAndFlush(new PingWebSocketFrame(), ch.voidPromise()), 30L, 30L, TimeUnit.SECONDS); future = ctx.executor().scheduleAtFixedRate(() -> ch.writeAndFlush(new PingWebSocketFrame(), ch.voidPromise()), 30L, 30L, TimeUnit.SECONDS);

View file

@ -33,7 +33,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
Map<String, String> properties; Map<String, String> properties;
User user = client.getUser(); User user = client.getUser();
if (user instanceof UserSupportAdditionalData userSupport) { if (user instanceof UserSupportAdditionalData userSupport) {
if (user.getPermissions().isPermission(ClientPermissions.PermissionConsts.ADMIN)) { if (client.permissions.hasPerm("launchserver.request.addionaldata.privileged")) {
properties = userSupport.getPropertiesMap(); properties = userSupport.getPropertiesMap();
} else { } else {
properties = userSupport.getPropertiesMapUnprivilegedSelf(); properties = userSupport.getPropertiesMapUnprivilegedSelf();
@ -55,7 +55,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
return; return;
} }
Map<String, String> properties; Map<String, String> properties;
if (client.permissions.isPermission(ClientPermissions.PermissionConsts.ADMIN)) { if (client.permissions.hasPerm("launchserver.request.addionaldata.privileged")) {
properties = userSupport.getPropertiesMap(); properties = userSupport.getPropertiesMap();
} else { } else {
properties = userSupport.getPropertiesMapUnprivileged(); properties = userSupport.getPropertiesMapUnprivileged();

View file

@ -18,7 +18,6 @@ public class AuthResponse extends SimpleResponse {
private transient final Logger logger = LogManager.getLogger(); private transient final Logger logger = LogManager.getLogger();
public String login; public String login;
public String client; public String client;
public boolean getSession;
public AuthRequest.AuthPasswordInterface password; public AuthRequest.AuthPasswordInterface password;
@ -49,12 +48,6 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
server.authHookManager.postHook.hook(context, clientData); server.authHookManager.postHook.hook(context, clientData);
if (context.report.isUsingOAuth()) { if (context.report.isUsingOAuth()) {
result.oauth = new AuthRequestEvent.OAuthRequestEvent(context.report.oauthAccessToken(), context.report.oauthRefreshToken(), context.report.oauthExpire()); result.oauth = new AuthRequestEvent.OAuthRequestEvent(context.report.oauthAccessToken(), context.report.oauthRefreshToken(), context.report.oauthExpire());
} else if (getSession) {
if (clientData.session == null) {
clientData.session = UUID.randomUUID();
//server.sessionManager.addClient(clientData);
}
result.session = clientData.session;
} }
if (context.report.minecraftAccessToken() != null) { if (context.report.minecraftAccessToken() != null) {
result.accessToken = context.report.minecraftAccessToken(); result.accessToken = context.report.minecraftAccessToken();

View file

@ -18,12 +18,9 @@ public class ExitResponse extends SimpleResponse {
public static void exit(LaunchServer server, WebSocketFrameHandler wsHandler, Channel channel, ExitRequestEvent.ExitReason reason) { public static void exit(LaunchServer server, WebSocketFrameHandler wsHandler, Channel channel, ExitRequestEvent.ExitReason reason) {
Client chClient = wsHandler.getClient(); Client chClient = wsHandler.getClient();
Client newCusClient = new Client(null); Client newCusClient = new Client();
newCusClient.checkSign = chClient.checkSign; newCusClient.checkSign = chClient.checkSign;
wsHandler.setClient(newCusClient); wsHandler.setClient(newCusClient);
if (chClient.session != null) {
throw new UnsupportedOperationException("Legacy session system removed");
}
ExitRequestEvent event = new ExitRequestEvent(reason); ExitRequestEvent event = new ExitRequestEvent(reason);
event.requestUUID = RequestEvent.eventUUID; event.requestUUID = RequestEvent.eventUUID;
wsHandler.service.sendObject(channel, event); wsHandler.service.sendObject(channel, event);
@ -41,13 +38,13 @@ public void execute(ChannelHandlerContext ctx, Client client) {
return; return;
} }
if (username == null) { if (username == null) {
if (client.useOAuth) { {
WebSocketFrameHandler handler = ctx.pipeline().get(WebSocketFrameHandler.class); WebSocketFrameHandler handler = ctx.pipeline().get(WebSocketFrameHandler.class);
if (handler == null) { if (handler == null) {
sendError("Exit internal error"); sendError("Exit internal error");
return; return;
} }
Client newClient = new Client(null, 0); Client newClient = new Client();
newClient.checkSign = client.checkSign; newClient.checkSign = client.checkSign;
handler.setClient(newClient); handler.setClient(newClient);
AuthSupportExit supportExit = client.auth.core.isSupport(AuthSupportExit.class); AuthSupportExit supportExit = client.auth.core.isSupport(AuthSupportExit.class);
@ -62,33 +59,6 @@ public void execute(ChannelHandlerContext ctx, Client client) {
} }
} }
sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.CLIENT)); sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.CLIENT));
} else {
if (client.session == null && exitAll) {
sendError("Session invalid");
return;
}
WebSocketFrameHandler handler = ctx.pipeline().get(WebSocketFrameHandler.class);
if (handler == null) {
sendError("Exit internal error");
return;
}
Client newClient = new Client(null);
newClient.checkSign = client.checkSign;
handler.setClient(newClient);
if (client.session != null) {
throw new UnsupportedOperationException("Legacy session system removed");
}
if (exitAll) {
service.forEachActiveChannels(((channel, webSocketFrameHandler) -> {
Client client1 = webSocketFrameHandler.getClient();
if (client.isAuth && client.username != null) {
if (!client1.isAuth || !client.username.equals(client1.username)) return;
} else {
if (client1.session != client.session) return;
}
exit(server, webSocketFrameHandler, channel, ExitRequestEvent.ExitReason.SERVER);
}));
}
} }
sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.CLIENT)); sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.CLIENT));
} else { } else {

View file

@ -2,9 +2,7 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.LauncherNetworkAPI;
import pro.gravit.launcher.events.request.RestoreSessionRequestEvent;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler;
import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.SimpleResponse;
import java.util.UUID; import java.util.UUID;

View file

@ -1,28 +0,0 @@
package pro.gravit.launchserver.socket.response.management;
import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.PingServerReportRequestEvent;
import pro.gravit.launcher.request.management.PingServerReportRequest;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse;
@Deprecated
public class PingServerReportResponse extends SimpleResponse {
public PingServerReportRequest.PingServerReport data;
public String name;
@Override
public String getType() {
return "pingServerReport";
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) {
if (!client.isAuth || client.permissions == null || !client.permissions.hasPerm("launchserver\\.management\\.pingserver")) {
sendError("Access denied");
return;
}
server.pingServerManager.updateServer(name, data);
sendResult(new PingServerReportRequestEvent());
}
}

View file

@ -1,43 +0,0 @@
package pro.gravit.launchserver.socket.response.management;
import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.PingServerRequestEvent;
import pro.gravit.launcher.request.management.PingServerReportRequest;
import pro.gravit.launchserver.auth.protect.interfaces.ProfilesProtectHandler;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Deprecated
public class PingServerResponse extends SimpleResponse {
public List<String> serverNames; //May be null
@Override
public String getType() {
return "pingServer";
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) {
Map<String, PingServerReportRequest.PingServerReport> map = new HashMap<>();
if (serverNames == null) {
server.pingServerManager.map.forEach((name, entity) -> {
if (server.config.protectHandler instanceof ProfilesProtectHandler) {
if (!((ProfilesProtectHandler) server.config.protectHandler).canGetProfile(entity.profile, client)) {
return;
}
}
if (!entity.isExpired()) {
map.put(name, entity.lastReport);
}
});
} else {
sendError("Not implemented");
return;
}
sendResult(new PingServerRequestEvent(map));
}
}

View file

@ -328,16 +328,7 @@ private void addModernClientArgs(Collection<String> args) {
if (version.compareTo(ClientProfile.Version.MC1710) >= 0) { if (version.compareTo(ClientProfile.Version.MC1710) >= 0) {
// Add user properties // Add user properties
Collections.addAll(args, "--userType", "mojang"); Collections.addAll(args, "--userType", "mojang");
ClientUserProperties properties = new ClientUserProperties(); Collections.addAll(args, "--userProperties", "{}");
if (playerProfile.skin != null) {
properties.skinURL = new String[]{playerProfile.skin.url};
properties.skinDigest = new String[]{SecurityHelper.toHex(playerProfile.skin.digest)};
}
if (playerProfile.cloak != null) {
properties.cloakURL = new String[]{playerProfile.cloak.url};
properties.cloakDigest = new String[]{SecurityHelper.toHex(playerProfile.cloak.digest)};
}
Collections.addAll(args, "--userProperties", Launcher.gsonManager.gson.toJson(properties));
// Add asset index // Add asset index
Collections.addAll(args, "--assetIndex", profile.getAssetIndex()); Collections.addAll(args, "--assetIndex", profile.getAssetIndex());
@ -371,16 +362,5 @@ private void addModernClientArgs(Collection<String> args) {
Collections.addAll(args, "--height", Integer.toString(height)); Collections.addAll(args, "--height", Integer.toString(height));
} }
} }
public static class ClientUserProperties {
@LauncherNetworkAPI
public String[] skinURL;
@LauncherNetworkAPI
public String[] skinDigest;
@LauncherNetworkAPI
public String[] cloakURL;
@LauncherNetworkAPI
public String[] cloakDigest;
}
} }
} }

View file

@ -8,46 +8,27 @@
public class ClientPermissions { public class ClientPermissions {
public static final ClientPermissions DEFAULT = new ClientPermissions(); public static final ClientPermissions DEFAULT = new ClientPermissions();
@LauncherNetworkAPI @LauncherNetworkAPI
@Deprecated
public long permissions;
@LauncherNetworkAPI
@Deprecated
public long flags;
@LauncherNetworkAPI
private List<String> roles; private List<String> roles;
@LauncherNetworkAPI @LauncherNetworkAPI
private List<String> perms; private List<String> perms;
private transient List<PermissionPattern> available; private transient List<PermissionPattern> available;
public ClientPermissions(HInput input) throws IOException {
this(input.readLong());
}
public ClientPermissions() { public ClientPermissions() {
} }
public ClientPermissions(long permissions) { public ClientPermissions(List<String> roles, List<String> permissions) {
this.permissions = permissions; this.roles = new ArrayList<>(roles);
} this.perms = new ArrayList<>(permissions);
public ClientPermissions(long permissions, long flags) {
this.permissions = permissions;
this.flags = flags;
} }
public static ClientPermissions getSuperuserAccount() { public static ClientPermissions getSuperuserAccount() {
ClientPermissions perm = new ClientPermissions(); ClientPermissions perm = new ClientPermissions();
perm.setPermission(PermissionConsts.ADMIN, true);
perm.addPerm("*"); perm.addPerm("*");
return perm; return perm;
} }
public long toLong() {
return permissions;
}
public boolean hasRole(String role) { public boolean hasRole(String role) {
return roles != null && roles.contains(role); return roles != null && roles.contains(role);
} }
@ -64,12 +45,6 @@ public synchronized void compile() {
for (String a : perms) { for (String a : perms) {
available.add(new PermissionPattern(a)); available.add(new PermissionPattern(a));
} }
if (permissions != 0) {
if (isPermission(PermissionConsts.ADMIN)) {
roles.add("ADMIN");
available.add(new PermissionPattern("*"));
}
}
} }
public boolean hasPerm(String action) { public boolean hasPerm(String action) {
@ -121,52 +96,6 @@ public List<String> getPerms() {
return perms; return perms;
} }
//Read methods
@Deprecated
public final boolean isPermission(PermissionConsts con) {
return (permissions & con.mask) != 0;
}
@Deprecated
public final boolean isPermission(long mask) {
return (permissions & mask) != 0;
}
@Deprecated
public final boolean isFlag(FlagConsts con) {
return (flags & con.mask) != 0;
}
@Deprecated
public final boolean isFlag(long mask) {
return (flags & mask) != 0;
}
//Write methods
@Deprecated
public final void setPermission(PermissionConsts con, boolean value) {
if (value) this.permissions |= con.mask;
else this.permissions &= ~con.mask;
}
@Deprecated
public final void setPermission(long mask, boolean value) {
if (value) this.permissions |= mask;
else this.permissions &= ~mask;
}
@Deprecated
public final void setFlag(FlagConsts con, boolean value) {
if (value) this.flags |= con.mask;
else this.flags &= ~con.mask;
}
@Deprecated
public final void setFlag(long mask, boolean value) {
if (value) this.flags |= mask;
else this.flags &= ~mask;
}
@Override @Override
public String toString() { public String toString() {
return "ClientPermissions{" + return "ClientPermissions{" +
@ -175,30 +104,6 @@ public String toString() {
'}'; '}';
} }
@Deprecated
public enum PermissionConsts {
ADMIN(0x01),
MANAGEMENT(0x02);
public final long mask;
PermissionConsts(long mask) {
this.mask = mask;
}
}
@Deprecated
public enum FlagConsts {
SYSTEM(0x01),
BANNED(0x02),
UNTRUSTED(0x04),
HIDDEN(0x08);
public final long mask;
FlagConsts(long mask) {
this.mask = mask;
}
}
public static class PermissionPattern { public static class PermissionPattern {
private final String[] parts; private final String[] parts;
private final int priority; private final int priority;

View file

@ -1,21 +0,0 @@
package pro.gravit.launcher.events;
import pro.gravit.launcher.LauncherNetworkAPI;
@Deprecated
public class ExceptionEvent extends RequestEvent {
@LauncherNetworkAPI
public final String message;
@LauncherNetworkAPI
public final String clazz;
public ExceptionEvent(Exception e) {
this.message = e.getMessage();
this.clazz = e.getClass().getName();
}
@Override
public String getType() {
return "exception";
}
}

View file

@ -1,7 +0,0 @@
package pro.gravit.launcher.events;
//Пустое событие
//Все обработчики обязаны его игнорировать
@Deprecated
public final class PingEvent {
}

View file

@ -1,20 +0,0 @@
package pro.gravit.launcher.events;
import pro.gravit.launcher.LauncherNetworkAPI;
import pro.gravit.launcher.request.WebSocketEvent;
//Используется, что бы послать короткое сообщение, которое вмещается в int
@Deprecated
public class SignalEvent implements WebSocketEvent {
@LauncherNetworkAPI
public final int signal;
public SignalEvent(int signal) {
this.signal = signal;
}
@Override
public String getType() {
return "signal";
}
}

View file

@ -1,19 +0,0 @@
package pro.gravit.launcher.events.request;
import pro.gravit.launcher.LauncherNetworkAPI;
import pro.gravit.launcher.request.WebSocketEvent;
@Deprecated
public class LogEvent implements WebSocketEvent {
@LauncherNetworkAPI
public final String string;
public LogEvent(String string) {
this.string = string;
}
@Override
public String getType() {
return "log";
}
}

View file

@ -1,11 +0,0 @@
package pro.gravit.launcher.events.request;
import pro.gravit.launcher.events.RequestEvent;
@Deprecated
public class PingServerReportRequestEvent extends RequestEvent {
@Override
public String getType() {
return "pingServerReport";
}
}

View file

@ -1,23 +0,0 @@
package pro.gravit.launcher.events.request;
import pro.gravit.launcher.events.RequestEvent;
import pro.gravit.launcher.request.management.PingServerReportRequest;
import java.util.Map;
@Deprecated
public class PingServerRequestEvent extends RequestEvent {
public Map<String, PingServerReportRequest.PingServerReport> serverMap;
public PingServerRequestEvent() {
}
public PingServerRequestEvent(Map<String, PingServerReportRequest.PingServerReport> serverMap) {
this.serverMap = serverMap;
}
@Override
public String getType() {
return "pingServer";
}
}

View file

@ -1,11 +0,0 @@
package pro.gravit.launcher.events.request;
import pro.gravit.launcher.events.RequestEvent;
@Deprecated
public class RegisterRequestEvent extends RequestEvent {
@Override
public String getType() {
return "register";
}
}

View file

@ -1,20 +0,0 @@
package pro.gravit.launcher.events.request;
import pro.gravit.launcher.events.RequestEvent;
@Deprecated
public class RestoreSessionRequestEvent extends RequestEvent {
public CurrentUserRequestEvent.UserInfo userInfo;
public RestoreSessionRequestEvent() {
}
public RestoreSessionRequestEvent(CurrentUserRequestEvent.UserInfo userInfo) {
this.userInfo = userInfo;
}
@Override
public String getType() {
return "restoreSession";
}
}

View file

@ -1,13 +1,11 @@
package pro.gravit.launcher.request; package pro.gravit.launcher.request;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.LauncherNetworkAPI;
import pro.gravit.launcher.events.request.AuthRequestEvent; import pro.gravit.launcher.events.request.AuthRequestEvent;
import pro.gravit.launcher.events.request.RefreshTokenRequestEvent; import pro.gravit.launcher.events.request.RefreshTokenRequestEvent;
import pro.gravit.launcher.events.request.RestoreRequestEvent; import pro.gravit.launcher.events.request.RestoreRequestEvent;
import pro.gravit.launcher.request.auth.RefreshTokenRequest; import pro.gravit.launcher.request.auth.RefreshTokenRequest;
import pro.gravit.launcher.request.auth.RestoreRequest; import pro.gravit.launcher.request.auth.RestoreRequest;
import pro.gravit.launcher.request.auth.RestoreSessionRequest;
import pro.gravit.launcher.request.websockets.StdWebSocketService; import pro.gravit.launcher.request.websockets.StdWebSocketService;
import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.launcher.request.websockets.WebSocketRequest;
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;

View file

@ -1,29 +0,0 @@
package pro.gravit.launcher.request.auth;
import pro.gravit.launcher.LauncherNetworkAPI;
import pro.gravit.launcher.events.request.RestoreSessionRequestEvent;
import pro.gravit.launcher.request.Request;
import pro.gravit.launcher.request.websockets.WebSocketRequest;
import java.util.UUID;
@Deprecated
public class RestoreSessionRequest extends Request<RestoreSessionRequestEvent> implements WebSocketRequest {
@LauncherNetworkAPI
public final UUID session;
public boolean needUserInfo;
public RestoreSessionRequest(UUID session) {
this.session = session;
}
public RestoreSessionRequest(UUID session, boolean needUserInfo) {
this.session = session;
this.needUserInfo = needUserInfo;
}
@Override
public String getType() {
return "restoreSession";
}
}

View file

@ -1,44 +0,0 @@
package pro.gravit.launcher.request.management;
import pro.gravit.launcher.events.request.PingServerReportRequestEvent;
import pro.gravit.launcher.request.Request;
import java.util.List;
public class PingServerReportRequest extends Request<PingServerReportRequestEvent> {
public final String name;
public final PingServerReport data;
public PingServerReportRequest(String name, PingServerReport data) {
this.name = name;
this.data = data;
}
@Override
public String getType() {
return "pingServerReport";
}
public static class PingServerReport {
public final String name;
public final int maxPlayers; // player slots
public final int playersOnline;
//Server addional info
public double tps; //Server tps
public List<UsernameInfo> users;
public PingServerReport(String name, int maxPlayers, int playersOnline) {
this.name = name;
this.maxPlayers = maxPlayers;
this.playersOnline = playersOnline;
}
public static class UsernameInfo {
public final String username;
public UsernameInfo(String username) {
this.username = username;
}
}
}
}

View file

@ -1,28 +0,0 @@
package pro.gravit.launcher.request.management;
import pro.gravit.launcher.events.request.PingServerRequestEvent;
import pro.gravit.launcher.request.Request;
import java.util.ArrayList;
import java.util.List;
public class PingServerRequest extends Request<PingServerRequestEvent> {
public List<String> serverNames; //May be null
public PingServerRequest() {
}
public PingServerRequest(List<String> serverNames) {
this.serverNames = serverNames;
}
public PingServerRequest(String serverName) {
this.serverNames = new ArrayList<>();
serverNames.add(serverName);
}
@Override
public String getType() {
return "pingServer";
}
}

View file

@ -3,9 +3,7 @@
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import pro.gravit.launcher.Launcher; import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.events.ExceptionEvent;
import pro.gravit.launcher.events.NotificationEvent; import pro.gravit.launcher.events.NotificationEvent;
import pro.gravit.launcher.events.SignalEvent;
import pro.gravit.launcher.events.request.*; import pro.gravit.launcher.events.request.*;
import pro.gravit.launcher.hasher.HashedEntry; import pro.gravit.launcher.hasher.HashedEntry;
import pro.gravit.launcher.hasher.HashedEntryAdapter; import pro.gravit.launcher.hasher.HashedEntryAdapter;
@ -97,21 +95,14 @@ public void registerResults() {
results.register("updateList", UpdateListRequestEvent.class); results.register("updateList", UpdateListRequestEvent.class);
results.register("error", ErrorRequestEvent.class); results.register("error", ErrorRequestEvent.class);
results.register("update", UpdateRequestEvent.class); results.register("update", UpdateRequestEvent.class);
results.register("restoreSession", RestoreSessionRequestEvent.class);
results.register("log", LogEvent.class);
results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class); results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class);
results.register("exception", ExceptionEvent.class);
results.register("register", RegisterRequestEvent.class);
results.register("notification", NotificationEvent.class); results.register("notification", NotificationEvent.class);
results.register("signal", SignalEvent.class);
results.register("exit", ExitRequestEvent.class); results.register("exit", ExitRequestEvent.class);
results.register("getSecureLevelInfo", GetSecureLevelInfoRequestEvent.class); results.register("getSecureLevelInfo", GetSecureLevelInfoRequestEvent.class);
results.register("verifySecureLevelKey", VerifySecureLevelKeyRequestEvent.class); results.register("verifySecureLevelKey", VerifySecureLevelKeyRequestEvent.class);
results.register("securityReport", SecurityReportRequestEvent.class); results.register("securityReport", SecurityReportRequestEvent.class);
results.register("hardwareReport", HardwareReportRequestEvent.class); results.register("hardwareReport", HardwareReportRequestEvent.class);
results.register("serverStatus", ServerStatusRequestEvent.class); results.register("serverStatus", ServerStatusRequestEvent.class);
results.register("pingServerReport", PingServerReportRequestEvent.class);
results.register("pingServer", PingServerRequestEvent.class);
results.register("currentUser", CurrentUserRequestEvent.class); results.register("currentUser", CurrentUserRequestEvent.class);
results.register("features", FeaturesRequestEvent.class); results.register("features", FeaturesRequestEvent.class);
results.register("refreshToken", RefreshTokenRequestEvent.class); results.register("refreshToken", RefreshTokenRequestEvent.class);

View file

@ -1,6 +1,5 @@
package pro.gravit.launcher.request.websockets; package pro.gravit.launcher.request.websockets;
import pro.gravit.launcher.events.ExceptionEvent;
import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.events.RequestEvent;
import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.events.request.ErrorRequestEvent;
import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.Request;
@ -93,9 +92,6 @@ public <T extends WebSocketEvent> void eventHandle(T webSocketEvent) {
if (future != null) { if (future != null) {
if (event instanceof ErrorRequestEvent) { if (event instanceof ErrorRequestEvent) {
future.completeExceptionally(new RequestException(((ErrorRequestEvent) event).error)); future.completeExceptionally(new RequestException(((ErrorRequestEvent) event).error));
} else if (event instanceof ExceptionEvent) {
future.completeExceptionally(new RequestException(
String.format("LaunchServer internal error: %s %s", ((ExceptionEvent) event).clazz, ((ExceptionEvent) event).message)));
} else } else
future.complete(event); future.complete(event);
futureMap.remove(event.requestUUID); futureMap.remove(event.requestUUID);

View file

@ -24,7 +24,6 @@ public final class JVMHelper {
public static final String OS_VERSION = OPERATING_SYSTEM_MXBEAN.getVersion(); public static final String OS_VERSION = OPERATING_SYSTEM_MXBEAN.getVersion();
public static final int OS_BITS = getCorrectOSArch(); public static final int OS_BITS = getCorrectOSArch();
public static final int JVM_BITS = Integer.parseInt(System.getProperty("sun.arch.data.model")); public static final int JVM_BITS = Integer.parseInt(System.getProperty("sun.arch.data.model"));
public static final SecurityManager SECURITY_MANAGER = System.getSecurityManager();
// Public static fields // Public static fields
public static final Runtime RUNTIME = Runtime.getRuntime(); public static final Runtime RUNTIME = Runtime.getRuntime();
public static final ClassLoader LOADER = ClassLoader.getSystemClassLoader(); public static final ClassLoader LOADER = ClassLoader.getSystemClassLoader();

@ -1 +1 @@
Subproject commit 4319cabbeb0abbb1c6bc76f23c16b7902b2be500 Subproject commit 56ad1f1d6a9d72e17f8283b077a9b4b53bfc5eb0