Skip to content

Commit

Permalink
https://github.com/XTLS/Xray-core/issues/3556#issuecomment-2238805008
Browse files Browse the repository at this point in the history
  • Loading branch information
YUNRU committed Jul 19, 2024
1 parent b277bac commit 45f4ad0
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions transport/internet/splithttp/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,32 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
if err != nil {
return nil, err
}
udpAddr, err := net.ResolveUDPAddr("udp", conn.RemoteAddr().String())
if err != nil {
return nil, err

var udpConn *net.UDPConn
var udpAddr *net.UDPAddr

switch c := conn.(type) {
case *internet.PacketConnWrapper:
var ok bool
udpConn, ok = c.Conn.(*net.UDPConn)
if !ok {
return nil, errors.New("PacketConnWrapper does not contain a UDP connection")
}
udpAddr, err = net.ResolveUDPAddr("udp", c.Dest.String())
if err != nil {
return nil, err
}
case *net.UDPConn:
udpConn = c
udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String())
if err != nil {
return nil, err
}
default:
return nil, errors.New("unsupported connection type: %T", conn)
}
return quic.DialEarly(ctx, conn.(*internet.PacketConnWrapper).Conn.(*net.UDPConn), udpAddr, tlsCfg, cfg)

return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg)
},
}
downloadTransport = roundTripper
Expand Down

0 comments on commit 45f4ad0

Please sign in to comment.