From 4ea7c312a8ad3f0b89d4d2ec0f5f502198612fd0 Mon Sep 17 00:00:00 2001 From: Erik van Zijst Date: Thu, 19 Aug 2021 15:38:36 +0200 Subject: [PATCH] Demote connection breakage from error to warning --- README.md | 2 +- build.sbt | 2 +- .../erikvanzijst/scalatlsproxy/TlsProxyHandler.scala | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index edc5cb4..4225c13 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ The project is published to Sonatype OSS: sbt users may add this to their `build.sbt`: ``` -libraryDependencies += "io.github.erikvanzijst" %% "scala-tlsproxy_2.12" % "0.2.0" +libraryDependencies += "io.github.erikvanzijst" % "scala-tlsproxy_2.12" % "0.3.0" ``` To use it as a library in-process: diff --git a/build.sbt b/build.sbt index 95cee05..fb2528e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ name := "scala-tlsproxy" organization := "io.github.erikvanzijst" -version := "0.3.0-SNAPSHOT" +version := "0.3.0" scalaVersion := "2.12.14" diff --git a/src/main/scala/io/github/erikvanzijst/scalatlsproxy/TlsProxyHandler.scala b/src/main/scala/io/github/erikvanzijst/scalatlsproxy/TlsProxyHandler.scala index 356d9df..38bd327 100644 --- a/src/main/scala/io/github/erikvanzijst/scalatlsproxy/TlsProxyHandler.scala +++ b/src/main/scala/io/github/erikvanzijst/scalatlsproxy/TlsProxyHandler.scala @@ -19,7 +19,7 @@ object ProxyPhase extends Enumeration { object TlsProxyHandler { val destPattern: Regex = "CONNECT ([^:]+):([0-9]+) HTTP/1.1".r - val userAgent: String = "TlsProxy/1.0 (github.com/erikvanzijst/scala_tlsproxy)" + val userAgent: String = "TlsProxy/0.3.0 (github.com/erikvanzijst/scala_tlsproxy)" } class TlsProxyHandler(selector: Selector, clientChannel: SocketChannel) extends KeyHandler with StrictLogging { @@ -54,7 +54,7 @@ class TlsProxyHandler(selector: Selector, clientChannel: SocketChannel) extends private def readClient(): Unit = { if (clientKey.isValid && clientKey.isReadable && clientChannel.read(clientBuffer) == -1) - throw new IOException(s"$clientAddress unexpected EOF from client") + throw new IOException(s"$clientAddress unexpected EOF from client") if (!clientBuffer.hasRemaining) throw new IOException(s"$clientAddress handshake overflow") } @@ -183,11 +183,10 @@ class TlsProxyHandler(selector: Selector, clientChannel: SocketChannel) extends } catch { case e: IOException => - val msg = s"$clientAddress -> $getServerAddress" + (if (phase == Established) s" (up: ${upstreamPipe.bytes} down: ${downstreamPipe.bytes})" else "") + s" connection failed: ${e.getClass.getSimpleName}: ${e.getMessage}" - logger.error(msg) + logger.warn(msg) close() }