mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-04 16:37:12 -05:00
allow multiple UDP incoming packets in freedom
This commit is contained in:
parent
d3ff2b3698
commit
3b1f92b7e8
@ -16,7 +16,7 @@ type TimeOutReader struct {
|
|||||||
worker io.Reader
|
worker io.Reader
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTimeOutReader(timeout int, connection net.Conn) *TimeOutReader {
|
func NewTimeOutReader(timeout int /* seconds */, connection net.Conn) *TimeOutReader {
|
||||||
reader := &TimeOutReader{
|
reader := &TimeOutReader{
|
||||||
connection: connection,
|
connection: connection,
|
||||||
timeout: -100,
|
timeout: -100,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package freedom
|
package freedom
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -58,21 +59,14 @@ func (this *FreedomConnection) Dispatch(firstPacket v2net.Packet, ray ray.Outbou
|
|||||||
defer readMutex.Unlock()
|
defer readMutex.Unlock()
|
||||||
defer close(output)
|
defer close(output)
|
||||||
|
|
||||||
response, err := v2io.ReadFrom(conn, nil)
|
var reader io.Reader
|
||||||
log.Info("Freedom receives ", response.Len(), " bytes from ", conn.RemoteAddr())
|
reader = conn
|
||||||
if response.Len() > 0 {
|
|
||||||
output <- response
|
|
||||||
} else {
|
|
||||||
response.Release()
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if firstPacket.Destination().IsUDP() {
|
if firstPacket.Destination().IsUDP() {
|
||||||
return
|
reader = v2net.NewTimeOutReader(4 /* seconds */, conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
v2io.RawReaderToChan(output, conn)
|
v2io.RawReaderToChan(output, reader)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
writeMutex.Lock()
|
writeMutex.Lock()
|
||||||
|
Loading…
Reference in New Issue
Block a user