From: Jason A. Donenfeld Date: Tue, 22 May 2018 17:40:51 +0000 (+0200) Subject: Avoid sticky sockets on Android X-Git-Tag: 0.0.20180524~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65a74f3175855dc41b49332103ada6bb27733291;p=thirdparty%2Fwireguard-go.git Avoid sticky sockets on Android The android policy routing system does insane things. --- diff --git a/conn_default.go b/conn_default.go index fc52fbf..14ed56c 100644 --- a/conn_default.go +++ b/conn_default.go @@ -1,4 +1,4 @@ -// +build !linux +// +build !linux android /* SPDX-License-Identifier: GPL-2.0 * @@ -143,9 +143,12 @@ func (bind *NativeBind) Send(buff []byte, endpoint Endpoint) error { var fwmarkIoctl int func init() { - if runtime.GOOS == "freebsd" { + switch runtime.GOOS { + case "linux", "android": + fwmarkIoctl = 36 /* unix.SO_MARK */ + case "freebsd": fwmarkIoctl = 0x1015 /* unix.SO_USER_COOKIE */ - } else if runtime.GOOS == "openbsd" { + case "openbsd": fwmarkIoctl = 0x1021 /* unix.SO_RTABLE */ } } diff --git a/conn_linux.go b/conn_linux.go index e5105e3..fa09087 100644 --- a/conn_linux.go +++ b/conn_linux.go @@ -1,3 +1,5 @@ +// +build !android + /* SPDX-License-Identifier: GPL-2.0 * * Copyright (C) 2017-2018 Jason A. Donenfeld . All Rights Reserved.