Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mobile builds #1035

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions overlay/tun_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 3 additions & 7 deletions overlay/tun_ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down