mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
fix: Disable XUDP global ID if source address invalid
This commit is contained in:
parent
65cff13bd8
commit
b183183fbc
|
@ -374,9 +374,13 @@ func (v *Vless) ListenPacketOnStreamConn(ctx context.Context, c net.Conn, metada
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.option.XUDP {
|
if v.option.XUDP {
|
||||||
|
var globalID [8]byte
|
||||||
|
if metadata.SourceValid() {
|
||||||
|
globalID = utils.GlobalID(metadata.SourceAddress())
|
||||||
|
}
|
||||||
return newPacketConn(N.NewThreadSafePacketConn(
|
return newPacketConn(N.NewThreadSafePacketConn(
|
||||||
vmessSing.NewXUDPConn(c,
|
vmessSing.NewXUDPConn(c,
|
||||||
utils.GlobalID(metadata.SourceAddress()),
|
globalID,
|
||||||
M.SocksaddrFromNet(metadata.UDPAddr())),
|
M.SocksaddrFromNet(metadata.UDPAddr())),
|
||||||
), v), nil
|
), v), nil
|
||||||
} else if v.option.PacketAddr {
|
} else if v.option.PacketAddr {
|
||||||
|
|
|
@ -224,13 +224,17 @@ func (v *Vmess) StreamConnContext(ctx context.Context, c net.Conn, metadata *C.M
|
||||||
func (v *Vmess) streamConn(c net.Conn, metadata *C.Metadata) (conn net.Conn, err error) {
|
func (v *Vmess) streamConn(c net.Conn, metadata *C.Metadata) (conn net.Conn, err error) {
|
||||||
if metadata.NetWork == C.UDP {
|
if metadata.NetWork == C.UDP {
|
||||||
if v.option.XUDP {
|
if v.option.XUDP {
|
||||||
|
var globalID [8]byte
|
||||||
|
if metadata.SourceValid() {
|
||||||
|
globalID = utils.GlobalID(metadata.SourceAddress())
|
||||||
|
}
|
||||||
if N.NeedHandshake(c) {
|
if N.NeedHandshake(c) {
|
||||||
conn = v.client.DialEarlyXUDPPacketConn(c,
|
conn = v.client.DialEarlyXUDPPacketConn(c,
|
||||||
utils.GlobalID(metadata.SourceAddress()),
|
globalID,
|
||||||
M.SocksaddrFromNet(metadata.UDPAddr()))
|
M.SocksaddrFromNet(metadata.UDPAddr()))
|
||||||
} else {
|
} else {
|
||||||
conn, err = v.client.DialXUDPPacketConn(c,
|
conn, err = v.client.DialXUDPPacketConn(c,
|
||||||
utils.GlobalID(metadata.SourceAddress()),
|
globalID,
|
||||||
M.SocksaddrFromNet(metadata.UDPAddr()))
|
M.SocksaddrFromNet(metadata.UDPAddr()))
|
||||||
}
|
}
|
||||||
} else if v.option.PacketAddr {
|
} else if v.option.PacketAddr {
|
||||||
|
|
|
@ -171,6 +171,10 @@ func (m *Metadata) SourceDetail() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Metadata) SourceValid() bool {
|
||||||
|
return m.SrcPort != "" && m.SrcIP.IsValid()
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Metadata) AddrType() int {
|
func (m *Metadata) AddrType() int {
|
||||||
switch true {
|
switch true {
|
||||||
case m.Host != "" || !m.DstIP.IsValid():
|
case m.Host != "" || !m.DstIP.IsValid():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user