import (
"fmt"
+ "runtime"
"syscall"
"golang.org/x/sys/unix"
var err error
switch network {
case "udp4":
- c.Control(func(fd uintptr) {
- err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_PKTINFO, 1)
- })
+ if runtime.GOOS != "android" {
+ c.Control(func(fd uintptr) {
+ err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_PKTINFO, 1)
+ })
+ }
case "udp6":
c.Control(func(fd uintptr) {
- err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_RECVPKTINFO, 1)
- if err != nil {
- return
+ if runtime.GOOS != "android" {
+ err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_RECVPKTINFO, 1)
+ if err != nil {
+ return
+ }
}
err = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_V6ONLY, 1)
})
-//go:build !linux
+//go:build !linux || android
/* SPDX-License-Identifier: MIT
*
// srcControlSize returns the recommended buffer size for pooling sticky control
// data.
const srcControlSize = 0
+
+const StdNetSupportsStickySockets = false
+//go:build linux && !android
+
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved.
}
var srcControlSize = unix.CmsgSpace(unix.SizeofInet6Pktinfo)
+
+const StdNetSupportsStickySockets = true
)
func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, error) {
+ if !conn.StdNetSupportsStickySockets {
+ return nil, nil
+ }
if _, ok := bind.(*conn.StdNetBind); !ok {
return nil, nil
}