From e2c7b455d2d6af9c0af73fdcd8c31b096f0a0e86 Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 29 Jan 2019 22:38:23 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=9D=D0=B0=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B9=D0=BA=D0=B0=20Netty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launchserver/LaunchServer.java | 6 ++++++ .../java/ru/gravit/launchserver/binary/JAConfigurator.java | 6 ++++++ .../ru/gravit/launchserver/binary/tasks/MainBuildTask.java | 2 ++ .../launchserver/socket/NettyServerSocketHandler.java | 2 +- .../src/main/java/ru/gravit/launcher/AutogenConfig.java | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index f1552b8d..8e0be32d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -86,6 +86,7 @@ public static final class Config { public int threadCoreCount; public ExeConf launch4j; + public NettyConfig netty; public boolean compress; @@ -178,6 +179,11 @@ public static class ExeConf { public String txtFileVersion; public String txtProductVersion; } + public class NettyConfig + { + public String bindAddress; + public int port; + } private final class ProfilesFileVisitor extends SimpleFileVisitor { private final Collection result; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java index cf300df7..71673a44 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java @@ -89,6 +89,12 @@ public void setPort(int port) { body.append(";"); } + public void setNettyPort(int port) { + body.append("this.nettyPort = "); + body.append(port); + body.append(";"); + } + public void setEnv(LauncherConfig.LauncherEnvironment env) { int i = 2; switch (env) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java index 5acbad06..aefe45f6 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -130,6 +130,8 @@ public Path process(Path inputJar) throws IOException { server.buildHookManager.hook(context); jaConfigurator.setAddress(server.config.getAddress()); jaConfigurator.setPort(server.config.port); + if(server.config.netty != null) + jaConfigurator.setNettyPort(server.config.netty.port); jaConfigurator.setProjectName(server.config.projectName); jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey()); jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512)); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java index 9e4542c8..3b243156 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java @@ -148,7 +148,7 @@ public void initChannel(NioSocketChannel ch) { pipeline.addLast(new WebSocketFrameHandler()); } }); - ChannelFuture f = b.bind(new InetSocketAddress(9876)).sync(); //TEST ONLY! + ChannelFuture f = b.bind(new InetSocketAddress(LaunchServer.server.config.netty.port)).sync(); //TEST ONLY! f.channel().closeFuture().sync(); } catch (InterruptedException e) { e.printStackTrace(); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java index aa64bb0b..b1c131fa 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java @@ -4,6 +4,7 @@ public class AutogenConfig { public String projectname; public String address; public int port; + public int nettyPort; public int clientPort; @SuppressWarnings("unused") private boolean isInitModules;