Add remote DNS setting #991
This commit is contained in:
@@ -68,6 +68,8 @@
|
||||
|
||||
<string name="nat">NAT 模式 (仅限调试)</string>
|
||||
<string name="nat_summary">从 VPN 模式切换为 NAT 模式,需要 ROOT 权限</string>
|
||||
<string name="remote_dns">远程 DNS</string>
|
||||
<string name="remote_dns_summary">用于远程域名解析的 DNS 服务器 (默认为 8.8.8.8)</string>
|
||||
|
||||
<string name="udp_dns">UDP 转发</string>
|
||||
<string name="udp_dns_summary">由远程服务器转发 UDP 协议的数据包</string>
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
|
||||
<string name="nat">NAT 模式 (已過時)</string>
|
||||
<string name="nat_summary">使用 NAT 模式代替 VPN 模式,需要 ROOT 權限</string>
|
||||
<string name="remote_dns">遠程 DNS</string>
|
||||
<string name="remote_dns_summary">用於遠程域名解析的 DNS 伺服器 (默認為 8.8.8.8) </string>
|
||||
|
||||
<string name="udp_dns">UDP 轉送</string>
|
||||
<string name="udp_dns_summary">向遠端轉送 UDP 封包</string>
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
<string name="profile_summary">Switch to another profile or add new profiles</string>
|
||||
<string name="nat">NAT mode (deprecated)</string>
|
||||
<string name="nat_summary">Use NAT mode instead of VPN mode. Requires ROOT permission.</string>
|
||||
<string name="remote_dns">Remote DNS</string>
|
||||
<string name="remote_dns_summary">DNS server for remote hostname resolution. (Default 8.8.8.8)</string>
|
||||
<string name="stat">Network Traffic</string>
|
||||
<string name="stat_summary">Sent: \t\t\t\t\t%3$s\t↑\t%1$s/s\nReceived: \t%4$s\t↓\t%2$s/s</string>
|
||||
<string name="stat_profiles">\n%1$s↑\t%2$s↓</string>
|
||||
|
||||
@@ -60,6 +60,10 @@
|
||||
android:entryValues="@array/route_value"
|
||||
android:summary="%s"
|
||||
android:title="@string/route_list"/>
|
||||
<be.mygod.preference.EditTextPreference
|
||||
android:key="remoteDns"
|
||||
android:title="@string/remote_dns"
|
||||
android:summary="@string/remote_dns_summary"/>
|
||||
<SwitchPreference
|
||||
android:key="isIpv6"
|
||||
android:persistent="false"
|
||||
@@ -119,8 +123,10 @@
|
||||
<SwitchPreference android:key="isNAT"
|
||||
android:title="@string/nat"
|
||||
android:summary="@string/nat_summary"/>
|
||||
|
||||
<Preference android:key="recovery" android:title="@string/recovery"
|
||||
android:summary="@string/recovery_summary"/>
|
||||
|
||||
<Preference android:key="about" android:title="@string/about"/>
|
||||
|
||||
</be.mygod.preference.PreferenceCategory>
|
||||
|
||||
@@ -123,10 +123,11 @@ class ShadowsocksNatService extends BaseService {
|
||||
, "-c" , getApplicationInfo.dataDir + "/ss-tunnel-nat.conf")
|
||||
|
||||
cmd += "-L"
|
||||
if (profile.route == Route.CHINALIST)
|
||||
cmd += "114.114.114.114:53"
|
||||
else
|
||||
|
||||
if (profile.remoteDns == null)
|
||||
cmd += "8.8.8.8:53"
|
||||
else
|
||||
cmd += profile.remoteDns + ":53"
|
||||
|
||||
if (profile.auth) cmd += "-A"
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ object ShadowsocksSettings {
|
||||
private final val TAG = "ShadowsocksSettings"
|
||||
private val PROXY_PREFS = Array(Key.name, Key.host, Key.remotePort, Key.localPort, Key.password, Key.method,
|
||||
Key.auth, Key.kcp, Key.kcpPort, Key.kcpcli)
|
||||
private val FEATURE_PREFS = Array(Key.route, Key.proxyApps, Key.udpdns, Key.ipv6)
|
||||
private val FEATURE_PREFS = Array(Key.route, Key.remoteDns, Key.proxyApps, Key.udpdns, Key.ipv6)
|
||||
|
||||
// Helper functions
|
||||
def updateDropDownPreference(pref: Preference, value: String) {
|
||||
@@ -76,6 +76,10 @@ object ShadowsocksSettings {
|
||||
case Key.password =>
|
||||
updateEditTextPreference(pref, profile.password)
|
||||
pref.setSummary(if (demo) "\u2022" * 32 else "%s")
|
||||
case Key.remoteDns =>
|
||||
updateEditTextPreference(pref, profile.remoteDns)
|
||||
if (profile.remoteDns != null)
|
||||
pref.setSummary(if (demo) "8.8.8.8" else "%s")
|
||||
case Key.method => updateDropDownPreference(pref, profile.method)
|
||||
case Key.route => updateDropDownPreference(pref, profile.route)
|
||||
case Key.proxyApps => updateSwitchPreference(pref, profile.proxyApps)
|
||||
@@ -129,6 +133,10 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
|
||||
profile.route = value.asInstanceOf[String]
|
||||
app.profileManager.updateProfile(profile)
|
||||
})
|
||||
findPreference(Key.remoteDns).setOnPreferenceChangeListener((_, value) => {
|
||||
profile.remoteDns = value.asInstanceOf[String]
|
||||
app.profileManager.updateProfile(profile)
|
||||
})
|
||||
|
||||
findPreference(Key.kcp).setOnPreferenceChangeListener((_, value) => {
|
||||
profile.kcp = value.asInstanceOf[Boolean]
|
||||
|
||||
@@ -274,10 +274,11 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
, "-c", getApplicationInfo.dataDir + "/ss-tunnel-vpn.conf")
|
||||
|
||||
cmd += "-L"
|
||||
if (profile.route == Route.CHINALIST)
|
||||
cmd += "114.114.114.114:53"
|
||||
else
|
||||
|
||||
if (profile.remoteDns == null)
|
||||
cmd += "8.8.8.8:53"
|
||||
else
|
||||
cmd += profile.remoteDns + ":53"
|
||||
|
||||
if (profile.auth) cmd += "-A"
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ object DBHelper {
|
||||
}
|
||||
|
||||
class DBHelper(val context: Context)
|
||||
extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 20) {
|
||||
extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 21) {
|
||||
import DBHelper._
|
||||
|
||||
lazy val profileDao: Dao[Profile, Int] = getDao(classOf[Profile])
|
||||
@@ -125,6 +125,10 @@ class DBHelper(val context: Context)
|
||||
} else if (oldVersion < 19) {
|
||||
profileDao.executeRawNoArgs("UPDATE `profile` SET kcpPort = 8399 WHERE kcpPort = 0;")
|
||||
}
|
||||
|
||||
if (oldVersion < 21) {
|
||||
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN remoteDns VARCHAR DEFAULT '8.8.8.8';")
|
||||
}
|
||||
} catch {
|
||||
case ex: Exception =>
|
||||
app.track(ex)
|
||||
|
||||
@@ -52,6 +52,9 @@ class Profile {
|
||||
@DatabaseField
|
||||
var route: String = "all"
|
||||
|
||||
@DatabaseField
|
||||
var remoteDns: String = "8.8.8.8"
|
||||
|
||||
@DatabaseField
|
||||
var proxyApps: Boolean = false
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ object Key {
|
||||
val method = "encMethod"
|
||||
val remotePort = "remotePortNum"
|
||||
val localPort = "localPortNum"
|
||||
val remoteDns = "remoteDns"
|
||||
|
||||
val profileTip = "profileTip"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user