From e3b1f5f108a195f3705974b60f813984586ccdcc Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Wed, 15 Feb 2023 12:12:34 +0900 Subject: [PATCH] remove tunImplementation & pcap --- .../java/io/nekohasekai/sagernet/Constants.kt | 2 -- .../io/nekohasekai/sagernet/bg/VpnService.kt | 5 ++-- .../sagernet/database/DataStore.kt | 3 --- .../sagernet/database/ProxyEntity.kt | 2 +- .../sagernet/ui/SettingsPreferenceFragment.kt | 25 ------------------- app/src/main/res/xml/global_preferences.xml | 13 ---------- libcore/core_commit.txt | 2 +- libcore/tun.go | 19 +------------- libcore/tun/tuns/tuns_linux.go | 7 ++++-- 9 files changed, 10 insertions(+), 68 deletions(-) diff --git a/app/src/main/java/io/nekohasekai/sagernet/Constants.kt b/app/src/main/java/io/nekohasekai/sagernet/Constants.kt index 2ffd546dc..7ba0eb583 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/Constants.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/Constants.kt @@ -83,8 +83,6 @@ object Key { const val MUX_PROTOCOLS = "mux" const val MUX_CONCURRENCY = "muxConcurrency" - const val TUN_IMPLEMENTATION = "tunImplementation" - const val ENABLE_PCAP = "enablePcap" const val ACQUIRE_WAKE_LOCK = "acquireWakeLock" const val SHOW_BOTTOM_BAR = "showBottomBar" diff --git a/app/src/main/java/io/nekohasekai/sagernet/bg/VpnService.kt b/app/src/main/java/io/nekohasekai/sagernet/bg/VpnService.kt index 2a6308fd1..99f00cb59 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/bg/VpnService.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/bg/VpnService.kt @@ -208,7 +208,7 @@ class VpnService : BaseVpnService(), val packageName = packageName var proxyApps = DataStore.proxyApps var bypass = DataStore.bypass - var workaroundSYSTEM = DataStore.tunImplementation == TunImplementation.SYSTEM + var workaroundSYSTEM = false /* DataStore.tunImplementation == TunImplementation.SYSTEM */ var needBypassRootUid = workaroundSYSTEM || data.proxy!!.config.outboundTagsAll.values.any { it.nekoBean?.needBypassRootUid() == true || it.hysteriaBean?.protocol == HysteriaBean.PROTOCOL_FAKETCP } @@ -282,13 +282,12 @@ class VpnService : BaseVpnService(), mtu = DataStore.mtu v2Ray = data.proxy!!.v2rayPoint iPv6Mode = ipv6Mode - implementation = DataStore.tunImplementation + implementation = 2 // Tun2Socket sniffing = DataStore.trafficSniffing fakeDNS = DataStore.enableFakeDns debug = DataStore.enableLog dumpUID = data.proxy!!.config.dumpUid trafficStats = DataStore.appTrafficStatistics - pCap = DataStore.enablePcap errorHandler = ErrorHandler { stopRunner(false, it) } diff --git a/app/src/main/java/io/nekohasekai/sagernet/database/DataStore.kt b/app/src/main/java/io/nekohasekai/sagernet/database/DataStore.kt index 42b2e7d98..e908cb765 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/database/DataStore.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/database/DataStore.kt @@ -130,7 +130,6 @@ object DataStore : OnPreferenceDataStoreChangeListener { var rulesProvider by configurationStore.stringToInt(Key.RULES_PROVIDER) var enableLog by configurationStore.boolean(Key.ENABLE_LOG) var logBufSize by configurationStore.int(Key.LOG_BUF_SIZE) { 0 } - var enablePcap by configurationStore.boolean(Key.ENABLE_PCAP) var acquireWakeLock by configurationStore.boolean(Key.ACQUIRE_WAKE_LOCK) var showBottomBar by configurationStore.boolean(Key.SHOW_BOTTOM_BAR) @@ -190,8 +189,6 @@ object DataStore : OnPreferenceDataStoreChangeListener { var connectionTestURL by configurationStore.string(Key.CONNECTION_TEST_URL) { CONNECTION_TEST_URL } var alwaysShowAddress by configurationStore.boolean(Key.ALWAYS_SHOW_ADDRESS) - var tunImplementation by configurationStore.stringToInt(Key.TUN_IMPLEMENTATION) { TunImplementation.SYSTEM } - var appTrafficStatistics by configurationStore.boolean(Key.APP_TRAFFIC_STATISTICS) var profileTrafficStatistics by configurationStore.boolean(Key.PROFILE_TRAFFIC_STATISTICS) { true } diff --git a/app/src/main/java/io/nekohasekai/sagernet/database/ProxyEntity.kt b/app/src/main/java/io/nekohasekai/sagernet/database/ProxyEntity.kt index 5fcb8f20a..ef03f2bea 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/database/ProxyEntity.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/database/ProxyEntity.kt @@ -345,7 +345,7 @@ data class ProxyEntity( fun needCoreMux(): Boolean { return when (type) { TYPE_VMESS -> Protocols.shouldEnableMux("vmess") && isV2RayNetworkTcp() - TYPE_TROJAN -> Protocols.shouldEnableMux("trojan") + TYPE_TROJAN -> Protocols.shouldEnableMux("trojan") && isV2RayNetworkTcp() TYPE_TROJAN_GO -> false else -> false } diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/SettingsPreferenceFragment.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/SettingsPreferenceFragment.kt index 5a7a97896..635639842 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/SettingsPreferenceFragment.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/SettingsPreferenceFragment.kt @@ -36,7 +36,6 @@ import com.takisoft.preferencex.SimpleMenuPreference import io.nekohasekai.sagernet.Key import io.nekohasekai.sagernet.R import io.nekohasekai.sagernet.SagerNet -import io.nekohasekai.sagernet.TunImplementation import io.nekohasekai.sagernet.database.DataStore import io.nekohasekai.sagernet.database.preference.EditTextPreferenceModifiers import io.nekohasekai.sagernet.ktx.* @@ -257,9 +256,7 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() { true } - val tunImplementation = findPreference(Key.TUN_IMPLEMENTATION)!! val resolveDestination = findPreference(Key.RESOLVE_DESTINATION)!! - val enablePcap = findPreference(Key.ENABLE_PCAP)!! val acquireWakeLock = findPreference(Key.ACQUIRE_WAKE_LOCK)!! speedInterval.onPreferenceChangeListener = reloadListener @@ -288,31 +285,9 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() { transproxyMode.onPreferenceChangeListener = reloadListener appTrafficStatistics.onPreferenceChangeListener = reloadListener - tunImplementation.onPreferenceChangeListener = reloadListener resolveDestination.onPreferenceChangeListener = reloadListener acquireWakeLock.onPreferenceChangeListener = reloadListener - enablePcap.setOnPreferenceChangeListener { _, newValue -> - if (newValue as Boolean) { - val path = File(app.externalAssets, "pcap").absolutePath - MaterialAlertDialogBuilder(requireContext()).apply { - setTitle(R.string.pcap) - setMessage(resources.getString(R.string.pcap_notice, path)) - setPositiveButton(android.R.string.ok) { _, _ -> - needReload() - } - setNegativeButton(android.R.string.copy) { _, _ -> - SagerNet.trySetPrimaryClip(path) - snackbar(R.string.copy_success).show() - } - }.show() - if (tunImplementation.value != "${TunImplementation.GVISOR}") { - tunImplementation.value = "${TunImplementation.GVISOR}" - } - } else needReload() - true - } - } override fun onResume() { diff --git a/app/src/main/res/xml/global_preferences.xml b/app/src/main/res/xml/global_preferences.xml index 967875652..e0fd2b402 100644 --- a/app/src/main/res/xml/global_preferences.xml +++ b/app/src/main/res/xml/global_preferences.xml @@ -26,14 +26,6 @@ app:key="serviceMode" app:title="@string/service_mode" app:useSimpleSummaryProvider="true" /> - -