Finalmask: Fix panic when udpHop or xicmp fails; Restore udpHop's default interval (#6808)

https://github.com/XTLS/Xray-core/pull/6808#pullrequestreview-5324529175

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
Esko Mobius
2026-09-27 22:17:47 +00:00
committed by RPRX
co-authored by 风扇滑翔翼
parent 2953d44734
commit 7780db9bbe
2 changed files with 14 additions and 6 deletions
+9 -2
View File
@@ -942,12 +942,19 @@ func (c *UDPHop) Build() (proto.Message, error) {
}
return nil, errors.New("invalid ip ", ip)
}
interval := c.Interval
if interval.From == 0 && interval.To == 0 {
interval.From, interval.To = 30, 30
}
if interval.From < 5 {
return nil, errors.New("interval must be at least 5")
}
return &udphop.Config{
Local: local,
Remote: remote,
RemoteOnce: remoteOnce,
IntervalMin: int64(c.Interval.From),
IntervalMax: int64(c.Interval.To),
IntervalMin: int64(interval.From),
IntervalMax: int64(interval.To),
RemoteIPs: remoteIPs,
RemotePorts: c.RemotePorts.Build().Ports(),
}, nil
+5 -4
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"slices"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/net"
@@ -88,7 +89,7 @@ func (fm *FinalMask) DialTCP(ctx context.Context, dest net.Destination) (net.Con
var newConn net.Conn
newConn, err = fm.tcpMasks[i].WrapConnClient(conn, &dest, dialer)
if err != nil {
_ = conn.Close()
common.CloseIfExists(conn)
return nil, err
}
conn = newConn
@@ -193,7 +194,7 @@ func (fm *FinalMask) DialUDP(ctx context.Context, dest net.Destination) (net.Con
}
newConn, err = fm.udpMasks[i].WrapPacketConnClient(conn, &dest, dialer)
if err != nil {
_ = conn.Close()
common.CloseIfExists(conn)
return nil, err
}
conn = newConn
@@ -240,7 +241,7 @@ func (fm *FinalMask) ListenPacket(ctx context.Context, addr net.Addr) (net.Packe
if _, ok := fm.udpMasks[i].(interface{ HeaderConn() }); ok {
newConn, err = fm.udpMasks[i].WrapPacketConnServer(nil, nil, nil)
if err != nil {
_ = conn.Close()
common.CloseIfExists(conn)
return nil, err
}
sizes = append(sizes, newConn.(interface{ Size() int }).Size())
@@ -253,7 +254,7 @@ func (fm *FinalMask) ListenPacket(ctx context.Context, addr net.Addr) (net.Packe
}
newConn, err = fm.udpMasks[i].WrapPacketConnServer(conn, addr, lc)
if err != nil {
_ = conn.Close()
common.CloseIfExists(conn)
return nil, err
}
conn = newConn