diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java index 30972bed..edb653fa 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java @@ -28,7 +28,7 @@ public void invoke(String... args) throws Exception { if (handler == null) handler = new NettyServerSocketHandler(server); if (args[0].equals("start")) { - CommonHelper.newThread("Netty Server",true,handler); + CommonHelper.newThread("Netty Server",true,handler).start(); } if (args[0].equals("stop")) { handler.close(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileInitializer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileInitializer.java deleted file mode 100644 index 8aa9ea0d..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileInitializer.java +++ /dev/null @@ -1,42 +0,0 @@ -package ru.gravit.launchserver.fileserver; - -import java.io.File; - -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.socket.SocketChannel; -import io.netty.handler.codec.http.HttpObjectAggregator; -import io.netty.handler.codec.http.HttpServerCodec; -import io.netty.handler.ssl.SslContext; -import io.netty.handler.stream.ChunkedWriteHandler; - -public class FileInitializer extends ChannelInitializer { - - private final SslContext sslCtx; - private final File base; - private final boolean outDirs; - - public FileInitializer(SslContext sslCtx, File base, boolean outDirs) { - this.sslCtx = sslCtx; - this.base = base; - this.outDirs = outDirs; - } - - public FileInitializer(File base, boolean outDirs) { - this.sslCtx = null; - this.base = base; - this.outDirs = outDirs; - } - - @Override - public void initChannel(SocketChannel ch) { - ChannelPipeline pipeline = ch.pipeline(); - if (sslCtx != null) { - pipeline.addLast(sslCtx.newHandler(ch.alloc())); - } - pipeline.addLast(new HttpServerCodec()); - pipeline.addLast(new HttpObjectAggregator(65536)); - pipeline.addLast(new ChunkedWriteHandler()); - pipeline.addLast(new FileServerHandler(base, outDirs)); - } -} 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 fb289908..11922c3c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java @@ -19,6 +19,7 @@ import ru.gravit.launcher.ssl.LauncherKeyStore; import ru.gravit.launcher.ssl.LauncherTrustManager; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.fileserver.FileServerHandler; import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.socket.websocket.WebSocketFrameHandler; import ru.gravit.launchserver.socket.websocket.WebSocketIndexPageHandler; @@ -142,7 +143,7 @@ public void initChannel(NioSocketChannel ch) { pipeline.addLast(new HttpObjectAggregator(65536)); pipeline.addLast(new WebSocketServerCompressionHandler()); pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true)); - pipeline.addLast(new WebSocketIndexPageHandler(WEBSOCKET_PATH)); + pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir,true)); pipeline.addLast(new WebSocketFrameHandler()); } });