Fix netd mode on Android 6 with repeater

This commit is contained in:
Mygod
2019-02-17 12:58:22 +08:00
parent 0be1116121
commit 3933e9bf64

View File

@@ -115,15 +115,16 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh
// by the time stopScript is called, table entry for upstream may already get removed // by the time stopScript is called, table entry for upstream may already get removed
"ip rule del from all iif $downstream priority $priority") "ip rule del from all iif $downstream priority $priority")
} }
when (masqueradeMode) { fun simpleMasquerade() {
MasqueradeMode.None -> { } // nothing to be done here
// note: specifying -i wouldn't work for POSTROUTING // note: specifying -i wouldn't work for POSTROUTING
MasqueradeMode.Simple -> {
iptablesAdd(if (upstream == null) "vpnhotspot_masquerade -s $hostSubnet -j MASQUERADE" else iptablesAdd(if (upstream == null) "vpnhotspot_masquerade -s $hostSubnet -j MASQUERADE" else
"vpnhotspot_masquerade -s $hostSubnet -o $upstream -j MASQUERADE", "nat") "vpnhotspot_masquerade -s $hostSubnet -o $upstream -j MASQUERADE", "nat")
} }
MasqueradeMode.Netd -> { when (masqueradeMode) {
check(upstream != null) MasqueradeMode.None -> { } // nothing to be done here
MasqueradeMode.Simple -> simpleMasquerade()
// fallback is only needed for repeater on API 23
MasqueradeMode.Netd -> if (upstream == null) simpleMasquerade() else {
/** /**
* 0 means that there are no interface addresses coming after, which is unused anyway. * 0 means that there are no interface addresses coming after, which is unused anyway.
* *