Add option to disable IPv6 tethering

Partially addresses #6, #20.
This commit is contained in:
Mygod
2018-06-01 22:30:31 +08:00
parent 79cdce40e2
commit 8e335fec1b
5 changed files with 15 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ class TetheringService : IpNeighbourMonitoringService(), VpnMonitor.Callback {
// system tethering already has working forwarding rules
// so it doesn't make sense to add additional forwarding rules
val routing = Routing(upstream, downstream).rule().forward().masquerade().dnsRedirect(dns)
if (app.pref.getBoolean("service.disableIpv6", false)) routing.disableIpv6()
routings[downstream] = routing
if (!routing.start()) failed = true
} catch (e: SocketException) {

View File

@@ -47,6 +47,12 @@ class Routing(val upstream: String?, private val downstream: String, ownerAddres
return this
}
fun disableIpv6(): Routing {
startScript.add("echo 1 >/proc/sys/net/ipv6/conf/$downstream/disable_ipv6")
stopScript.add("echo 0 >/proc/sys/net/ipv6/conf/$downstream/disable_ipv6")
return this
}
/**
* Since Android 5.0, RULE_PRIORITY_TETHERING = 18000.
* This also works for Wi-Fi direct where there's no rule at 18000.