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)