Skip to content

Commit

Permalink
Demote connection breakage from error to warning
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvanzijst committed Aug 19, 2021
1 parent af688d5 commit 4ea7c31
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name := "scala-tlsproxy"
organization := "io.github.erikvanzijst"

version := "0.3.0-SNAPSHOT"
version := "0.3.0"

scalaVersion := "2.12.14"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 4ea7c31

Please sign in to comment.