From 8d4f942662c0db9f4ca65e709058232e8c0cfe4a Mon Sep 17 00:00:00 2001 From: "alikemal.ocalan" Date: Tue, 2 Feb 2021 20:07:15 +0300 Subject: [PATCH] Upgrade 2.5-SNAPSHOT --- Dockerfile | 2 +- gradle.properties | 2 +- .../handler/ProxyClientHandler.kt | 25 ++++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index a024660..b9505aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,5 +10,5 @@ WORKDIR /bin/runner RUN rm -rf /src #-XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -CMD ["java","-XX:MaxRAMPercentage=45", "-XshowSettings:vm","-Dio.netty.tryReflectionSetAccessible=true","--illegal-access=warn","--add-opens","java.base/jdk.internal.misc=ALL-UNNAMED","-cp","greentunnel4jvm.jar","com.github.alikemalocalan.greentunnel4jvm.HttpProxyServerKt"] +CMD ["java","-XX:MaxRAMPercentage=45", "-XshowSettings:vm","-Dio.netty.tryReflectionSetAccessible=true","--illegal-access=warn","--add-opens","java.base/jdk.internal.misc=ALL-UNNAMED","-cp","greentunnel4jvm.jar","com.github.alikemalocalan.greentunnel4jvm.ProxyServerKt"] EXPOSE 8080 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4de6bfd..314e86f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,5 +2,5 @@ kotlin.code.style=official kotlin_version=1.4.21-2 projectGroup=com.github.alikemalocalan projectName=greentunnel4jvm -projectVersion=2.4-SNAPSHOT +projectVersion=2.5-SNAPSHOT projectMainClassName=com.github.alikemalocalan.greentunnel4jvm.gui.Gui \ No newline at end of file diff --git a/src/main/kotlin/com/github/alikemalocalan/greentunnel4jvm/handler/ProxyClientHandler.kt b/src/main/kotlin/com/github/alikemalocalan/greentunnel4jvm/handler/ProxyClientHandler.kt index cabac66..a26bc54 100644 --- a/src/main/kotlin/com/github/alikemalocalan/greentunnel4jvm/handler/ProxyClientHandler.kt +++ b/src/main/kotlin/com/github/alikemalocalan/greentunnel4jvm/handler/ProxyClientHandler.kt @@ -55,19 +55,20 @@ class ProxyClientHandler : ChannelInboundHandlerAdapter() { ctx: ChannelHandlerContext, request: HttpRequest ): Optional = - kotlin.runCatching { request.toInetSocketAddress() }.fold(onSuccess = { remoteAddress -> - val remoteFuture = bootstrap - .group(ctx.channel().eventLoop()) // use the same EventLoop - .handler(ProxyRemoteHandler(ctx, request)) - .connect(remoteAddress) - - ctx.channel().config().isAutoRead = false // if remote connection has done, stop reading - remoteFuture.addListener { - ctx.channel().config().isAutoRead = true // connection is ready, enable AutoRead - } + kotlin.runCatching { request.toInetSocketAddress() } + .fold(onSuccess = { remoteAddress -> + val remoteFuture = bootstrap + .group(ctx.channel().eventLoop()) // use the same EventLoop + .handler(ProxyRemoteHandler(ctx, request)) + .connect(remoteAddress) + + ctx.channel().config().isAutoRead = false // if remote connection has done, stop reading + remoteFuture.addListener { + ctx.channel().config().isAutoRead = true // connection is ready, enable AutoRead + } - return Optional.of(remoteFuture.channel()) - }, onFailure = { return Optional.empty() }) + return Optional.of(remoteFuture.channel()) + }, onFailure = { return Optional.empty() }) override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) {