Compare commits

..

1 commit

Author SHA1 Message Date
Metall
f11bdcf2fa
Merge 05530b6664 into 263cf26258 2025-02-11 23:22:39 +00:00
54 changed files with 195 additions and 151 deletions

View file

@ -26,11 +26,14 @@
targetCompatibility = '21'
configurations {
compileOnlyA
bundleOnly
bundle
hikari
pack
launch4j
bundleOnly.extendsFrom bundle
api.extendsFrom bundle, pack
api.extendsFrom bundle, hikari, pack, launch4j
}
jar {
@ -85,13 +88,6 @@ pack project(':LauncherAPI')
bundle group: 'io.netty', name: 'netty-transport-classes-epoll', version: rootProject['verNetty']
bundle group: 'io.netty', name: 'netty-transport-native-epoll', version: rootProject['verNetty'], classifier: 'linux-x86_64'
bundle group: 'io.netty', name: 'netty-transport-native-epoll', version: rootProject['verNetty'], classifier: 'linux-aarch_64'
bundle group: 'io.netty', name: 'netty-transport-classes-io_uring', version: rootProject['verNetty']
bundle group: 'io.netty', name: 'netty-transport-native-io_uring', version: rootProject['verNetty'], classifier: 'linux-x86_64'
bundle group: 'io.netty', name: 'netty-transport-native-io_uring', version: rootProject['verNetty'], classifier: 'linux-aarch_64'
// Netty
bundle 'org.jboss.marshalling:jboss-marshalling:1.4.11.Final'
bundle 'com.google.protobuf.nano:protobuf-javanano:3.1.0'
//
bundle group: 'org.slf4j', name: 'slf4j-api', version: rootProject['verSlf4j']
bundle group: 'com.mysql', name: 'mysql-connector-j', version: rootProject['verMySQLConn']
bundle group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: rootProject['verMariaDBConn']
@ -107,26 +103,40 @@ pack project(':LauncherAPI')
annotationProcessor(group: 'org.apache.logging.log4j', name: 'log4j-core', version: rootProject['verLog4j'])
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit']
bundle 'io.micrometer:micrometer-core:1.14.4'
bundle('com.zaxxer:HikariCP:6.2.1') {
hikari 'io.micrometer:micrometer-core:1.13.1'
hikari('com.zaxxer:HikariCP:5.1.0') {
exclude group: 'javassist'
exclude group: 'io.micrometer'
exclude group: 'org.slf4j'
}
}
tasks.register('hikari', Copy) {
duplicatesStrategy = 'EXCLUDE'
into "$buildDir/libs/libraries/hikaricp"
from configurations.hikari
}
tasks.register('dumpLibs', Copy) {
duplicatesStrategy = 'EXCLUDE'
dependsOn tasks.hikari
into "$buildDir/libs/libraries"
from configurations.bundleOnly
}
tasks.register('dumpCompileOnlyLibs', Copy) {
duplicatesStrategy = 'EXCLUDE'
into "$buildDir/libs/launcher-libraries-compile"
from configurations.compileOnlyA
}
tasks.register('bundle', Zip) {
duplicatesStrategy = 'EXCLUDE'
dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.jar
dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.jar
archiveFileName = 'LaunchServer.zip'
destinationDirectory = file("$buildDir")
from(tasks.dumpLibs.destinationDir) { into 'libraries' }
from(tasks.dumpCompileOnlyLibs.destinationDir) { into 'launcher-libraries-compile' }
from(tasks.jar)
from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' }
}
@ -137,7 +147,7 @@ pack project(':LauncherAPI')
from parent.childProjects.Launcher.tasks.dumpLibs
}
assemble.dependsOn tasks.dumpLibs, tasks.dumpClientLibs, tasks.bundle, tasks.cleanjar
assemble.dependsOn tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.dumpClientLibs, tasks.bundle, tasks.cleanjar
publishing {

View file

@ -2,6 +2,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import pro.gravit.launcher.base.Launcher;
import pro.gravit.launcher.base.events.RequestEvent;
import pro.gravit.launcher.base.events.request.ProfilesRequestEvent;
import pro.gravit.launcher.base.modules.events.ClosePhase;
@ -22,16 +23,20 @@
import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.SocketCommandServer;
import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler;
import pro.gravit.launchserver.socket.response.auth.ProfilesResponse;
import pro.gravit.launchserver.socket.response.auth.RestoreResponse;
import pro.gravit.utils.command.Command;
import pro.gravit.utils.command.CommandHandler;
import pro.gravit.utils.command.SubCommand;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.SecurityHelper;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.security.KeyStore;
import java.time.Duration;
import java.time.Instant;

View file

@ -36,6 +36,7 @@
import java.nio.file.Path;
import java.security.Security;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.List;
public class LaunchServerStarter {

View file

@ -18,7 +18,7 @@
import java.util.stream.Stream;
public class Main {
private static final List<String> classpathOnly = List.of("proguard", "jline", "progressbar", "kotlin");
private static final List<String> classpathOnly = List.of("proguard", "jline", "progressbar", "kotlin", "epoll");
private static final String LOG4J_PROPERTY = "log4j2.configurationFile";
private static final String DEBUG_PROPERTY = "launchserver.main.debug";
private static final String LIBRARIES_PROPERTY = "launchserver.dir.libraries";

View file

@ -174,7 +174,7 @@ public AuthManager.AuthReport sudo(User user, boolean shadow) throws IOException
}
@Override
public User checkServer(Client client, String username, String serverID) {
public User checkServer(Client client, String username, String serverID) throws IOException {
SQLUser user = (SQLUser) getUserByUsername(username);
if (user == null) {
return null;

View file

@ -1,5 +1,6 @@
package pro.gravit.launchserver.auth.core;
import pro.gravit.launcher.base.ClientPermissions;
import pro.gravit.launcher.base.request.secure.HardwareReportRequest;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair;

View file

@ -41,12 +41,12 @@ public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext c
}
@Override
public User checkServer(Client client, String username, String serverID) {
public User checkServer(Client client, String username, String serverID) throws IOException {
return null;
}
@Override
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) {
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) throws IOException {
return false;
}

View file

@ -11,7 +11,9 @@
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware;
import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportHardware;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.utils.helper.IOHelper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.sql.*;
import java.util.Base64;
@ -83,7 +85,7 @@ protected SQLUser constructUser(ResultSet set) throws SQLException {
set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), set.getLong(hardwareIdColumn)) : null;
}
private SQLUserHardware fetchHardwareInfo(ResultSet set) throws SQLException {
private SQLUserHardware fetchHardwareInfo(ResultSet set) throws SQLException, IOException {
HardwareReportRequest.HardwareInfo hardwareInfo = new HardwareReportRequest.HardwareInfo();
hardwareInfo.hwDiskId = set.getString("hwDiskId");
hardwareInfo.baseboardSerialNumber = set.getString("baseboardSerialNumber");
@ -124,7 +126,7 @@ public UserHardware getHardwareInfoByPublicKey(byte[] publicKey) {
return null;
}
}
} catch (SQLException throwables) {
} catch (SQLException | IOException throwables) {
logger.error("SQL Error", throwables);
return null;
}
@ -147,7 +149,7 @@ public UserHardware getHardwareInfoByData(HardwareReportRequest.HardwareInfo inf
}
}
}
} catch (SQLException throwables) {
} catch (SQLException | IOException throwables) {
logger.error("SQL Error", throwables);
}
return null;
@ -168,7 +170,7 @@ public UserHardware getHardwareInfoById(String id) {
return null;
}
}
} catch (SQLException throwables) {
} catch (SQLException | IOException throwables) {
logger.error("SQL Error", throwables);
return null;
}
@ -292,7 +294,7 @@ protected AbstractSQLCoreProvider.SQLUserSession createSession(AbstractSQLCorePr
}
@Override
public UserSession extendedCheckServer(Client client, String username, String serverID) {
public UserSession extendedCheckServer(Client client, String username, String serverID) throws IOException {
AbstractSQLCoreProvider.SQLUser user = (AbstractSQLCoreProvider.SQLUser) getUserByUsername(username);
if (user == null) {
return null;

View file

@ -6,5 +6,5 @@
import java.io.IOException;
public interface AuthSupportExtendedCheckServer {
UserSession extendedCheckServer(Client client, String username, String serverID);
UserSession extendedCheckServer(Client client, String username, String serverID) throws IOException;
}

View file

@ -143,7 +143,7 @@ public void init(LaunchServer server, AuthProviderPair pair) {
}
@Override
public User checkServer(Client client, String username, String serverID) {
public User checkServer(Client client, String username, String serverID) throws IOException {
var savedServerId = sqlSessionStore.getServerIdByUsername(username);
if (!serverID.equals(savedServerId)) {
return null;
@ -153,7 +153,7 @@ public User checkServer(Client client, String username, String serverID) {
}
@Override
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) {
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) throws IOException {
User user;
try {
user = createUserFromMinecraftToken(accessToken);

View file

@ -3,6 +3,8 @@
import pro.gravit.launchserver.auth.SQLSourceConfig;
import pro.gravit.utils.helper.LogHelper;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.SQLException;
import java.util.UUID;

View file

@ -4,7 +4,9 @@
import org.apache.logging.log4j.Logger;
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

View file

@ -56,7 +56,7 @@ public final byte[] getDigest() {
public void init() {
}
public final boolean sync() {
public final boolean sync() throws IOException {
try {
var target = syncBinaryFile.toString();
var path = server.config.updatesProvider.download(null, List.of(target)).get(target);

View file

@ -13,6 +13,7 @@
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.IOHelper;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collections;

View file

@ -2,13 +2,17 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import pro.gravit.launcher.base.Launcher;
import pro.gravit.launcher.base.profiles.ClientProfile;
import pro.gravit.launcher.base.profiles.ClientProfileBuilder;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

View file

@ -5,7 +5,9 @@
import pro.gravit.launcher.base.profiles.ClientProfile;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.IOHelper;
import java.nio.file.Files;
import java.util.UUID;
public class DeleteProfileCommand extends Command {

View file

@ -22,7 +22,7 @@ public String getUsageDescription() {
}
@Override
public void invoke(String... args) {
public void invoke(String... args) throws Exception {
for(var profile : server.getProfiles()) {
logger.info("{} ({}) {}", profile.getTitle(), profile.getVersion().toString(), profile.isLimited() ? "limited" : "");
}

View file

@ -2,10 +2,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import pro.gravit.launcher.base.Launcher;
import pro.gravit.launcher.base.profiles.ClientProfile;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.helper.MakeProfileHelper;
import pro.gravit.utils.helper.IOHelper;
import java.io.Writer;
public class MakeProfileCommand extends Command {
private transient final Logger logger = LogManager.getLogger();

View file

@ -2,10 +2,17 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import pro.gravit.launcher.base.Launcher;
import pro.gravit.launcher.base.profiles.ClientProfile;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.IOHelper;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.UUID;
public class SaveProfilesCommand extends Command {

View file

@ -1,5 +1,6 @@
package pro.gravit.launchserver.config;
import io.netty.channel.epoll.Epoll;
import io.netty.handler.logging.LogLevel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -18,7 +19,6 @@
import pro.gravit.launchserver.components.AuthLimiterComponent;
import pro.gravit.launchserver.components.Component;
import pro.gravit.launchserver.components.ProGuardComponent;
import pro.gravit.launchserver.socket.NettyObjectFactory;
import java.util.*;
@ -64,7 +64,12 @@ public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env) {
newConfig.netty.fileServerEnabled = true;
newConfig.netty.binds = new NettyBindAddress[]{new NettyBindAddress("0.0.0.0", 9274)};
newConfig.netty.performance = new NettyPerformanceConfig();
newConfig.netty.performance.mode = NettyObjectFactory.NettyFactoryMode.AUTO;
try {
newConfig.netty.performance.usingEpoll = Epoll.isAvailable();
} catch (Throwable e) {
// Epoll class line 51+ catch (Exception) but Error will be thrown by System.load
newConfig.netty.performance.usingEpoll = false;
} // such as on ARM
newConfig.netty.performance.bossThread = 2;
newConfig.netty.performance.workerThread = 8;
newConfig.netty.performance.schedulerThread = 2;
@ -272,7 +277,7 @@ public static class NettyConfig {
}
public static class NettyPerformanceConfig {
public NettyObjectFactory.NettyFactoryMode mode = NettyObjectFactory.NettyFactoryMode.AUTO;
public boolean usingEpoll;
public int bossThread;
public int workerThread;
public int schedulerThread;

View file

@ -1,10 +1,20 @@
package pro.gravit.launchserver.manangers;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import pro.gravit.launcher.core.hasher.HashedDir;
import pro.gravit.launcher.core.serialize.HInput;
import pro.gravit.launcher.core.serialize.HOutput;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.modules.events.LaunchServerUpdatesSyncEvent;
import pro.gravit.utils.helper.IOHelper;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Stream;
public class UpdatesManager {
private final LaunchServer server;
@ -14,12 +24,12 @@ public UpdatesManager(LaunchServer server) {
}
@Deprecated
public void readUpdatesFromCache() {
public void readUpdatesFromCache() throws IOException {
}
@Deprecated
public void readUpdatesDir() {
public void readUpdatesDir() throws IOException {
}

View file

@ -4,6 +4,7 @@
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.Epoll;
import io.netty.channel.group.DefaultChannelGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
@ -35,9 +36,14 @@ public class LauncherNettyServer implements AutoCloseable {
public LauncherNettyServer(LaunchServer server) {
LaunchServerConfig.NettyConfig config = server.config.netty;
NettyObjectFactory.setMode(config.performance.mode);
NettyObjectFactory.setUsingEpoll(config.performance.usingEpoll);
Logger logger = LogManager.getLogger();
logger.info("Netty usage {} transport mode", NettyObjectFactory.getMode());
if (config.performance.usingEpoll) {
logger.debug("Netty: Epoll enabled");
}
if (config.performance.usingEpoll && !Epoll.isAvailable()) {
logger.error("Epoll is not available: (netty,perfomance.usingEpoll configured wrongly)", Epoll.unavailabilityCause());
}
bossGroup = NettyObjectFactory.newEventLoopGroup(config.performance.bossThread, "LauncherNettyServer.bossGroup");
workerGroup = NettyObjectFactory.newEventLoopGroup(config.performance.workerThread, "LauncherNettyServer.workerGroup");
serverBootstrap = new ServerBootstrap();

View file

@ -2,58 +2,30 @@
import io.netty.channel.ChannelFactory;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.MultiThreadIoEventLoopGroup;
import io.netty.channel.ServerChannel;
import io.netty.channel.epoll.Epoll;
import io.netty.channel.epoll.EpollIoHandler;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollServerSocketChannel;
import io.netty.channel.nio.NioIoHandler;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.uring.IoUring;
import io.netty.channel.uring.IoUringIoHandler;
import io.netty.channel.uring.IoUringServerSocketChannel;
public class NettyObjectFactory {
private static NettyFactoryMode mode;
private static boolean epoll = false;
public static void setMode(NettyFactoryMode mode) {
NettyObjectFactory.mode = mode;
if(mode == NettyFactoryMode.AUTO) {
if(IoUring.isAvailable()) {
NettyObjectFactory.mode = NettyFactoryMode.IO_URING;
return;
}
if(Epoll.isAvailable()) {
NettyObjectFactory.mode = NettyFactoryMode.EPOLL;
return;
}
NettyObjectFactory.mode = NettyFactoryMode.NIO;
}
}
public static NettyFactoryMode getMode() {
return mode;
public static void setUsingEpoll(boolean value) {
epoll = value;
}
public static EventLoopGroup newEventLoopGroup(int threads, String poolName) {
return switch (mode) {
case AUTO -> null;
case NIO -> new MultiThreadIoEventLoopGroup(threads, NioIoHandler.newFactory());
case EPOLL -> new MultiThreadIoEventLoopGroup(threads, EpollIoHandler.newFactory());
case IO_URING -> new MultiThreadIoEventLoopGroup(threads, IoUringIoHandler.newFactory());
};
if (epoll)
return new EpollEventLoopGroup(threads);
else
return new NioEventLoopGroup(threads);
}
public static ChannelFactory<? extends ServerChannel> getServerSocketChannelFactory() {
return switch (mode) {
case AUTO -> null;
case NIO -> NioServerSocketChannel::new;
case EPOLL -> EpollServerSocketChannel::new;
case IO_URING -> IoUringServerSocketChannel::new;
};
}
public enum NettyFactoryMode {
AUTO, NIO, EPOLL, IO_URING
if (epoll)
return EpollServerSocketChannel::new;
else
return NioServerSocketChannel::new;
}
}

View file

@ -5,6 +5,7 @@
import pro.gravit.launchserver.config.log4j.LogAppender;
import pro.gravit.utils.command.CommandHandler;
import java.io.IOException;
import java.net.StandardProtocolFamily;
import java.net.UnixDomainSocketAddress;
import java.nio.ByteBuffer;
@ -63,9 +64,9 @@ public void run() {
ByteBuffer buffer = ByteBuffer.allocate(1024);
while (true) {
SocketChannel channel = serverChannel.accept();
try (channel) {
channel.configureBlocking(true);
String command = null;
try {
mark:
while (true) {
int bytesRead = channel.read(buffer);
@ -85,6 +86,7 @@ public void run() {
}
} finally {
buffer.clear();
channel.close();
}
}
} catch (Throwable e) {

View file

@ -22,6 +22,7 @@
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.UnsupportedTemporalTypeException;
import java.util.Arrays;

View file

@ -7,7 +7,7 @@
public interface WebSocketServerResponse extends WebSocketRequest {
String getType();
void execute(ChannelHandlerContext ctx, Client client);
void execute(ChannelHandlerContext ctx, Client client) throws Exception;
default ThreadSafeStatus getThreadSafeStatus() {
return ThreadSafeStatus.READ;

View file

@ -23,7 +23,7 @@ public String getType() {
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
sendResult(new CurrentUserRequestEvent(collectUserInfoFromClient(server, client)));
}
}

View file

@ -44,7 +44,7 @@ public String getType() {
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
if (accessToken == null && !client.isAuth && needUserInfo) {
sendError("Invalid request");
return;

View file

@ -12,7 +12,7 @@ public String getType() {
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
if(!client.isAuth || client.auth == null || client.getUser() == null) {
sendError("Access denied");
return;

View file

@ -14,7 +14,7 @@ public String getType() {
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
if(!client.isAuth || client.auth == null || client.getUser() == null) {
sendError("Access denied");
return;

View file

@ -12,7 +12,7 @@ public String getType() {
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
sendResult(new GetConnectUUIDRequestEvent(connectUUID, server.shardId));
}
}

View file

@ -28,6 +28,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;
public class ClientLauncherProcess {
public final List<String> pre = new LinkedList<>();

View file

@ -12,6 +12,7 @@
import java.lang.reflect.Type;
import java.net.InetSocketAddress;
import java.nio.file.Path;
import java.util.*;
public final class ClientProfile implements Comparable<ClientProfile> {

View file

@ -3,6 +3,7 @@
import java.io.IOException;
public final class RequestException extends IOException {
private static final long serialVersionUID = 7558237657082664821L;
public RequestException(String message) {

View file

@ -6,7 +6,7 @@
public interface RequestService {
<T extends WebSocketEvent> CompletableFuture<T> request(Request<T> request) throws IOException;
void open();
void open() throws Exception;
void registerEventHandler(EventHandler handler);

View file

@ -33,7 +33,7 @@ public abstract class ClientJSONPoint implements WebSocket.Listener {
private final Object sendSyncObject = new Object();
private volatile StringBuilder builder = new StringBuilder();
public ClientJSONPoint(final String uri) {
public ClientJSONPoint(final String uri) throws SSLException {
this(URI.create(uri));
}
@ -114,7 +114,7 @@ public void send(String text) {
abstract void onOpen();
public void close() {
public void close() throws InterruptedException {
webSocket.abort();
}

View file

@ -33,7 +33,7 @@ public abstract class ClientWebSocketService extends ClientJSONPoint {
public OnCloseCallback onCloseCallback;
public ReconnectCallback reconnectCallback;
public ClientWebSocketService(String address) {
public ClientWebSocketService(String address) throws SSLException {
super(createURL(address));
this.gson = Launcher.gsonManager.gson;
this.onConnect = true;

View file

@ -40,7 +40,11 @@ public static CompletableFuture<StdWebSocketService> initWebSockets(String addre
service.openAsync(() -> {
future.complete(service);
JVMHelper.RUNTIME.addShutdownHook(new Thread(() -> {
try {
service.close();
} catch (InterruptedException e) {
LogHelper.error(e);
}
}));
}, future::completeExceptionally);
return future;

View file

@ -7,9 +7,9 @@
public class ClientVersionTest {
@Test
public void parseTest() {
Assertions.assertEquals("1.0.0", ClientProfile.Version.of("1.0.0").toCleanString());
Assertions.assertEquals("1.0.0.1", ClientProfile.Version.of("1.0.0-1").toCleanString());
Assertions.assertEquals("1.0.0", ClientProfile.Version.of("-----1.0.0").toCleanString());
Assertions.assertEquals(ClientProfile.Version.of("1.0.0").toCleanString(), "1.0.0");
Assertions.assertEquals(ClientProfile.Version.of("1.0.0-1").toCleanString(), "1.0.0.1");
Assertions.assertEquals(ClientProfile.Version.of("-----1.0.0").toCleanString(), "1.0.0");
}
@Test

View file

@ -49,12 +49,12 @@ public void dependenciesTest() {
moduleManager.loadModule(new Depend3Module());
moduleManager.loadModule(new MainModule());
moduleManager.initModules(null);
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("depend1").getInitStatus());
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("depend2").getInitStatus());
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("depend3").getInitStatus());
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("internal").getInitStatus());
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("virtual").getInitStatus());
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("main").getInitStatus());
Assertions.assertEquals(moduleManager.getModule("depend1").getInitStatus(), LauncherModule.InitStatus.FINISH);
Assertions.assertEquals(moduleManager.getModule("depend2").getInitStatus(), LauncherModule.InitStatus.FINISH);
Assertions.assertEquals(moduleManager.getModule("depend3").getInitStatus(), LauncherModule.InitStatus.FINISH);
Assertions.assertEquals(moduleManager.getModule("internal").getInitStatus(), LauncherModule.InitStatus.FINISH);
Assertions.assertEquals(moduleManager.getModule("virtual").getInitStatus(), LauncherModule.InitStatus.FINISH);
Assertions.assertEquals(moduleManager.getModule("main").getInitStatus(), LauncherModule.InitStatus.FINISH);
}
@Test
@ -62,7 +62,7 @@ public void cyclicTest() {
moduleManager.loadModule(new CyclicDependModule());
moduleManager.loadModule(new Cyclic2DependModule());
moduleManager.initModules(null);
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("cyclic1").getInitStatus());
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("cyclic2").getInitStatus());
Assertions.assertEquals(moduleManager.getModule("cyclic1").getInitStatus(), LauncherModule.InitStatus.FINISH);
Assertions.assertEquals(moduleManager.getModule("cyclic2").getInitStatus(), LauncherModule.InitStatus.FINISH);
}
}

View file

@ -16,10 +16,10 @@ public Depend1Module() {
@Override
public void init(LauncherInitContext initContext) {
InternalModule module = modulesManager.getModule(InternalModule.class);
Assertions.assertEquals(InitStatus.FINISH, module.getInitStatus());
Assertions.assertEquals(module.getInitStatus(), InitStatus.FINISH);
Depend3Module module1 = modulesManager.getModule(Depend3Module.class);
Assertions.assertEquals(InitStatus.FINISH, module1.getInitStatus());
Assertions.assertEquals(module1.getInitStatus(), InitStatus.FINISH);
VirtualInterface virtualInterface = modulesManager.getModuleByInterface(VirtualInterface.class);
Assertions.assertEquals(InitStatus.FINISH, ((LauncherModule) virtualInterface).getInitStatus());
Assertions.assertEquals(((LauncherModule) virtualInterface).getInitStatus(), InitStatus.FINISH);
}
}

View file

@ -17,8 +17,8 @@ public MainModule() {
@Override
public void init(LauncherInitContext initContext) {
Depend1Module module = modulesManager.getModule(Depend1Module.class);
Assertions.assertEquals(InitStatus.FINISH, module.getInitStatus());
Assertions.assertEquals(module.getInitStatus(), InitStatus.FINISH);
Depend2Module module2 = modulesManager.getModule(Depend2Module.class);
Assertions.assertEquals(InitStatus.FINISH, module2.getInitStatus());
Assertions.assertEquals(module2.getInitStatus(), InitStatus.FINISH);
}
}

View file

@ -124,7 +124,7 @@ private static void realMain(String[] args) throws Throwable {
LogHelper.dev("Classpath entry %s", e);
}
}
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).toList();
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).collect(Collectors.toList());
// Start client with WatchService monitoring
RequestService service;
if (params.offlineMode) {

View file

@ -282,7 +282,7 @@ public enum WalkAction {
@FunctionalInterface
public interface WalkCallback {
WalkAction walked(String path, String name, HashedEntry entry);
WalkAction walked(String path, String name, HashedEntry entry) throws IOException;
}
public static class FindRecursiveResult {

View file

@ -1,6 +1,7 @@
package pro.gravit.utils;
public class HookException extends RuntimeException {
private static final long serialVersionUID = -529141998961943161L;
public HookException(String message) {
super(message);

View file

@ -6,9 +6,9 @@ public final class Version implements Comparable<Version> {
public static final int MAJOR = 5;
public static final int MINOR = 6;
public static final int PATCH = 11;
public static final int PATCH = 9;
public static final int BUILD = 1;
public static final Version.Type RELEASE = Type.DEV;
public static final Version.Type RELEASE = Type.STABLE;
public final int major;
public final int minor;
public final int patch;

View file

@ -1,6 +1,7 @@
package pro.gravit.utils.command;
public final class CommandException extends Exception {
private static final long serialVersionUID = -6588814993972117772L;
public CommandException(String message) {

View file

@ -221,40 +221,38 @@ public static ArgsParseResult parseJavaArgs(List<String> args) {
continue;
}
}
switch (arg) {
case "--module-path", "-p" -> {
if(arg.equals("--module-path") || arg.equals("-p")) {
prevArgType = PrevArgType.MODULE_PATH;
continue;
}
case "--classpath", "-cp" -> {
if(arg.equals("--classpath") || arg.equals("-cp")) {
prevArgType = PrevArgType.CLASSPATH;
continue;
}
case "--add-modules" -> {
if(arg.equals("--add-modules")) {
prevArgType = PrevArgType.ADD_MODULES;
continue;
}
case "--add-opens" -> {
if(arg.equals("--add-opens")) {
prevArgType = PrevArgType.ADD_OPENS;
continue;
}
case "--add-exports" -> {
if(arg.equals("--add-exports")) {
prevArgType = PrevArgType.ADD_EXPORTS;
continue;
}
case "--add-reads" -> {
if(arg.equals("--add-reads")) {
prevArgType = PrevArgType.ADD_READS;
continue;
}
case "--module", "-m" -> {
if(arg.equals("--module") || arg.equals("-m")) {
prevArgType = PrevArgType.MODULE;
continue;
}
case "-jar" -> {
if(arg.equals("-jar")) {
prevArgType = PrevArgType.JAR;
continue;
}
}
jvmArgs.add(arg);
}
return new ArgsParseResult(conf, classpath, jvmArgs, mainClass, mainModule, jarFile, args);

View file

@ -83,7 +83,7 @@ public static byte[] getClassBytes(Class<?> clazz, ClassLoader classLoader) thro
return IOHelper.read(classLoader.getResourceAsStream(getClassFile(clazz)));
}
public static InputStream getClassBytesStream(Class<?> clazz) {
public static InputStream getClassBytesStream(Class<?> clazz) throws IOException {
return getClassBytesStream(clazz, clazz.getClassLoader());
}

View file

@ -68,7 +68,7 @@ public void addTransformer(ClassTransformer transformer) {
}
instrumentation.addTransformer(new ClassFileTransformer() {
@Override
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
if(transformer.filter(null, className)) {
return transformer.transform(null, className, protectionDomain, classfileBuffer);
}

View file

@ -30,8 +30,8 @@ public void main() {
String json2 = gson.toJson(new MyTestClass2("BBBB"), TestInterface.class);
TestInterface test1 = gson.fromJson(json, TestInterface.class);
TestInterface test2 = gson.fromJson(json2, TestInterface.class);
Assertions.assertEquals("AAAA", test1.get());
Assertions.assertEquals("BBBB", test2.get());
Assertions.assertEquals(test1.get(), "AAAA");
Assertions.assertEquals(test2.get(), "BBBB");
}
public interface TestInterface {

View file

@ -5,7 +5,7 @@
id 'org.openjfx.javafxplugin' version '0.1.0' apply false
}
group = 'pro.gravit.launcher'
version = '5.6.10'
version = '5.6.9'
apply from: 'props.gradle'

@ -1 +1 @@
Subproject commit 00b275f82f52b9bbfebe4649b8c96a438365aecd
Subproject commit 803846d9c4db29fb64ad96e45e46b1e9f64b2e03

View file

@ -1,6 +1,6 @@
project.ext {
verAsm = '9.7.1'
verNetty = '4.2.0.RC3'
verNetty = '4.1.114.Final'
verOshiCore = '6.6.6'
verJunit = '5.11.4'
verJansi = '2.4.1'