Do not assume iptables-save is available

This commit is contained in:
Mygod
2018-02-22 01:13:52 -08:00
parent ca9398c04b
commit 4b43a6a1ba
2 changed files with 3 additions and 3 deletions

View File

@@ -51,7 +51,7 @@ class TetheringService : Service(), VpnMonitor.Callback, IpNeighbourMonitor.Call
for ((downstream, value) in routings) if (value == null) { for ((downstream, value) in routings) if (value == null) {
// system tethering already has working forwarding rules // system tethering already has working forwarding rules
// so it doesn't make sense to add additional forwarding rules // so it doesn't make sense to add additional forwarding rules
val routing = Routing(upstream, downstream).rule().forward(true).dnsRedirect(dns) val routing = Routing(upstream, downstream).rule().forward().dnsRedirect(dns)
if (routing.start()) routings[downstream] = routing else { if (routing.start()) routings[downstream] = routing else {
failed = true failed = true
routing.stop() routing.stop()

View File

@@ -32,10 +32,10 @@ class Routing(val upstream: String?, val downstream: String, ownerAddress: InetA
fun dump() = loggerSu(""" fun dump() = loggerSu("""
|echo iptables |echo iptables
|iptables-save |sh -c 'exec -a iptables-save iptables'
|echo |echo
|echo iptables -t nat |echo iptables -t nat
|iptables-save -t nat |sh -c 'exec -a iptables-save iptables -t nat'
|echo |echo
|echo ip rule |echo ip rule
|ip rule |ip rule