Merge tag 'v5.1.10' into dev

5.1.10 Stable
This commit is contained in:
Gravita 2021-02-12 21:34:27 +07:00
commit 8ff31888e9
10 changed files with 62 additions and 23 deletions

View file

@ -1,9 +1,6 @@
name: push name: push
on: on:
push: push:
create:
tags:
- v*
jobs: jobs:
launcher: launcher:
name: Launcher name: Launcher
@ -55,7 +52,7 @@ jobs:
- name: Create release - name: Create release
id: create_release id: create_release
uses: actions/create-release@v1 uses: actions/create-release@v1
if: github.event_name == 'create' if: github.event.ref == 'refs/tags/*'
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
@ -65,13 +62,13 @@ jobs:
prerelease: false prerelease: false
- name: Pack release - name: Pack release
if: github.event_name == 'create' if: github.event.ref == 'refs/tags/*'
run: | run: |
cd artifacts/ cd artifacts/
zip -r -9 ../Release.zip * zip -r -9 ../Release.zip *
- name: Upload release - name: Upload release
if: github.event_name == 'create' if: github.event.ref == 'refs/tags/*'
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -293,6 +293,15 @@ public void invoke(String... args) throws Exception {
} }
}; };
commands.put("reload", reload); 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; return commands;
} }
@ -319,7 +328,8 @@ public void buildLauncherBinaries() throws IOException {
} }
public void close() throws Exception { public void close() throws Exception {
LogHelper.info("Close server socket");
nettyServerSocketHandler.close();
// Close handlers & providers // Close handlers & providers
config.close(ReloadType.FULL); config.close(ReloadType.FULL);
modulesManager.invokeEvent(new ClosePhase()); modulesManager.invokeEvent(new ClosePhase());
@ -368,8 +378,14 @@ public void run() {
} }
if (config.netty != null) if (config.netty != null)
rebindNettyServerSocket(); rebindNettyServerSocket();
modulesManager.fullInitializedLaunchServer(this); try {
modulesManager.invokeEvent(new LaunchServerFullInitEvent(this)); 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 { public void syncLauncherBinaries() throws IOException {

View file

@ -61,7 +61,13 @@ public static void main(String[] args) throws Exception {
Path privateKeyFile = dir.resolve("private.key"); Path privateKeyFile = dir.resolve("private.key");
ECPublicKey publicKey; ECPublicKey publicKey;
ECPrivateKey privateKey; 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(); CertificateManager certificateManager = new CertificateManager();
try { try {
certificateManager.readTrustStore(dir.resolve("truststore")); certificateManager.readTrustStore(dir.resolve("truststore"));

View file

@ -17,7 +17,7 @@
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream; import java.util.stream.Stream;
public class MemorySessionStorage extends SessionStorage implements NeedGarbageCollection { public class MemorySessionStorage extends SessionStorage implements NeedGarbageCollection, AutoCloseable {
private transient final Map<UUID, Entry> clientSet = new ConcurrentHashMap<>(128); private transient final Map<UUID, Entry> clientSet = new ConcurrentHashMap<>(128);
private transient final Map<UUID, Set<Entry>> uuidIndex = new ConcurrentHashMap<>(32); private transient final Map<UUID, Set<Entry>> uuidIndex = new ConcurrentHashMap<>(32);
@ -90,10 +90,6 @@ public boolean deleteSessionsByUserUUID(UUID userUUID) {
public void clear() { public void clear() {
clientSet.clear(); clientSet.clear();
uuidIndex.clear(); uuidIndex.clear();
if(autoDump) {
garbageCollection();
dumpSessionsData();
}
} }
public void dumpSessionsData() { public void dumpSessionsData() {
@ -161,6 +157,14 @@ public void garbageCollection() {
to_delete.clear(); to_delete.clear();
} }
@Override
public void close() throws Exception {
if(autoDump) {
garbageCollection();
dumpSessionsData();
}
}
private static class Entry { private static class Entry {
public byte[] data; public byte[] data;
public UUID sessionUuid; public UUID sessionUuid;
@ -174,8 +178,8 @@ public Entry(byte[] data, UUID sessionUuid) {
} }
private static class DumpedData { private static class DumpedData {
private transient final Map<UUID, Entry> clientSet; private final Map<UUID, Entry> clientSet;
private transient final Map<UUID, Set<Entry>> uuidIndex; private final Map<UUID, Set<Entry>> uuidIndex;
private DumpedData(Map<UUID, Entry> clientSet, Map<UUID, Set<Entry>> uuidIndex) { private DumpedData(Map<UUID, Entry> clientSet, Map<UUID, Set<Entry>> uuidIndex) {
this.clientSet = clientSet; this.clientSet = clientSet;

View file

@ -235,6 +235,13 @@ public void close(LaunchServer.ReloadType type) {
} }
if(sessions != null) { if(sessions != null) {
server.unregisterObject("sessions", sessions); server.unregisterObject("sessions", sessions);
if (sessions instanceof AutoCloseable) {
try {
((AutoCloseable) sessions).close();
} catch (Exception e) {
LogHelper.error(e);
}
}
} }
if (dao != null) { if (dao != null) {
server.unregisterObject("dao", dao); server.unregisterObject("dao", dao);

View file

@ -24,6 +24,7 @@
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
public class LauncherNettyServer implements AutoCloseable { public class LauncherNettyServer implements AutoCloseable {
private static final String WEBSOCKET_PATH = "/api"; private static final String WEBSOCKET_PATH = "/api";
@ -77,7 +78,9 @@ public ChannelFuture bind(InetSocketAddress address) {
@Override @Override
public void close() { public void close() {
workerGroup.shutdownGracefully(); workerGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS);
bossGroup.shutdownGracefully(); bossGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS);
//workerGroup.shutdownGracefully();
//bossGroup.shutdownGracefully();
} }
} }

View file

@ -31,6 +31,7 @@ public class AsyncDownloader {
public final Callback callback; public final Callback callback;
@LauncherInject("launcher.certificatePinning") @LauncherInject("launcher.certificatePinning")
private static boolean isCertificatePinning; private static boolean isCertificatePinning;
private static volatile SSLSocketFactory sslSocketFactory;
public AsyncDownloader(Callback callback) { public AsyncDownloader(Callback callback) {
this.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 { public SSLSocketFactory makeSSLSocketFactory() throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, KeyManagementException {
if(sslSocketFactory != null) return sslSocketFactory;
SSLContext sslContext = SSLContext.getInstance("TLS"); SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, CertificatePinningTrustManager.getTrustManager().getTrustManagers(), new SecureRandom()); sslContext.init(null, CertificatePinningTrustManager.getTrustManager().getTrustManagers(), new SecureRandom());
return sslContext.getSocketFactory(); sslSocketFactory = sslContext.getSocketFactory();
return sslSocketFactory;
} }
public void downloadListInOneThread(List<SizedFile> files, String baseURL, Path targetDir) throws URISyntaxException, IOException { public void downloadListInOneThread(List<SizedFile> files, String baseURL, Path targetDir) throws URISyntaxException, IOException {

View file

@ -21,6 +21,7 @@ public final class CertificatePinningTrustManager {
@LauncherInject("launchercore.certificates") @LauncherInject("launchercore.certificates")
private static List<byte[]> secureConfigCertificates; private static List<byte[]> secureConfigCertificates;
private static X509Certificate[] certs = null; private static X509Certificate[] certs = null;
private volatile static TrustManagerFactory INSTANCE;
private static X509Certificate[] getInternalCertificates() { private static X509Certificate[] getInternalCertificates() {
CertificateFactory certFactory = null; CertificateFactory certFactory = null;
try { try {
@ -45,6 +46,7 @@ public static X509Certificate[] getCertificates() {
} }
public static TrustManagerFactory getTrustManager() throws KeyStoreException, NoSuchAlgorithmException, IOException, CertificateException { public static TrustManagerFactory getTrustManager() throws KeyStoreException, NoSuchAlgorithmException, IOException, CertificateException {
if(INSTANCE != null) return INSTANCE;
if(certs == null) certs = getInternalCertificates(); if(certs == null) certs = getInternalCertificates();
TrustManagerFactory factory = TrustManagerFactory.getInstance("X.509"); TrustManagerFactory factory = TrustManagerFactory.getInstance("X.509");
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
@ -57,6 +59,7 @@ public static TrustManagerFactory getTrustManager() throws KeyStoreException, No
i++; i++;
} }
factory.init(keystore); factory.init(keystore);
INSTANCE = factory;
return factory; return factory;
} }
} }

View file

@ -7,8 +7,8 @@ public final class Version {
public static final int MAJOR = 5; public static final int MAJOR = 5;
public static final int MINOR = 1; public static final int MINOR = 1;
public static final int PATCH = 10; 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.DEV; public static final Version.Type RELEASE = Type.STABLE;
public final int major; public final int major;
public final int minor; public final int minor;
public final int patch; public final int patch;

View file

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