From e1a5392bebb1712d691bf5e12e57df297e6d4068 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+rprx@users.noreply.github.com> Date: Sat, 6 Mar 2021 07:19:09 +0000 Subject: [PATCH] Use buf.PacketReader when UDPOverride is available --- proxy/freedom/freedom.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 95ba4fdc..7117930b 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -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)) }