Files
x/internal/net/dialer/dialer_darwin.go
T
ginuerzh dc31d5c15f fix(dialer): add switchNetns stubs for all non-Linux platforms
The switchNetns function was only defined for linux (dialer_netns.go,
build tag linux && !android) and android (dialer_android.go, stub).
This left darwin, freebsd, openbsd, windows, and other platforms with
an undefined symbol at dialer.go:55.

Add no-op stubs to all remaining platform files so the dialer package
compiles on every GOOS.
2026-06-18 14:33:02 +08:00

43 lines
895 B
Go

package dialer
import (
"net"
"syscall"
"golang.org/x/sys/unix"
)
func bindDevice(network, address string, fd uintptr, ifceName string) error {
if ifceName == "" {
return nil
}
host, _, _ := net.SplitHostPort(address)
if ip := net.ParseIP(host); ip != nil && !ip.IsGlobalUnicast() {
return nil
}
ifce, err := net.InterfaceByName(ifceName)
if err != nil {
return err
}
switch network {
case "tcp", "tcp4", "udp", "udp4":
return unix.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_BOUND_IF, ifce.Index)
case "tcp6", "udp6":
return unix.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_BOUND_IF, ifce.Index)
}
return nil
}
func setMark(fd uintptr, mark int) error {
return nil
}
// switchNetns is a no-op stub — network namespace switching is a Linux-only feature.
func switchNetns(name string) (restore func(), err error) {
return nil, nil
}