From 87dafef2d5a2f1ff4a86157fe30cec707f77f343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 20 Aug 2022 09:32:59 +0800 Subject: [PATCH] Fix route on android --- tun_linux.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tun_linux.go b/tun_linux.go index 1b1b345..1718adc 100644 --- a/tun_linux.go +++ b/tun_linux.go @@ -190,12 +190,15 @@ func (t *NativeTun) rules() []*netlink.Rule { rules = append(rules, it) priority++ - it = netlink.NewRule() - it.Priority = priority - it.IPProto = unix.IPPROTO_ICMP - it.Goto = nopPriority - rules = append(rules, it) - priority++ + if runtime.GOOS != "android" { + // not supported on android, why? + it = netlink.NewRule() + it.Priority = priority + it.IPProto = unix.IPPROTO_ICMP + it.Goto = nopPriority + rules = append(rules, it) + priority++ + } } if t.options.Inet6Address.IsValid() { @@ -206,12 +209,14 @@ func (t *NativeTun) rules() []*netlink.Rule { rules = append(rules, it) priority++ - it = netlink.NewRule() - it.Priority = priority - it.IPProto = unix.IPPROTO_ICMPV6 - it.Goto = nopPriority - rules = append(rules, it) - priority++ + if runtime.GOOS != "android" { + it = netlink.NewRule() + it.Priority = priority + it.IPProto = unix.IPPROTO_ICMPV6 + it.Goto = nopPriority + rules = append(rules, it) + priority++ + } } it = netlink.NewRule()