Support strict mode for system tethering

TODO: Set up rules when upstream interface not found.
This commit is contained in:
Mygod
2018-09-03 16:37:54 +08:00
parent 0342d97fb0
commit 89c26fe384
6 changed files with 13 additions and 6 deletions

View File

@@ -84,6 +84,11 @@ class Routing(val upstream: String?, private val downstream: String, ownerAddres
stopScript.addFirst("$IPTABLES -D FORWARD -j vpnhotspot_fwd")
}
fun overrideSystemRules() {
startScript.add("$IPTABLES -A vpnhotspot_fwd -i $downstream -j DROP")
stopScript.addFirst("$IPTABLES -D vpnhotspot_fwd -i $downstream -j DROP")
}
fun masquerade(strict: Boolean = true) {
val hostSubnet = "${hostAddress.address.hostAddress}/${hostAddress.networkPrefixLength}"
startScript.add("quiet $IPTABLES -t nat -N vpnhotspot_masquerade 2>/dev/null")