diff --git a/common/net/timed_io.go b/common/net/timed_io.go index 63c310e6..5415c781 100644 --- a/common/net/timed_io.go +++ b/common/net/timed_io.go @@ -16,7 +16,7 @@ type TimeOutReader struct { worker io.Reader } -func NewTimeOutReader(timeout int, connection net.Conn) *TimeOutReader { +func NewTimeOutReader(timeout int /* seconds */, connection net.Conn) *TimeOutReader { reader := &TimeOutReader{ connection: connection, timeout: -100, diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index dfe3f7a2..31c9fcec 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -1,6 +1,7 @@ package freedom import ( + "io" "net" "sync" @@ -58,21 +59,14 @@ func (this *FreedomConnection) Dispatch(firstPacket v2net.Packet, ray ray.Outbou defer readMutex.Unlock() defer close(output) - response, err := v2io.ReadFrom(conn, nil) - log.Info("Freedom receives ", response.Len(), " bytes from ", conn.RemoteAddr()) - if response.Len() > 0 { - output <- response - } else { - response.Release() - } - if err != nil { - return - } + var reader io.Reader + reader = conn + if firstPacket.Destination().IsUDP() { - return + reader = v2net.NewTimeOutReader(4 /* seconds */, conn) } - v2io.RawReaderToChan(output, conn) + v2io.RawReaderToChan(output, reader) }() writeMutex.Lock()