diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt index de459673..cbc67e9b 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt @@ -41,6 +41,7 @@ class AngApplication : MultiDexApplication() { WorkManager.initialize(this, workManagerConfiguration) SettingsManager.initRoutingRulesets(this) + SettingsManager.migrateHysteria2PinSHA256() es.dmoral.toasty.Toasty.Config.getInstance() .setGravity(android.view.Gravity.BOTTOM, 0, 200) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/dto/ProfileItem.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/dto/ProfileItem.kt index 843c7f61..4fe07730 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/dto/ProfileItem.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/dto/ProfileItem.kt @@ -124,7 +124,7 @@ data class ProfileItem( && this.obfsPassword == obj.obfsPassword && this.portHopping == obj.portHopping && this.portHoppingInterval == obj.portHoppingInterval - && this.pinSHA256 == obj.pinSHA256 + && this.pinnedCA256 == obj.pinnedCA256 ) } } \ No newline at end of file diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/Hysteria2Fmt.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/Hysteria2Fmt.kt index cfc127b2..1107e448 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/Hysteria2Fmt.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/Hysteria2Fmt.kt @@ -44,7 +44,7 @@ object Hysteria2Fmt : FmtBase() { if (config.portHopping.isNotNullEmpty()) { config.portHoppingInterval = queryParam["mportHopInt"] } - config.pinSHA256 = queryParam["pinSHA256"] + config.pinnedCA256 = queryParam["pinSHA256"] } @@ -75,8 +75,8 @@ object Hysteria2Fmt : FmtBase() { if (config.portHoppingInterval.isNotNullEmpty()) { dicQuery["mportHopInt"] = config.portHoppingInterval.orEmpty() } - if (config.pinSHA256.isNotNullEmpty()) { - dicQuery["pinSHA256"] = config.pinSHA256.orEmpty() + if (config.pinnedCA256.isNotNullEmpty()) { + dicQuery["pinSHA256"] = config.pinnedCA256.orEmpty() } return toUri(config, config.password, dicQuery) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt index 35cc4c5f..46fdb412 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt @@ -16,6 +16,7 @@ import com.v2ray.ang.enums.Language import com.v2ray.ang.dto.ProfileItem import com.v2ray.ang.enums.RoutingType import com.v2ray.ang.dto.RulesetItem +import com.v2ray.ang.dto.ServersCache import com.v2ray.ang.dto.V2rayConfig import com.v2ray.ang.enums.VpnInterfaceAddressConfig import com.v2ray.ang.handler.MmkvManager.decodeServerConfig @@ -422,4 +423,30 @@ object SettingsManager { MmkvManager.encodeSettings(key, default) } } + + fun migrateHysteria2PinSHA256() { + // Check if migration has already been done + val migrationKey = "hysteria2_pin_sha256_migrated" + if (MmkvManager.decodeSettingsBool(migrationKey, false)) { + return + } + + val serverList = decodeServerList() + + for (guid in serverList) { + val profile = decodeServerConfig(guid) ?: continue + if (profile.configType != EConfigType.HYSTERIA2) { + continue + } + if (profile.pinSHA256.isNullOrEmpty() || !profile.pinnedCA256.isNullOrEmpty()) { + continue + } + profile.pinnedCA256 = profile.pinSHA256 + profile.pinSHA256 = null + MmkvManager.encodeServerConfig(guid, profile) + } + + MmkvManager.encodeSettings(migrationKey, true) + } + } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ServerActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ServerActivity.kt index 8f25052f..636c323b 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ServerActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ServerActivity.kt @@ -129,7 +129,6 @@ class ServerActivity : BaseActivity() { private val et_obfs_password: EditText? by lazy { findViewById(R.id.et_obfs_password) } private val et_port_hop: EditText? by lazy { findViewById(R.id.et_port_hop) } private val et_port_hop_interval: EditText? by lazy { findViewById(R.id.et_port_hop_interval) } - private val et_pinsha256: EditText? by lazy { findViewById(R.id.et_pinsha256) } private val et_bandwidth_down: EditText? by lazy { findViewById(R.id.et_bandwidth_down) } private val et_bandwidth_up: EditText? by lazy { findViewById(R.id.et_bandwidth_up) } private val et_extra: EditText? by lazy { findViewById(R.id.et_extra) } @@ -367,7 +366,6 @@ class ServerActivity : BaseActivity() { et_obfs_password?.text = Utils.getEditable(config.obfsPassword) et_port_hop?.text = Utils.getEditable(config.portHopping) et_port_hop_interval?.text = Utils.getEditable(config.portHoppingInterval) - et_pinsha256?.text = Utils.getEditable(config.pinSHA256) et_bandwidth_down?.text = Utils.getEditable(config.bandwidthDown) et_bandwidth_up?.text = Utils.getEditable(config.bandwidthUp) } @@ -536,7 +534,6 @@ class ServerActivity : BaseActivity() { config.obfsPassword = et_obfs_password?.text?.toString() config.portHopping = et_port_hop?.text?.toString() config.portHoppingInterval = et_port_hop_interval?.text?.toString() - config.pinSHA256 = et_pinsha256?.text?.toString() config.bandwidthDown = et_bandwidth_down?.text?.toString() config.bandwidthUp = et_bandwidth_up?.text?.toString() } diff --git a/V2rayNG/app/src/main/res/layout/layout_tls_hysteria2.xml b/V2rayNG/app/src/main/res/layout/layout_tls_hysteria2.xml index fc279bcb..f3eadc5f 100644 --- a/V2rayNG/app/src/main/res/layout/layout_tls_hysteria2.xml +++ b/V2rayNG/app/src/main/res/layout/layout_tls_hysteria2.xml @@ -80,10 +80,10 @@ + android:text="@string/server_lab_pinned_ca256" /> diff --git a/V2rayNG/app/src/main/res/values-ar/strings.xml b/V2rayNG/app/src/main/res/values-ar/strings.xml index 93f65389..277b0cbc 100644 --- a/V2rayNG/app/src/main/res/values-ar/strings.xml +++ b/V2rayNG/app/src/main/res/values-ar/strings.xml @@ -109,7 +109,6 @@ Obfs password Port Hopping Port Hopping Interval - pinSHA256 Bandwidth down (Supported units: k/m/g/t) Bandwidth up (Supported units: k/m/g/t) XHTTP Mode diff --git a/V2rayNG/app/src/main/res/values-bn/strings.xml b/V2rayNG/app/src/main/res/values-bn/strings.xml index b72b0f30..863c9a4a 100644 --- a/V2rayNG/app/src/main/res/values-bn/strings.xml +++ b/V2rayNG/app/src/main/res/values-bn/strings.xml @@ -108,7 +108,6 @@ Obfs password Port Hopping Port Hopping Interval - pinSHA256 Bandwidth down (Supported units: k/m/g/t) Bandwidth up (Supported units: k/m/g/t) XHTTP Mode diff --git a/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml b/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml index a804cacc..953f55bb 100644 --- a/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml +++ b/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml @@ -108,7 +108,6 @@ رزم obfs پورت گوم (درگا سرورن ز نۊ هؽل اکونه) فاسله پورت گوم (سانیه) - pinSHA256 ب لم ٱووڌن پئنا باند (واهڌ) وا روء رئڌن پئنا باند (واهڌ) هالت XHTTP diff --git a/V2rayNG/app/src/main/res/values-fa/strings.xml b/V2rayNG/app/src/main/res/values-fa/strings.xml index 4f356a91..6bc10901 100644 --- a/V2rayNG/app/src/main/res/values-fa/strings.xml +++ b/V2rayNG/app/src/main/res/values-fa/strings.xml @@ -108,7 +108,6 @@ رمز عبور obfs پورت پرش (درگاه سرور را بازنویسی می کند) فاصله پورت پرش (ثانیه) - pinSHA256 کاهش پهنای باند (واحد) افزایش پهنای باند (واحد) حالت XHTTP diff --git a/V2rayNG/app/src/main/res/values-ru/strings.xml b/V2rayNG/app/src/main/res/values-ru/strings.xml index 273f04f8..3d9adecb 100644 --- a/V2rayNG/app/src/main/res/values-ru/strings.xml +++ b/V2rayNG/app/src/main/res/values-ru/strings.xml @@ -108,7 +108,6 @@ Пароль obfs Смена портов (переопределяет порт) Интервал смены портов - pinSHA256 Входящая пропускная способность (допускаются: k/m/g/t) Исходящая пропускная способность (допускаются: k/m/g/t) Режим XHTTP diff --git a/V2rayNG/app/src/main/res/values-vi/strings.xml b/V2rayNG/app/src/main/res/values-vi/strings.xml index 0b62575f..99779ed8 100644 --- a/V2rayNG/app/src/main/res/values-vi/strings.xml +++ b/V2rayNG/app/src/main/res/values-vi/strings.xml @@ -108,7 +108,6 @@ Obfs password Port Hopping Port Hopping Interval - pinSHA256 Bandwidth down (Supported units: k/m/g/t) Bandwidth up (Supported units: k/m/g/t) XHTTP Mode diff --git a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml index 18f2044b..87ff259c 100644 --- a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml @@ -108,7 +108,6 @@ 混淆密码 跳跃端口 (会覆盖服务器端口) 端口跳跃间隔 (秒) - SHA256 证书指纹 带宽下行 (支持的单位 k/m/g/t) 带宽上行 (支持的单位 k/m/g/t) XHTTP 模式 diff --git a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml index ffc1ab00..2fac4392 100644 --- a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml @@ -108,7 +108,6 @@ 混淆密碼 跳躍連接埠 (會覆蓋伺服器連接埠) 連接埠跳躍間隔 (秒) - SHA256 憑證指紋 頻寬下行 (支持的單位 k/m/g/t) 頻寬上行 (支持的單位 k/m/g/t) XHTTP 模式 diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index 561ad994..0cf42460 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -109,7 +109,6 @@ Obfs password Port Hopping(will override the port) Port Hopping Interval - pinSHA256 Bandwidth down (Supported units: k/m/g/t) Bandwidth up (Supported units: k/m/g/t) XHTTP Mode