mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-24 20:33:33 +02:00
Use buf.PacketReader when UDPOverride is available
This commit is contained in:
parent
24f564b401
commit
e1a5392beb
1 changed files with 1 additions and 9 deletions
|
@ -195,11 +195,10 @@ func NewPacketReader(conn net.Conn, UDPOverride net.Destination) buf.Reader {
|
|||
if statConn != nil {
|
||||
counter = statConn.ReadCounter
|
||||
}
|
||||
if c, ok := iConn.(*internet.PacketConnWrapper); ok {
|
||||
if c, ok := iConn.(*internet.PacketConnWrapper); ok && UDPOverride.Address == nil && UDPOverride.Port == 0 {
|
||||
return &PacketReader{
|
||||
PacketConnWrapper: c,
|
||||
Counter: counter,
|
||||
UDPOverride: UDPOverride,
|
||||
}
|
||||
}
|
||||
return &buf.PacketReader{Reader: conn}
|
||||
|
@ -208,7 +207,6 @@ func NewPacketReader(conn net.Conn, UDPOverride net.Destination) buf.Reader {
|
|||
type PacketReader struct {
|
||||
*internet.PacketConnWrapper
|
||||
stats.Counter
|
||||
UDPOverride net.Destination
|
||||
}
|
||||
|
||||
func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
||||
|
@ -225,12 +223,6 @@ func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
|||
Port: net.Port(d.(*net.UDPAddr).Port),
|
||||
Network: net.Network_UDP,
|
||||
}
|
||||
if r.UDPOverride.Address != nil {
|
||||
b.UDP.Address = r.UDPOverride.Address
|
||||
}
|
||||
if r.UDPOverride.Port != 0 {
|
||||
b.UDP.Port = r.UDPOverride.Port
|
||||
}
|
||||
if r.Counter != nil {
|
||||
r.Counter.Add(int64(n))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue