Revert "Remove fallback upstream monitor"

This commit reverts 99e721bf7e.

Fixes #119.
This commit is contained in:
Mygod
2019-07-15 23:28:48 +08:00
parent 654c1fc48f
commit 5583e742ca
9 changed files with 107 additions and 34 deletions

View File

@@ -11,6 +11,7 @@ import androidx.preference.SwitchPreference
import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.net.Routing.Companion.IPTABLES
import be.mygod.vpnhotspot.net.TetherOffloadManager
import be.mygod.vpnhotspot.net.monitor.FallbackUpstreamMonitor
import be.mygod.vpnhotspot.net.monitor.IpMonitor
import be.mygod.vpnhotspot.net.monitor.UpstreamMonitor
import be.mygod.vpnhotspot.net.wifi.WifiDoubleLock
@@ -115,6 +116,9 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|echo iptables -nvx -L vpnhotspot_fwd
|$IPTABLES -nvx -L vpnhotspot_fwd
|echo
|echo iptables -nvx -L vpnhotspot_acl
|$IPTABLES -nvx -L vpnhotspot_acl
|echo
|echo logcat-su
|logcat -d
""".trimMargin())
@@ -146,23 +150,24 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
override fun onDisplayPreferenceDialog(preference: Preference) {
when (preference.key) {
UpstreamMonitor.KEY -> AlwaysAutoCompleteEditTextPreferenceDialogFragmentCompat().apply {
setArguments(preference.key, try {
NetworkInterface.getNetworkInterfaces().asSequence()
.filter {
try {
it.isUp && !it.isLoopback && it.interfaceAddresses.isNotEmpty()
} catch (_: SocketException) {
false
UpstreamMonitor.KEY, FallbackUpstreamMonitor.KEY ->
AlwaysAutoCompleteEditTextPreferenceDialogFragmentCompat().apply {
setArguments(preference.key, try {
NetworkInterface.getNetworkInterfaces().asSequence()
.filter {
try {
it.isUp && !it.isLoopback && it.interfaceAddresses.isNotEmpty()
} catch (_: SocketException) {
false
}
}
}
.map { it.name }.sorted().toList().toTypedArray()
} catch (e: SocketException) {
Timber.d(e)
emptyArray<String>()
})
setTargetFragment(this@SettingsPreferenceFragment, 0)
}.show(fragmentManager ?: return, preference.key)
.map { it.name }.sorted().toList().toTypedArray()
} catch (e: SocketException) {
Timber.d(e)
emptyArray<String>()
})
setTargetFragment(this@SettingsPreferenceFragment, 0)
}.show(fragmentManager ?: return, preference.key)
else -> super.onDisplayPreferenceDialog(preference)
}
}