From af2fc48378d740169f2743fbba8d2abf0175ef6c Mon Sep 17 00:00:00 2001 From: John Maguire Date: Wed, 6 Dec 2023 16:18:21 -0500 Subject: [PATCH] Fix mobile builds (#1035) --- overlay/tun_android.go | 10 +++------- overlay/tun_ios.go | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/overlay/tun_android.go b/overlay/tun_android.go index c731d78..c5c52db 100644 --- a/overlay/tun_android.go +++ b/overlay/tun_android.go @@ -18,7 +18,7 @@ type tun struct { io.ReadWriteCloser fd int cidr *net.IPNet - routeTree *cidr.Tree4 + routeTree *cidr.Tree4[iputil.VpnIp] l *logrus.Logger } @@ -46,12 +46,8 @@ func newTun(_ *logrus.Logger, _ string, _ *net.IPNet, _ int, _ []Route, _ int, _ } func (t *tun) RouteFor(ip iputil.VpnIp) iputil.VpnIp { - r := t.routeTree.MostSpecificContains(ip) - if r != nil { - return r.(iputil.VpnIp) - } - - return 0 + _, r := t.routeTree.MostSpecificContains(ip) + return r } func (t tun) Activate() error { diff --git a/overlay/tun_ios.go b/overlay/tun_ios.go index 26f34ec..ce65b33 100644 --- a/overlay/tun_ios.go +++ b/overlay/tun_ios.go @@ -20,7 +20,7 @@ import ( type tun struct { io.ReadWriteCloser cidr *net.IPNet - routeTree *cidr.Tree4 + routeTree *cidr.Tree4[iputil.VpnIp] } func newTun(_ *logrus.Logger, _ string, _ *net.IPNet, _ int, _ []Route, _ int, _ bool, _ bool) (*tun, error) { @@ -46,12 +46,8 @@ func (t *tun) Activate() error { } func (t *tun) RouteFor(ip iputil.VpnIp) iputil.VpnIp { - r := t.routeTree.MostSpecificContains(ip) - if r != nil { - return r.(iputil.VpnIp) - } - - return 0 + _, r := t.routeTree.MostSpecificContains(ip) + return r } // The following is hoisted up from water, we do this so we can inject our own fd on iOS