From bca195ca96bb553fa787024f5e381d904bdd7ae9 Mon Sep 17 00:00:00 2001 From: Gravita Date: Sun, 7 Feb 2021 22:01:26 +0700 Subject: [PATCH 1/8] [ANY] Release 5.0.10 stable --- LauncherCore/src/main/java/pro/gravit/utils/Version.java | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index 3e643fc5..ade09420 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -8,7 +8,7 @@ public final class Version { public static final int MINOR = 1; public static final int PATCH = 10; 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; diff --git a/build.gradle b/build.gradle index 9eafacce..b53c73e8 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ id 'org.openjfx.javafxplugin' version '0.0.8' apply false } group = 'pro.gravit.launcher' -version = '5.1.10-SNAPSHOT' +version = '5.1.10' apply from: 'props.gradle' From 3ccb0c5c8aaa968746c9b66bce0e04568b1fa242 Mon Sep 17 00:00:00 2001 From: Gravita Date: Mon, 8 Feb 2021 14:42:07 +0700 Subject: [PATCH 2/8] =?UTF-8?q?[FIX]=20=D0=9E=D0=BF=D1=82=D0=B8=D0=BC?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20`certificatePinning`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launcher/CertificatePinningTrustManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/CertificatePinningTrustManager.java b/LauncherCore/src/main/java/pro/gravit/launcher/CertificatePinningTrustManager.java index 0c9838f7..a8183fbc 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/CertificatePinningTrustManager.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/CertificatePinningTrustManager.java @@ -21,6 +21,7 @@ public final class CertificatePinningTrustManager { @LauncherInject("launchercore.certificates") private static List secureConfigCertificates; private static X509Certificate[] certs = null; + private volatile static TrustManagerFactory INSTANCE; private static X509Certificate[] getInternalCertificates() { CertificateFactory certFactory = null; try { @@ -45,6 +46,7 @@ public static X509Certificate[] getCertificates() { } public static TrustManagerFactory getTrustManager() throws KeyStoreException, NoSuchAlgorithmException, IOException, CertificateException { + if(INSTANCE != null) return INSTANCE; if(certs == null) certs = getInternalCertificates(); TrustManagerFactory factory = TrustManagerFactory.getInstance("X.509"); KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); @@ -57,6 +59,7 @@ public static TrustManagerFactory getTrustManager() throws KeyStoreException, No i++; } factory.init(keystore); + INSTANCE = factory; return factory; } } From 715498982724bb2dd491dc05f68627060936831d Mon Sep 17 00:00:00 2001 From: Gravita Date: Mon, 8 Feb 2021 17:58:24 +0700 Subject: [PATCH 3/8] =?UTF-8?q?[FIX]=20OutOfMemory=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?=D1=81=20`certificatePinning`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pro/gravit/launcher/AsyncDownloader.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/AsyncDownloader.java b/LauncherCore/src/main/java/pro/gravit/launcher/AsyncDownloader.java index 12699f34..97689567 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/AsyncDownloader.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/AsyncDownloader.java @@ -31,6 +31,7 @@ public class AsyncDownloader { public final Callback callback; @LauncherInject("launcher.certificatePinning") private static boolean isCertificatePinning; + private static volatile SSLSocketFactory sslSocketFactory; public AsyncDownloader(Callback callback) { this.callback = callback; @@ -71,9 +72,11 @@ public void downloadFile(URL url, Path target) throws IOException { } public SSLSocketFactory makeSSLSocketFactory() throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, KeyManagementException { + if(sslSocketFactory != null) return sslSocketFactory; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, CertificatePinningTrustManager.getTrustManager().getTrustManagers(), new SecureRandom()); - return sslContext.getSocketFactory(); + sslSocketFactory = sslContext.getSocketFactory(); + return sslSocketFactory; } public void downloadListInOneThread(List files, String baseURL, Path targetDir) throws URISyntaxException, IOException { From f6d954827ef0184095ca4134bf700f143d2be119 Mon Sep 17 00:00:00 2001 From: Gravita Date: Mon, 8 Feb 2021 18:23:46 +0700 Subject: [PATCH 4/8] [FIX] GitHub Actions --- .github/workflows/push.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index fd5ef96f..a2a04688 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,9 +1,6 @@ name: push on: push: - create: - tags: - - v* jobs: launcher: name: Launcher @@ -55,7 +52,7 @@ jobs: - name: Create release id: create_release uses: actions/create-release@v1 - if: github.event_name == 'create' + if: github.event.ref == 'refs/tags/*' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -65,13 +62,13 @@ jobs: prerelease: false - name: Pack release - if: github.event_name == 'create' + if: github.event.ref == 'refs/tags/*' run: | cd artifacts/ zip -r -9 ../Release.zip * - name: Upload release - if: github.event_name == 'create' + if: github.event.ref == 'refs/tags/*' uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9084361a3848aa8a6085e6d6785c3452164abdd9 Mon Sep 17 00:00:00 2001 From: Gravita Date: Fri, 12 Feb 2021 20:56:55 +0700 Subject: [PATCH 5/8] =?UTF-8?q?[FIX]=20=D0=97=D0=B0=D1=89=D0=B8=D1=82?= =?UTF-8?q?=D0=B0=20=D0=BE=D1=82=20=D0=B4=D1=83=D1=80=D0=B0=D0=BA=D0=B0=20?= =?UTF-8?q?(=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5=D0=BA)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pro/gravit/launchserver/LaunchServerStarter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java index 0c2079d9..a8e858b4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java @@ -61,7 +61,13 @@ public static void main(String[] args) throws Exception { Path privateKeyFile = dir.resolve("private.key"); ECPublicKey publicKey; ECPrivateKey privateKey; - Security.addProvider(new BouncyCastleProvider()); + try { + Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider"); + Security.addProvider(new BouncyCastleProvider()); + } catch (ClassNotFoundException ex) { + LogHelper.error("Library BouncyCastle not found! Is directory 'libraries' empty?"); + return; + } CertificateManager certificateManager = new CertificateManager(); try { certificateManager.readTrustStore(dir.resolve("truststore")); From 3cd9ddee0d1075ed1079f66d62349c92dcef6327 Mon Sep 17 00:00:00 2001 From: Gravita Date: Fri, 12 Feb 2021 21:19:49 +0700 Subject: [PATCH 6/8] =?UTF-8?q?[FIX]=20autoDump=20=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=88=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launchserver/LaunchServer.java | 13 ++++++++++--- .../auth/session/MemorySessionStorage.java | 18 +++++++++++------- .../config/LaunchServerConfig.java | 7 +++++++ .../socket/LauncherNettyServer.java | 7 +++++-- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index b74d8de7..202459d6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -319,7 +319,8 @@ public void buildLauncherBinaries() throws IOException { } public void close() throws Exception { - + LogHelper.info("Close server socket"); + nettyServerSocketHandler.close(); // Close handlers & providers config.close(ReloadType.FULL); modulesManager.invokeEvent(new ClosePhase()); @@ -368,8 +369,14 @@ public void run() { } if (config.netty != null) rebindNettyServerSocket(); - modulesManager.fullInitializedLaunchServer(this); - modulesManager.invokeEvent(new LaunchServerFullInitEvent(this)); + try { + modulesManager.fullInitializedLaunchServer(this); + modulesManager.invokeEvent(new LaunchServerFullInitEvent(this)); + LogHelper.info("LaunchServer started"); + } catch (Throwable e) { + LogHelper.error(e); + JVMHelper.RUNTIME.exit(-1); + } } public void syncLauncherBinaries() throws IOException { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/session/MemorySessionStorage.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/session/MemorySessionStorage.java index 620b0faa..0dc45db7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/session/MemorySessionStorage.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/session/MemorySessionStorage.java @@ -17,7 +17,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; -public class MemorySessionStorage extends SessionStorage implements NeedGarbageCollection { +public class MemorySessionStorage extends SessionStorage implements NeedGarbageCollection, AutoCloseable { private transient final Map clientSet = new ConcurrentHashMap<>(128); private transient final Map> uuidIndex = new ConcurrentHashMap<>(32); @@ -90,10 +90,6 @@ public boolean deleteSessionsByUserUUID(UUID userUUID) { public void clear() { clientSet.clear(); uuidIndex.clear(); - if(autoDump) { - garbageCollection(); - dumpSessionsData(); - } } public void dumpSessionsData() { @@ -161,6 +157,14 @@ public void garbageCollection() { to_delete.clear(); } + @Override + public void close() throws Exception { + if(autoDump) { + garbageCollection(); + dumpSessionsData(); + } + } + private static class Entry { public byte[] data; public UUID sessionUuid; @@ -174,8 +178,8 @@ public Entry(byte[] data, UUID sessionUuid) { } private static class DumpedData { - private transient final Map clientSet; - private transient final Map> uuidIndex; + private final Map clientSet; + private final Map> uuidIndex; private DumpedData(Map clientSet, Map> uuidIndex) { this.clientSet = clientSet; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java index 671a4ba9..107153c5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -235,6 +235,13 @@ public void close(LaunchServer.ReloadType type) { } if(sessions != null) { server.unregisterObject("sessions", sessions); + if (sessions instanceof AutoCloseable) { + try { + ((AutoCloseable) sessions).close(); + } catch (Exception e) { + LogHelper.error(e); + } + } } if (dao != null) { server.unregisterObject("dao", dao); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java index 6042d2d2..a68169df 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java @@ -24,6 +24,7 @@ import pro.gravit.utils.helper.LogHelper; import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; public class LauncherNettyServer implements AutoCloseable { private static final String WEBSOCKET_PATH = "/api"; @@ -77,7 +78,9 @@ public ChannelFuture bind(InetSocketAddress address) { @Override public void close() { - workerGroup.shutdownGracefully(); - bossGroup.shutdownGracefully(); + workerGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS); + bossGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS); + //workerGroup.shutdownGracefully(); + //bossGroup.shutdownGracefully(); } } From b8be6d4ef667a7e1a33327364048f388a4c23e9b Mon Sep 17 00:00:00 2001 From: Gravita Date: Fri, 12 Feb 2021 21:33:05 +0700 Subject: [PATCH 7/8] [FEATURE] LaunchServer save command --- .../main/java/pro/gravit/launchserver/LaunchServer.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 202459d6..724d8a31 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -293,6 +293,15 @@ public void invoke(String... args) throws Exception { } }; commands.put("reload", reload); + SubCommand save = new SubCommand() { + @Override + public void invoke(String... args) throws Exception { + launchServerConfigManager.writeConfig(config); + launchServerConfigManager.writeRuntimeConfig(runtime); + LogHelper.info("LaunchServerConfig saved"); + } + }; + commands.put("save", save); return commands; } From 0e505a1feb31f35285a1b8b6e9c1c61df38b1816 Mon Sep 17 00:00:00 2001 From: Gravita Date: Fri, 12 Feb 2021 21:33:49 +0700 Subject: [PATCH 8/8] [ANY] 5.1.10b2 stable --- LauncherCore/src/main/java/pro/gravit/utils/Version.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index ade09420..1686b8bc 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -7,7 +7,7 @@ public final class Version { public static final int MAJOR = 5; public static final int MINOR = 1; public static final int PATCH = 10; - public static final int BUILD = 1; + public static final int BUILD = 2; public static final Version.Type RELEASE = Type.STABLE; public final int major; public final int minor;