You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// SOCKS does not include a length in the header, so take
// a punt that each request will be readable in one go.
buf := make([]byte, 256)
n, err := local_reader.Read(buf)
if err != nil || n < 2 {
//log.Printf("[%s] unable to read SOCKS header: %v", local.RemoteAddr(), err)
return fmt.Errorf("[%s] unable to read SOCKS header: %v", local.RemoteAddr(), err)
}
buf = buf[:n]
.......
see http://golang.org/pkg/bufio/#Reader.Read
It calls Read at most once on the underlying Reader, hence n may be less than len(p).
if local_reader.Read(buf) return 4 bytes, it may fall, is it?
The text was updated successfully, but these errors were encountered:
Theoretically, it may fail. But in reality, the header part is sent by client at once after connected, Server have very little chance that read less data than such a few bytes.
func ServConn(local_reader *bufio.Reader, local *net.TCPConn, dialer Dialer) error {
connections.Add(1)
defer local.Close()
defer connections.Done()
.......
see http://golang.org/pkg/bufio/#Reader.Read
It calls Read at most once on the underlying Reader, hence n may be less than len(p).
if local_reader.Read(buf) return 4 bytes, it may fall, is it?
The text was updated successfully, but these errors were encountered: