mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[REFACTOR] IDEA Inspect
This commit is contained in:
parent
6da27bdf99
commit
0c97fdf45c
30 changed files with 28 additions and 150 deletions
|
@ -1,7 +1,5 @@
|
||||||
package pro.gravit.launchserver;
|
package pro.gravit.launchserver;
|
||||||
|
|
||||||
import org.bouncycastle.crypto.util.PrivateKeyFactory;
|
|
||||||
import org.bouncycastle.operator.OperatorCreationException;
|
|
||||||
import pro.gravit.launcher.Launcher;
|
import pro.gravit.launcher.Launcher;
|
||||||
import pro.gravit.launcher.NeedGarbageCollection;
|
import pro.gravit.launcher.NeedGarbageCollection;
|
||||||
import pro.gravit.launcher.hasher.HashedDir;
|
import pro.gravit.launcher.hasher.HashedDir;
|
||||||
|
@ -38,9 +36,6 @@
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
|
||||||
import java.security.KeyPair;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.interfaces.ECPrivateKey;
|
import java.security.interfaces.ECPrivateKey;
|
||||||
import java.security.interfaces.ECPublicKey;
|
import java.security.interfaces.ECPublicKey;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -151,36 +146,6 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
|
||||||
featuresManager = new FeaturesManager(this);
|
featuresManager = new FeaturesManager(this);
|
||||||
//Generate or set new Certificate API
|
//Generate or set new Certificate API
|
||||||
certificateManager.orgName = config.projectName;
|
certificateManager.orgName = config.projectName;
|
||||||
/*
|
|
||||||
if (false) {
|
|
||||||
if (IOHelper.isFile(caCertFile) && IOHelper.isFile(caKeyFile)) {
|
|
||||||
certificateManager.ca = certificateManager.readCertificate(caCertFile);
|
|
||||||
certificateManager.caKey = certificateManager.readPrivateKey(caKeyFile);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
certificateManager.generateCA();
|
|
||||||
certificateManager.writeCertificate(caCertFile, certificateManager.ca);
|
|
||||||
certificateManager.writePrivateKey(caKeyFile, certificateManager.caKey);
|
|
||||||
} catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException | OperatorCreationException e) {
|
|
||||||
LogHelper.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (IOHelper.isFile(serverCertFile) && IOHelper.isFile(serverKeyFile)) {
|
|
||||||
certificateManager.server = certificateManager.readCertificate(serverCertFile);
|
|
||||||
certificateManager.serverKey = certificateManager.readPrivateKey(serverKeyFile);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
KeyPair pair = certificateManager.generateKeyPair();
|
|
||||||
certificateManager.server = certificateManager.generateCertificate(config.projectName.concat(" Server"), pair.getPublic());
|
|
||||||
certificateManager.serverKey = PrivateKeyFactory.createKey(pair.getPrivate().getEncoded());
|
|
||||||
certificateManager.writePrivateKey(serverKeyFile, pair.getPrivate());
|
|
||||||
certificateManager.writeCertificate(serverCertFile, certificateManager.server);
|
|
||||||
} catch (InvalidAlgorithmParameterException | NoSuchAlgorithmException | OperatorCreationException e) {
|
|
||||||
LogHelper.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
config.init(ReloadType.FULL);
|
config.init(ReloadType.FULL);
|
||||||
registerObject("launchServer", this);
|
registerObject("launchServer", this);
|
||||||
GarbageManager.registerNeedGC(sessionManager);
|
GarbageManager.registerNeedGC(sessionManager);
|
||||||
|
|
|
@ -73,8 +73,6 @@ public LaunchServerBuilder setLaunchServerConfigManager(LaunchServer.LaunchServe
|
||||||
}
|
}
|
||||||
|
|
||||||
public LaunchServer build() throws Exception {
|
public LaunchServer build() throws Exception {
|
||||||
//if(updatesDir == null) updatesDir = dir.resolve("updates");
|
|
||||||
//if(profilesDir == null) profilesDir = dir.resolve("profiles");
|
|
||||||
directories.collect();
|
directories.collect();
|
||||||
if (launchServerConfigManager == null) {
|
if (launchServerConfigManager == null) {
|
||||||
launchServerConfigManager = new LaunchServer.LaunchServerConfigManager() {
|
launchServerConfigManager = new LaunchServer.LaunchServerConfigManager() {
|
||||||
|
|
|
@ -75,9 +75,6 @@ public static void main(String[] args) throws Exception {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
//LauncherTrustManager.CheckMode mode = (Version.RELEASE == Version.Type.LTS || Version.RELEASE == Version.Type.STABLE) ?
|
|
||||||
// (allowUnsigned ? LauncherTrustManager.CheckMode.WARN_IN_NOT_SIGNED : LauncherTrustManager.CheckMode.EXCEPTION_IN_NOT_SIGNED) :
|
|
||||||
// (allowUnsigned ? LauncherTrustManager.CheckMode.NONE_IN_NOT_SIGNED : LauncherTrustManager.CheckMode.WARN_IN_NOT_SIGNED);
|
|
||||||
LauncherTrustManager.CheckClassResult result = certificateManager.checkClass(LaunchServer.class);
|
LauncherTrustManager.CheckClassResult result = certificateManager.checkClass(LaunchServer.class);
|
||||||
if(result.type == LauncherTrustManager.CheckClassResultType.SUCCESS) {
|
if(result.type == LauncherTrustManager.CheckClassResultType.SUCCESS) {
|
||||||
LogHelper.info("LaunchServer signed by %s", result.endCertificate.getSubjectDN().getName());
|
LogHelper.info("LaunchServer signed by %s", result.endCertificate.getSubjectDN().getName());
|
||||||
|
|
|
@ -23,7 +23,7 @@ public Map<String, Command> getCommands() {
|
||||||
Map<String, Command> commands = new HashMap<>();
|
Map<String, Command> commands = new HashMap<>();
|
||||||
commands.put("hardwarelist", new SubCommand() {
|
commands.put("hardwarelist", new SubCommand() {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) {
|
||||||
for (MemoryHWIDEntity e : db) {
|
for (MemoryHWIDEntity e : db) {
|
||||||
printHardwareInfo(LogHelper.Level.INFO, e.hardware);
|
printHardwareInfo(LogHelper.Level.INFO, e.hardware);
|
||||||
LogHelper.info("ID %d banned %s", e.id, e.banned ? "true" : "false");
|
LogHelper.info("ID %d banned %s", e.id, e.banned ? "true" : "false");
|
||||||
|
@ -74,7 +74,7 @@ public HardwareReportRequest.HardwareInfo findHardwareInfoByPublicKey(byte[] pub
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createHardwareInfo(HardwareReportRequest.HardwareInfo hardwareInfo, byte[] publicKey, Client client) throws HWIDException {
|
public void createHardwareInfo(HardwareReportRequest.HardwareInfo hardwareInfo, byte[] publicKey, Client client) {
|
||||||
db.add(new MemoryHWIDEntity(hardwareInfo, publicKey));
|
db.add(new MemoryHWIDEntity(hardwareInfo, publicKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public HardwareReportRequest.HardwareInfo findHardwareInfoByPublicKey(byte[] pub
|
||||||
if (set.next()) {
|
if (set.next()) {
|
||||||
if (set.getBoolean(11)) //isBanned
|
if (set.getBoolean(11)) //isBanned
|
||||||
{
|
{
|
||||||
throw new SecurityException("You HWID banned");
|
throw new HWIDException("You HWID banned");
|
||||||
}
|
}
|
||||||
long id = set.getLong(10);
|
long id = set.getLong(10);
|
||||||
setUserHardwareId(connection, client.username, id);
|
setUserHardwareId(connection, client.username, id);
|
||||||
|
@ -62,7 +62,7 @@ public HardwareReportRequest.HardwareInfo findHardwareInfoByPublicKey(byte[] pub
|
||||||
}
|
}
|
||||||
} catch (SQLException | IOException throwables) {
|
} catch (SQLException | IOException throwables) {
|
||||||
LogHelper.error(throwables);
|
LogHelper.error(throwables);
|
||||||
throw new SecurityException("SQL error. Please try again later");
|
throw new HWIDException("SQL error. Please try again later");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public void createHardwareInfo(HardwareReportRequest.HardwareInfo hardwareInfo,
|
||||||
}
|
}
|
||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
LogHelper.error(throwables);
|
LogHelper.error(throwables);
|
||||||
throw new SecurityException("SQL error. Please try again later");
|
throw new HWIDException("SQL error. Please try again later");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public boolean addPublicKeyToHardwareInfo(HardwareReportRequest.HardwareInfo har
|
||||||
if (result.compareLevel > criticalCompareLevel) {
|
if (result.compareLevel > criticalCompareLevel) {
|
||||||
if (set.getBoolean(11)) //isBanned
|
if (set.getBoolean(11)) //isBanned
|
||||||
{
|
{
|
||||||
throw new SecurityException("You HWID banned");
|
throw new HWIDException("You HWID banned");
|
||||||
}
|
}
|
||||||
writeHwidLog(connection, id, publicKey);
|
writeHwidLog(connection, id, publicKey);
|
||||||
changePublicKey(connection, id, publicKey);
|
changePublicKey(connection, id, publicKey);
|
||||||
|
@ -130,7 +130,7 @@ public boolean addPublicKeyToHardwareInfo(HardwareReportRequest.HardwareInfo har
|
||||||
}
|
}
|
||||||
} catch (SQLException | IOException throwables) {
|
} catch (SQLException | IOException throwables) {
|
||||||
LogHelper.error(throwables);
|
LogHelper.error(throwables);
|
||||||
throw new SecurityException("SQL error. Please try again later");
|
throw new HWIDException("SQL error. Please try again later");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import pro.gravit.launcher.Launcher;
|
import pro.gravit.launcher.Launcher;
|
||||||
import pro.gravit.launcher.NeedGarbageCollection;
|
import pro.gravit.launcher.NeedGarbageCollection;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.manangers.SessionManager;
|
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
|
@ -158,7 +157,7 @@ public void garbageCollection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws Exception {
|
public void close() {
|
||||||
if(autoDump) {
|
if(autoDump) {
|
||||||
garbageCollection();
|
garbageCollection();
|
||||||
dumpSessionsData();
|
dumpSessionsData();
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.utils.ProviderMap;
|
import pro.gravit.utils.ProviderMap;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public String getUsageDescription() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) {
|
||||||
server.pingServerManager.map.forEach((name, data) -> {
|
server.pingServerManager.map.forEach((name, data) -> {
|
||||||
LogHelper.info("[%s] online %d / %d", name, data.lastReport == null ? -1 : data.lastReport.playersOnline, data.lastReport == null ? -1 : data.lastReport.maxPlayers);
|
LogHelper.info("[%s] online %d / %d", name, data.lastReport == null ? -1 : data.lastReport.playersOnline, data.lastReport == null ? -1 : data.lastReport.maxPlayers);
|
||||||
if(data.lastReport != null && data.lastReport.users != null)
|
if(data.lastReport != null && data.lastReport.users != null)
|
||||||
|
|
|
@ -31,7 +31,7 @@ public String getUsageDescription() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) {
|
||||||
LaunchServerConfig config = server.config;
|
LaunchServerConfig config = server.config;
|
||||||
config.auth.forEach((name, pair) -> {
|
config.auth.forEach((name, pair) -> {
|
||||||
if (pair.provider instanceof AcceptAuthProvider) {
|
if (pair.provider instanceof AcceptAuthProvider) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ public void invoke(String... args) throws Exception {
|
||||||
if (!IOHelper.isDir(targetDir))
|
if (!IOHelper.isDir(targetDir))
|
||||||
throw new IllegalArgumentException(String.format("%s not directory", targetDir.toString()));
|
throw new IllegalArgumentException(String.format("%s not directory", targetDir.toString()));
|
||||||
Optional<SignJarTask> task = server.launcherBinary.getTaskByClass(SignJarTask.class);
|
Optional<SignJarTask> task = server.launcherBinary.getTaskByClass(SignJarTask.class);
|
||||||
if (!task.isPresent()) throw new IllegalStateException("SignJarTask not found");
|
if (task.isEmpty()) throw new IllegalStateException("SignJarTask not found");
|
||||||
IOHelper.walk(targetDir, new SignJarVisitor(task.get()), true);
|
IOHelper.walk(targetDir, new SignJarVisitor(task.get()), true);
|
||||||
LogHelper.info("Success signed");
|
LogHelper.info("Success signed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public void invoke(String... args) throws Exception {
|
||||||
tmpSign = server.dir.resolve("build").resolve(target.toFile().getName());
|
tmpSign = server.dir.resolve("build").resolve(target.toFile().getName());
|
||||||
LogHelper.info("Signing jar %s to %s", target.toString(), tmpSign.toString());
|
LogHelper.info("Signing jar %s to %s", target.toString(), tmpSign.toString());
|
||||||
Optional<SignJarTask> task = server.launcherBinary.getTaskByClass(SignJarTask.class);
|
Optional<SignJarTask> task = server.launcherBinary.getTaskByClass(SignJarTask.class);
|
||||||
if (!task.isPresent()) throw new IllegalStateException("SignJarTask not found");
|
if (task.isEmpty()) throw new IllegalStateException("SignJarTask not found");
|
||||||
task.get().sign(server.config.sign, target, tmpSign);
|
task.get().sign(server.config.sign, target, tmpSign);
|
||||||
if (args.length <= 1) {
|
if (args.length <= 1) {
|
||||||
LogHelper.info("Move temp jar %s to %s", tmpSign.toString(), target.toString());
|
LogHelper.info("Move temp jar %s to %s", tmpSign.toString(), target.toString());
|
||||||
|
|
|
@ -60,7 +60,7 @@ public Map<String, Command> getCommands() {
|
||||||
Map<String, Command> commands = new HashMap<>();
|
Map<String, Command> commands = new HashMap<>();
|
||||||
commands.put("getallusers", new SubCommand() {
|
commands.put("getallusers", new SubCommand() {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (User user : userDAO.findAll()) {
|
for (User user : userDAO.findAll()) {
|
||||||
LogHelper.subInfo("[%s] UUID: %s", user.getUsername(), user.getUuid().toString());
|
LogHelper.subInfo("[%s] UUID: %s", user.getUsername(), user.getUuid().toString());
|
||||||
|
@ -119,7 +119,7 @@ public void invoke(String... args) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws Exception {
|
public void close() {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ public HashingNonClosingOutputStream(OutputStream out, MessageDigest hasher) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,15 +119,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
|
||||||
targetConfig = Launcher.gsonManager.configGson.fromJson(reader, clazz);
|
targetConfig = Launcher.gsonManager.configGson.fromJson(reader, clazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Field[] fields = clazz.getFields();
|
|
||||||
//for (Field field : fields) {
|
|
||||||
// if ((field.getModifiers() & Modifier.STATIC) != 0) continue;
|
|
||||||
// Object obj = field.get(targetConfig);
|
|
||||||
// String configPropertyName = "modules.".concat(entity.moduleConfigName.toLowerCase()).concat(".").concat(field.getName().toLowerCase());
|
|
||||||
// if (entity.propertyMap == null) entity.propertyMap = new HashMap<>();
|
|
||||||
// LogHelper.dev("Property name %s", configPropertyName);
|
|
||||||
// entity.propertyMap.put(configPropertyName, obj);
|
|
||||||
//}
|
|
||||||
if (entity.propertyMap == null) entity.propertyMap = new HashMap<>();
|
if (entity.propertyMap == null) entity.propertyMap = new HashMap<>();
|
||||||
addClassFieldsToProperties(entity.propertyMap, "modules.".concat(entity.moduleConfigName.toLowerCase()), targetConfig, clazz);
|
addClassFieldsToProperties(entity.propertyMap, "modules.".concat(entity.moduleConfigName.toLowerCase()), targetConfig, clazz);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
|
@ -104,8 +104,6 @@ public static class Mirror {
|
||||||
boolean enabled;
|
boolean enabled;
|
||||||
|
|
||||||
Mirror(String url) {
|
Mirror(String url) {
|
||||||
//assetsURLMask = url.concat("assets/%s.zip");
|
|
||||||
//clientsURLMask = url.concat("clients/%s.zip");
|
|
||||||
baseUrl = url;
|
baseUrl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
import pro.gravit.launchserver.auth.RequiredDAO;
|
import pro.gravit.launchserver.auth.RequiredDAO;
|
||||||
import pro.gravit.launchserver.socket.Client;
|
import pro.gravit.launchserver.socket.Client;
|
||||||
import pro.gravit.utils.HookSet;
|
import pro.gravit.utils.HookSet;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,5 @@ public ChannelFuture bind(InetSocketAddress address) {
|
||||||
public void close() {
|
public void close() {
|
||||||
workerGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS);
|
workerGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS);
|
||||||
bossGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS);
|
bossGroup.shutdownGracefully(2, 5, TimeUnit.SECONDS);
|
||||||
//workerGroup.shutdownGracefully();
|
|
||||||
//bossGroup.shutdownGracefully();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,6 @@ public class WebSocketService {
|
||||||
public WebSocketService(ChannelGroup channels, LaunchServer server) {
|
public WebSocketService(ChannelGroup channels, LaunchServer server) {
|
||||||
this.channels = channels;
|
this.channels = channels;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
//this.gsonBuiler.registerTypeAdapter(WebSocketServerResponse.class, new JsonResponseAdapter(this));
|
|
||||||
//this.gsonBuiler.registerTypeAdapter(WebSocketEvent.class, new JsonResultSerializeAdapter());
|
|
||||||
//this.gsonBuiler.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter());
|
|
||||||
this.gson = Launcher.gsonManager.gson;
|
this.gson = Launcher.gsonManager.gson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +75,7 @@ public void forEachActiveChannels(BiConsumer<Channel, WebSocketFrameHandler> cal
|
||||||
WebSocketFrameHandler wsHandler = channel.pipeline().get(WebSocketFrameHandler.class);
|
WebSocketFrameHandler wsHandler = channel.pipeline().get(WebSocketFrameHandler.class);
|
||||||
if (wsHandler == null) continue;
|
if (wsHandler == null) continue;
|
||||||
callback.accept(channel, wsHandler);
|
callback.accept(channel, wsHandler);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerResponses() {
|
public static void registerResponses() {
|
||||||
|
|
|
@ -30,71 +30,10 @@ public void close() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
/*SSLContext sc = null;
|
|
||||||
try {
|
|
||||||
sc = SSLContextInit();
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (UnrecoverableKeyException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (KeyStoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (KeyManagementException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (CertificateException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}*/
|
|
||||||
//System.setProperty( "javax.net.ssl.keyStore","keystore");
|
|
||||||
//System.setProperty( "javax.net.ssl.keyStorePassword","PSP1000");
|
|
||||||
/*try {
|
|
||||||
Selector selector = Selector.open();
|
|
||||||
ServerSocketChannel serverChannel = ServerSocketChannel.open();
|
|
||||||
serverChannel.configureBlocking(false);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}*/
|
|
||||||
LogHelper.info("Starting netty server socket thread");
|
LogHelper.info("Starting netty server socket thread");
|
||||||
//SSLEngine engine = sc.createSSLEngine();
|
|
||||||
//engine.setUseClientMode(false);
|
|
||||||
nettyServer = new LauncherNettyServer(server);
|
nettyServer = new LauncherNettyServer(server);
|
||||||
for (LaunchServerConfig.NettyBindAddress address : server.config.netty.binds) {
|
for (LaunchServerConfig.NettyBindAddress address : server.config.netty.binds) {
|
||||||
nettyServer.bind(new InetSocketAddress(address.address, address.port));
|
nettyServer.bind(new InetSocketAddress(address.address, address.port));
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
try (SSLServerSocket serverSocket = (SSLServerSocket) ssf.createServerSocket()) {
|
|
||||||
serverSocket.setEnabledProtocols(new String[] {"TLSv1.2"});
|
|
||||||
if (!this.serverSocket.compareAndSet(null, serverSocket)) {
|
|
||||||
throw new IllegalStateException("Previous socket wasn't closed");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set socket params
|
|
||||||
serverSocket.setReuseAddress(true);
|
|
||||||
serverSocket.setPerformancePreferences(1, 0, 2);
|
|
||||||
//serverSocket.setReceiveBufferSize(0x10000);
|
|
||||||
serverSocket.bind(server.config.getSocketAddress());
|
|
||||||
LogHelper.info("Server socket thread successfully started");
|
|
||||||
// Listen for incoming connections
|
|
||||||
while (serverSocket.isBound()) {
|
|
||||||
SSLSocket socket = (SSLSocket) serverSocket.accept();
|
|
||||||
sockets.add(socket);
|
|
||||||
socket.startHandshake();
|
|
||||||
// Invoke pre-connect listener
|
|
||||||
long id = idCounter.incrementAndGet();
|
|
||||||
if (listener != null && !listener.onConnect(id, socket.getInetAddress())) {
|
|
||||||
continue; // Listener didn't accepted this connection
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reply in separate thread
|
|
||||||
threadPool.execute(new ResponseThread(server, id, socket));
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Ignore error after close/rebind
|
|
||||||
if (serverSocket.get() != null) {
|
|
||||||
LogHelper.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,9 +80,6 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
|
||||||
AuthProvider.authError(String.format("Illegal result: '%s'", aresult.username));
|
AuthProvider.authError(String.format("Illegal result: '%s'", aresult.username));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//if (clientData.profile == null) {
|
|
||||||
// throw new AuthException("You profile not found");
|
|
||||||
//}
|
|
||||||
server.authHookManager.postHook.hook(context, clientData);
|
server.authHookManager.postHook.hook(context, clientData);
|
||||||
clientData.isAuth = true;
|
clientData.isAuth = true;
|
||||||
clientData.permissions = aresult.permissions;
|
clientData.permissions = aresult.permissions;
|
||||||
|
|
|
@ -20,7 +20,7 @@ public String getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
if (username != null && (!client.isAuth || client.permissions == null || !client.permissions.isPermission(ClientPermissions.PermissionConsts.ADMIN))) {
|
if (username != null && (!client.isAuth || client.permissions == null || !client.permissions.isPermission(ClientPermissions.PermissionConsts.ADMIN))) {
|
||||||
sendError("Permissions denied");
|
sendError("Permissions denied");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -12,7 +12,7 @@ public String getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
sendResult(new FeaturesRequestEvent(server.featuresManager.getMap()));
|
sendResult(new FeaturesRequestEvent(server.featuresManager.getMap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public String getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
if (!client.isAuth || client.permissions == null || !client.permissions.isPermission(ClientPermissions.PermissionConsts.MANAGEMENT)) {
|
if (!client.isAuth || client.permissions == null || !client.permissions.isPermission(ClientPermissions.PermissionConsts.MANAGEMENT)) {
|
||||||
sendError("Access denied");
|
sendError("Access denied");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -20,7 +20,7 @@ public String getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
Map<String, PingServerReportRequest.PingServerReport> map = new HashMap<>();
|
Map<String, PingServerReportRequest.PingServerReport> map = new HashMap<>();
|
||||||
if (serverNames == null) {
|
if (serverNames == null) {
|
||||||
server.pingServerManager.map.forEach((name, entity) -> {
|
server.pingServerManager.map.forEach((name, entity) -> {
|
||||||
|
|
|
@ -13,7 +13,7 @@ public String getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
ServerStatusRequestEvent event = new ServerStatusRequestEvent(server.config.projectName);
|
ServerStatusRequestEvent event = new ServerStatusRequestEvent(server.config.projectName);
|
||||||
event.totalJavaMemory = JVMHelper.RUNTIME.totalMemory();
|
event.totalJavaMemory = JVMHelper.RUNTIME.totalMemory();
|
||||||
event.freeJavaMemory = JVMHelper.RUNTIME.freeMemory();
|
event.freeJavaMemory = JVMHelper.RUNTIME.freeMemory();
|
||||||
|
|
|
@ -13,7 +13,7 @@ public String getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
if (!(server.config.protectHandler instanceof SecureProtectHandler)) {
|
if (!(server.config.protectHandler instanceof SecureProtectHandler)) {
|
||||||
GetSecureLevelInfoRequestEvent response = new GetSecureLevelInfoRequestEvent(null);
|
GetSecureLevelInfoRequestEvent response = new GetSecureLevelInfoRequestEvent(null);
|
||||||
response.enabled = false;
|
response.enabled = false;
|
||||||
|
|
|
@ -16,7 +16,7 @@ public String getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
if (server.config.protectHandler instanceof HardwareProtectHandler) {
|
if (server.config.protectHandler instanceof HardwareProtectHandler) {
|
||||||
try {
|
try {
|
||||||
((HardwareProtectHandler) server.config.protectHandler).onHardwareReport(this, client);
|
((HardwareProtectHandler) server.config.protectHandler).onHardwareReport(this, client);
|
||||||
|
|
|
@ -20,7 +20,7 @@ public String getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
if (!(server.config.protectHandler instanceof SecureProtectHandler)) {
|
if (!(server.config.protectHandler instanceof SecureProtectHandler)) {
|
||||||
sendError("Method not allowed");
|
sendError("Method not allowed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ public String getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
if (!(server.config.protectHandler instanceof SecureProtectHandler) || client.trustLevel == null || client.trustLevel.verifySecureKey == null) {
|
if (!(server.config.protectHandler instanceof SecureProtectHandler) || client.trustLevel == null || client.trustLevel.verifySecureKey == null) {
|
||||||
sendError("This method not allowed");
|
sendError("This method not allowed");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -136,7 +136,9 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
||||||
}
|
}
|
||||||
args.add(MAGIC_ARG);
|
args.add(MAGIC_ARG);
|
||||||
args.add("-XX:+DisableAttachMechanism");
|
args.add("-XX:+DisableAttachMechanism");
|
||||||
args.add("-Xmx256M");
|
if(launcherMemoryLimit != 0) {
|
||||||
|
args.add(String.format("-Xmx%dM", launcherMemoryLimit));
|
||||||
|
}
|
||||||
//Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
//Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
||||||
args.add("-cp");
|
args.add("-cp");
|
||||||
args.add(pathLauncher);
|
args.add(pathLauncher);
|
||||||
|
|
Loading…
Reference in a new issue