mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-12 13:40:53 +00:00
fix windows udp by the way
This commit is contained in:
parent
e70488287b
commit
ea5106e8ec
2 changed files with 5 additions and 2 deletions
|
@ -40,7 +40,10 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|||
if err != nil {
|
||||
return errors.New("failed to find the interface").Base(err)
|
||||
}
|
||||
isV4 := (network == "tcp4" || network == "udp4")
|
||||
// easy way to check if the address is ipv4
|
||||
isV4 := strings.Contains(address, ".")
|
||||
// note: DO NOT trust the passed network variable, it can be udp6 even if the address is ipv4
|
||||
// because operating system might(always) use ipv6 socket to process ipv4
|
||||
if isV4 {
|
||||
var bytes [4]byte
|
||||
binary.BigEndian.PutUint32(bytes[:], uint32(inf.Index))
|
||||
|
|
|
@ -63,7 +63,7 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
|
|||
lc.Control = func(network, address string, c syscall.RawConn) error {
|
||||
return c.Control(func(fd uintptr) {
|
||||
if sockopt != nil {
|
||||
if err := applyOutboundSocketOptions(network, "", fd, sockopt); err != nil {
|
||||
if err := applyOutboundSocketOptions(network, dest.NetAddr(), fd, sockopt); err != nil {
|
||||
errors.LogInfo(ctx, err, "failed to apply socket options")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue