Commit 1cc12481 authored by Mygod's avatar Mygod

Revert binding 0.0.0.0 on Chrome OS

Fixes #2248.

Power user that requires proxy on Linux should update to M-75 or use a proxy server app instead.
parent 044fb23d
......@@ -22,8 +22,6 @@ package com.github.shadowsocks.bg
import android.content.Context
import android.util.Base64
import android.util.Log
import com.crashlytics.android.Crashlytics
import com.github.shadowsocks.Core
import com.github.shadowsocks.acl.Acl
import com.github.shadowsocks.acl.AclSyncer
......@@ -34,7 +32,9 @@ import com.github.shadowsocks.preference.DataStore
import com.github.shadowsocks.utils.parseNumericAddress
import com.github.shadowsocks.utils.signaturesCompat
import com.github.shadowsocks.utils.useCancellable
import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.File
import java.net.HttpURLConnection
import java.net.URL
......@@ -85,16 +85,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
// it's hard to resolve DNS on a specific interface so we'll do it here
if (profile.host.parseNumericAddress() == null) {
var retries = 0
while (true) try {
profile.host = service.resolver(profile.host).firstOrNull()?.hostAddress ?: throw UnknownHostException()
return
} catch (e: UnknownHostException) {
// retries are only needed on Chrome OS where arc0 is brought up/down during VPN changes
if (!DataStore.hasArc0) throw e
Thread.yield()
Crashlytics.log(Log.WARN, "ProxyInstance-resolver", "Retry resolving attempt #${++retries}")
}
profile.host = service.resolver(profile.host).firstOrNull()?.hostAddress ?: throw UnknownHostException()
}
}
......
......@@ -31,8 +31,6 @@ import com.github.shadowsocks.utils.DirectBoot
import com.github.shadowsocks.utils.Key
import com.github.shadowsocks.utils.parsePort
import java.net.InetSocketAddress
import java.net.NetworkInterface
import java.net.SocketException
object DataStore : OnPreferenceDataStoreChangeListener {
val publicStore = RoomPreferenceDataStore(PublicDatabase.kvPairDao)
......@@ -68,27 +66,7 @@ object DataStore : OnPreferenceDataStoreChangeListener {
val directBootAware: Boolean get() = Core.directBootSupported && canToggleLocked
val tcpFastOpen: Boolean get() = TcpFastOpen.sendEnabled && DataStore.publicStore.getBoolean(Key.tfo, true)
val serviceMode get() = publicStore.getString(Key.serviceMode) ?: Key.modeVpn
/**
* An alternative way to detect this interface could be checking MAC address = 00:ff:aa:00:00:55, but there is no
* reliable way of getting MAC address for now.
*/
val hasArc0 by lazy {
var retry = 0
while (retry < 5) {
try {
return@lazy NetworkInterface.getByName("arc0") != null
} catch (_: SocketException) { }
retry++
Thread.sleep(100L shl retry)
}
false
}
/**
* Binding bogus IP address 100.115.92.2 in Chrome OS directly does not seem to work reliably. It might be due to
* the IP may not be available when the device is not connected to any network.
*/
val listenAddress get() = if (publicStore.getBoolean(Key.shareOverLan, hasArc0)) "0.0.0.0" else "127.0.0.1"
val listenAddress get() = if (publicStore.getBoolean(Key.shareOverLan, false)) "0.0.0.0" else "127.0.0.1"
var portProxy: Int
get() = getLocalPort(Key.portProxy, 1080)
set(value) = publicStore.putString(Key.portProxy, value.toString())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment