diff --git a/proxy/https.go b/proxy/https.go index 0f5b0fb..c8776f6 100644 --- a/proxy/https.go +++ b/proxy/https.go @@ -2,7 +2,6 @@ package proxy import ( "fmt" - "io" "net" // "time" @@ -26,13 +25,7 @@ func HandleHttps(clientConn net.Conn, ip string) { for { buf, err := util.ReadMessage(remoteConn) if err != nil { - if err != io.EOF { - util.Debug("Error reading from the server:", err) - } else { - util.Debug("Remote connection Closed: ", err) - } - - util.Debug("Closing connection: ", remoteConn.RemoteAddr()) + util.Debug("Error reading from the server", err, " Closing connection ", remoteConn.RemoteAddr()) return } @@ -40,7 +33,7 @@ func HandleHttps(clientConn net.Conn, ip string) { _, write_err := clientConn.Write(buf) if write_err != nil { - util.Debug("Error writing to client:", write_err) + util.Debug("Error sending data to the client:", write_err) return } } @@ -51,17 +44,12 @@ func HandleHttps(clientConn net.Conn, ip string) { clientHello, err := util.ReadMessage(clientConn) if err != nil { - if err != io.EOF { - util.Debug("Error reading from the client:", err) - } else { - util.Debug("Client connection Closed: ", err) - } - - util.Debug("Closing connection: ", clientConn.RemoteAddr()) + util.Debug("Error reading client hello", err, " Closing connection ", clientConn.RemoteAddr()) } + util.Debug(clientConn.RemoteAddr(), "Client sent hello", len(clientHello)) - chunks, err := util.SplitSliceInChunks(clientHello, config.GetConfig().MTU) + chunks, err := util.SplitInChunks(clientHello, config.GetConfig().MTU) if err != nil { util.Debug("Error chunking client hello: ", err) } @@ -77,15 +65,10 @@ func HandleHttps(clientConn net.Conn, ip string) { for { buf, err := util.ReadMessage(clientConn) if err != nil { - if err != io.EOF { - util.Debug("Error reading from the client:", err) - } else { - util.Debug("Client connection Closed: ", err) - } - - util.Debug("Closing connection: ", clientConn.RemoteAddr()) + util.Debug("Error reading from the client", err, " Closing connection ", clientConn.RemoteAddr()) break } + util.Debug(clientConn.RemoteAddr(), "Client sent data", len(buf)) _, write_err := remoteConn.Write(buf) diff --git a/util/util.go b/util/util.go index 693cf3a..54a9f95 100644 --- a/util/util.go +++ b/util/util.go @@ -109,7 +109,7 @@ func ExtractMethod(message *[]byte) (string) { return strings.ToUpper(method) } -func SplitSliceInChunks(a []byte, size int) ([][]byte, error) { +func SplitInChunks(a []byte, size int) ([][]byte, error) { if size < 1 { return nil, errors.New("chuckSize must be greater than zero") }