Skip to content
This repository has been archived by the owner on Apr 3, 2021. It is now read-only.

Commit

Permalink
ignore unknown data read from tcp conn
Browse files Browse the repository at this point in the history
  • Loading branch information
eycorsican committed Nov 20, 2018
1 parent 286aef5 commit c24548e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions proxy/socks/udp.go
Expand Up @@ -39,10 +39,21 @@ func NewUDPHandler(proxyHost string, proxyPort uint16, timeout time.Duration) co
}

func (h *udpHandler) handleTCP(conn core.Connection, c net.Conn) {
var buf = make([]byte, 1)
c.SetDeadline(time.Time{})
c.Read(buf)
h.Close(conn)
buf := core.NewBytes(core.BufSize)
defer core.FreeBytes(buf)

for {
c.SetDeadline(time.Time{})
_, err := c.Read(buf)
if err == io.EOF {
h.Close(conn)
return
} else if err != nil {
log.Printf("failed to handle TCP connection for UDP associate request: %v", err)
h.Close(conn)
return
}
}
}

func (h *udpHandler) fetchUDPInput(conn core.Connection, input net.Conn) {
Expand Down

0 comments on commit c24548e

Please sign in to comment.