Skip to content

Commit

Permalink
remove log
Browse files Browse the repository at this point in the history
  • Loading branch information
ginuerzh committed Feb 28, 2020
1 parent ee8b5d5 commit b2d5319
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,23 @@ func (c *relayConn) Read(b []byte) (n int, err error) {
resp := new(relay.Response)
_, err = resp.ReadFrom(c.Conn)
if err != nil {
log.Log("[relay] read:", err)
return
}
if resp.Version != relay.Version1 {
err = relay.ErrBadVersion
log.Log("[relay] read:", err)
return
}
if resp.Status != relay.StatusOK {
err = fmt.Errorf("status %d", resp.Status)
log.Log("[relay] read:", err)
return
}
log.Log("[relay] read response OK")
})

if err != nil {
log.Log("[relay] %s <- %s: %s", c.Conn.LocalAddr(), c.Conn.RemoteAddr(), err)
return
}

if !c.udp {
return c.Conn.Read(b)
}
Expand All @@ -296,7 +297,6 @@ func (c *relayConn) Read(b []byte) (n int, err error) {
return
}
dlen := int(binary.BigEndian.Uint16(bb[:]))
log.Log("[relay] read udp", dlen)
if len(b) >= dlen {
return io.ReadFull(c.Conn, b[:dlen])
}
Expand Down Expand Up @@ -325,7 +325,6 @@ func (c *relayConn) Write(b []byte) (n int, err error) {
c.wbuf.Write(bb[:])
}
c.wbuf.Write(b) // append the data to the cached header
log.Log("[relay] write wbuf", len(b))
// _, err = c.Conn.Write(c.wbuf.Bytes())
// c.wbuf.Reset()
_, err = c.wbuf.WriteTo(c.Conn)
Expand All @@ -339,7 +338,6 @@ func (c *relayConn) Write(b []byte) (n int, err error) {
binary.BigEndian.PutUint16(buf[:2], uint16(len(b)))
n = copy(buf[2:], b)
_, err = c.Conn.Write(buf)
log.Log("[relay] write", n)
return
}

Expand Down

0 comments on commit b2d5319

Please sign in to comment.