Skip to content

Commit

Permalink
chore: remove transproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Sep 29, 2023
1 parent 606eca0 commit 7b9bd8d
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 67 deletions.
3 changes: 0 additions & 3 deletions app/src/main/java/io/nekohasekai/sagernet/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ object Key {

const val APPEND_HTTP_PROXY = "appendHttpProxy"

const val REQUIRE_TRANSPROXY = "requireTransproxy"
const val TRANSPROXY_MODE = "transproxyMode"
const val TRANSPROXY_PORT = "transproxyPort"
const val CONNECTION_TEST_URL = "connectionTestURL"

const val TCP_KEEP_ALIVE_INTERVAL = "tcpKeepAliveInterval"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SagerConnection(
val serviceClass
get() = when (DataStore.serviceMode) {
Key.MODE_PROXY -> ProxyService::class
Key.MODE_VPN -> VpnService::class // Key.MODE_TRANS -> TransproxyService::class
Key.MODE_VPN -> VpnService::class
else -> throw UnknownError()
}.java

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ object DataStore : OnPreferenceDataStoreChangeListener {
set(value) {
saveLocalPort(Key.LOCAL_DNS_PORT, value)
}
var transproxyPort: Int
get() = getLocalPort(Key.TRANSPROXY_PORT, 9200)
set(value) = saveLocalPort(Key.TRANSPROXY_PORT, value)

fun initGlobal() {
if (configurationStore.getString(Key.MIXED_PORT) == null) {
Expand All @@ -126,9 +123,6 @@ object DataStore : OnPreferenceDataStoreChangeListener {
if (configurationStore.getString(Key.LOCAL_DNS_PORT) == null) {
localDNSPort = localDNSPort
}
if (configurationStore.getString(Key.TRANSPROXY_PORT) == null) {
transproxyPort = transproxyPort
}
}


Expand All @@ -151,8 +145,6 @@ object DataStore : OnPreferenceDataStoreChangeListener {
val persistAcrossReboot by configurationStore.boolean(Key.PERSIST_ACROSS_REBOOT) { false }

var appendHttpProxy by configurationStore.boolean(Key.APPEND_HTTP_PROXY)
var requireTransproxy by configurationStore.boolean(Key.REQUIRE_TRANSPROXY)
var transproxyMode by configurationStore.stringToInt(Key.TRANSPROXY_MODE)
var connectionTestURL by configurationStore.string(Key.CONNECTION_TEST_URL) { CONNECTION_TEST_URL }
var connectionTestConcurrent by configurationStore.int("connectionTestConcurrent") { 5 }
var alwaysShowAddress by configurationStore.boolean(Key.ALWAYS_SHOW_ADDRESS)
Expand Down
24 changes: 0 additions & 24 deletions app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import moe.matsuri.nb4a.utils.listByLineOrComma
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull

const val TAG_MIXED = "mixed-in"
const val TAG_TRANS = "trans-in"

const val TAG_PROXY = "proxy"
const val TAG_DIRECT = "direct"
Expand Down Expand Up @@ -154,7 +153,6 @@ fun buildConfig(
val needSniff = DataStore.trafficSniffing > 0
val needSniffOverride = DataStore.trafficSniffing == 2
val externalIndexMap = ArrayList<IndexEntity>()
val requireTransproxy = if (forTest) false else DataStore.requireTransproxy
val ipv6Mode = if (forTest) IPv6Mode.ENABLE else DataStore.ipv6Mode

fun genDomainStrategy(noAsIs: Boolean): String {
Expand Down Expand Up @@ -254,28 +252,6 @@ fun buildConfig(
})
}

if (requireTransproxy) {
if (DataStore.transproxyMode == 1) {
inbounds.add(Inbound_TProxyOptions().apply {
type = "tproxy"
tag = TAG_TRANS
listen = bind
listen_port = DataStore.transproxyPort
sniff = needSniff
sniff_override_destination = needSniffOverride
})
} else {
inbounds.add(Inbound_RedirectOptions().apply {
type = "redirect"
tag = TAG_TRANS
listen = bind
listen_port = DataStore.transproxyPort
sniff = needSniff
sniff_override_destination = needSniffOverride
})
}
}

outbounds = mutableListOf()

// init routing object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
val enableDnsRouting = findPreference<SwitchPreference>(Key.ENABLE_DNS_ROUTING)!!
val enableFakeDns = findPreference<SwitchPreference>(Key.ENABLE_FAKEDNS)!!

val requireTransproxy = findPreference<SwitchPreference>(Key.REQUIRE_TRANSPROXY)!!
val transproxyPort = findPreference<EditTextPreference>(Key.TRANSPROXY_PORT)!!
val transproxyMode = findPreference<SimpleMenuPreference>(Key.TRANSPROXY_MODE)!!
val logLevel = findPreference<LongClickListPreference>(Key.LOG_LEVEL)!!
val mtu = findPreference<MTUPreference>(Key.MTU)!!

Expand Down Expand Up @@ -126,16 +123,6 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
true
}

transproxyPort.isEnabled = requireTransproxy.isChecked
transproxyMode.isEnabled = requireTransproxy.isChecked

requireTransproxy.setOnPreferenceChangeListener { _, newValue ->
transproxyPort.isEnabled = newValue as Boolean
transproxyMode.isEnabled = newValue
needReload()
true
}

val muxProtocols = findPreference<MultiSelectListPreference>(Key.MUX_PROTOCOLS)!!

muxProtocols.apply {
Expand Down Expand Up @@ -203,9 +190,6 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
ipv6Mode.onPreferenceChangeListener = reloadListener
allowAccess.onPreferenceChangeListener = reloadListener

transproxyPort.onPreferenceChangeListener = reloadListener
transproxyMode.onPreferenceChangeListener = reloadListener

resolveDestination.onPreferenceChangeListener = reloadListener
tunImplementation.onPreferenceChangeListener = reloadListener
acquireWakeLock.onPreferenceChangeListener = reloadListener
Expand Down
15 changes: 0 additions & 15 deletions app/src/main/res/xml/global_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,6 @@
app:key="appendHttpProxy"
app:summary="@string/append_http_proxy_sum"
app:title="@string/append_http_proxy" />
<SwitchPreference
app:icon="@drawable/ic_baseline_transgender_24"
app:key="requireTransproxy"
app:title="@string/require_transproxy" />
<EditTextPreference
app:key="transproxyPort"
app:title="@string/port_transproxy"
app:useSimpleSummaryProvider="true" />
<moe.matsuri.nb4a.ui.SimpleMenuPreference
app:defaultValue="0"
app:entries="@array/transproxy_mode"
app:entryValues="@array/int_array_2"
app:key="transproxyMode"
app:title="@string/transproxy_mode"
app:useSimpleSummaryProvider="true" />
<SwitchPreference
app:icon="@drawable/ic_baseline_nat_24"
app:key="allowAccess"
Expand Down

0 comments on commit 7b9bd8d

Please sign in to comment.