From a09a7c8cf60543d6a91f1e3fb5c296ec5710f664 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 29 Aug 2019 16:19:33 +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=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F/=D0=B2=D1=8B=D0=BA=D0=BB=D1=8E=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=BA=D1=80=D1=8B=D1=82=D1=8B?= =?UTF-8?q?=D1=85=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D1=81=D0=BA=D0=B0=D1=87=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/config/LaunchServerConfig.java | 1 + .../launchserver/socket/LauncherNettyServer.java | 2 +- .../handlers/fileserver/FileServerHandler.java | 12 +++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) 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 80ad1675..dae1f39b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -254,6 +254,7 @@ public static class NettyConfig { public boolean fileServerEnabled; public boolean sendExceptionEnabled; public boolean ipForwarding; + public boolean showHiddenFiles; public String launcherURL; public String downloadURL; public String launcherEXEURL; 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 b1ab80b7..e95fa544 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java @@ -63,7 +63,7 @@ public void initChannel(SocketChannel ch) { pipeline.addLast(new WebSocketServerCompressionHandler()); pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true)); if (server.config.netty.fileServerEnabled) - pipeline.addLast(new FileServerHandler(server.updatesDir, true)); + pipeline.addLast(new FileServerHandler(server.updatesDir, true, config.showHiddenFiles)); pipeline.addLast(new WebSocketFrameHandler(context, server, service)); pipelineHook.hook(context, ch); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java index b6deb6e3..ff3e6b19 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java @@ -58,10 +58,12 @@ public class FileServerHandler extends SimpleChannelInboundHandler&\\\"]*"); - private static void sendListing(ChannelHandlerContext ctx, File dir, String dirPath) { + private static void sendListing(ChannelHandlerContext ctx, File dir, String dirPath, boolean showHidden) { FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK); response.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/html; charset=UTF-8"); @@ -201,7 +203,7 @@ private static void sendListing(ChannelHandlerContext ctx, File dir, String dirP .append("
  • ..
  • \r\n"); for (File f : dir.listFiles()) { - if (f.isHidden() || !f.canRead()) { + if (( f.isHidden() && !showHidden) || !f.canRead()) { continue; }