Skip to content

Commit

Permalink
Add option to disable IPv6 tethering
Browse files Browse the repository at this point in the history
Partially addresses #6, #20.
  • Loading branch information
Mygod committed Jun 1, 2018
1 parent 79cdce4 commit 8e335fe
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions mobile/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
<string name="settings_service_repeater_oc_summary">"自动 (1\u201114 = 2.4GHz, 15\u2011165 = 5GHz)"</string>
<string name="settings_service_repeater_strict">严格模式</string>
<string name="settings_service_repeater_strict_summary">只允许通过 VPN 隧道的包通过,不适用于系统共享</string>
<string name="settings_service_disable_ipv6">禁用 IPv6 共享</string>
<string name="settings_service_disable_ipv6_summary">防止 IPv6 VPN 泄漏。</string>
<string name="settings_service_dns">备用 DNS 服务器[:端口]</string>
<string name="settings_service_clean">清理/重新应用路由规则</string>
<string name="settings_misc">杂项</string>
Expand Down
2 changes: 2 additions & 0 deletions mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
<string name="settings_service_repeater_strict">Strict mode</string>
<string name="settings_service_repeater_strict_summary">Only allow packets that goes through VPN tunnel. Does not
apply to system tethering.</string>
<string name="settings_service_disable_ipv6">Disable IPv6 tethering</string>
<string name="settings_service_disable_ipv6_summary">Enabling this option will prevent VPN leaks via IPv6.</string>
<string name="settings_service_dns">Fallback DNS server[:port]</string>
<string name="settings_service_clean">Clean/reapply routing rules</string>
<string name="settings_misc">Misc</string>
Expand Down
4 changes: 4 additions & 0 deletions mobile/src/main/res/xml/pref_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
android:key="service.repeater.strict"
android:title="@string/settings_service_repeater_strict"
android:summary="@string/settings_service_repeater_strict_summary"/>
<SwitchPreference
android:key="service.disableIpv6"
android:title="@string/settings_service_disable_ipv6"
android:summary="@string/settings_service_disable_ipv6_summary"/>
<AutoSummaryEditTextPreference
android:key="service.dns"
android:title="@string/settings_service_dns"
Expand Down

0 comments on commit 8e335fe

Please sign in to comment.