From 3b3dc129186db3123e8f62ef4f75fe476192de0c Mon Sep 17 00:00:00 2001 From: dingjun Date: Mon, 6 Jul 2020 19:57:21 +0800 Subject: [PATCH] add debug log --- server.go | 2 +- tcp_server.go | 2 ++ ws_server.go | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index ee37215..52a5b50 100644 --- a/server.go +++ b/server.go @@ -72,7 +72,7 @@ func forwardWS2TCP(conn1 *websocket.Conn, conn2 net.Conn) { for { n, err := conn2.Read(buf) - if err != nil { + if err != nil && err != io.EOF { log.Errorln(err) break } diff --git a/tcp_server.go b/tcp_server.go index 67ca5b1..946c425 100644 --- a/tcp_server.go +++ b/tcp_server.go @@ -36,6 +36,8 @@ func (srv *tcpServer) serve(c net.Conn) { u, _ := url.Parse(srv.remote) + log.Debugf("connected from %s, forward to %s", c.RemoteAddr(), srv.remote) + if u.Scheme == "ws" || u.Scheme == "wss" { conn1, resp, err := dialer.Dial(srv.remote, nil) if err != nil { diff --git a/ws_server.go b/ws_server.go index 6cf2ee1..7d81f6b 100644 --- a/ws_server.go +++ b/ws_server.go @@ -46,6 +46,8 @@ func (wss *wsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + log.Debugf("request %s, forward to %s", p, remote) + conn, err := upgrader.Upgrade(w, r, nil) if err != nil { log.Errorln(err)