Refactor hev tunnel timeout settings

Changed hev tunnel read/write timeout preference to accept separate TCP and UDP values in seconds (default 300,60). Updated related keys, default values, and UI strings across multiple languages to reflect the new format and units.
https://github.com/2dust/v2rayNG/issues/5057
This commit is contained in:
2dust
2025-12-24 20:07:34 +08:00
parent 60ddf5ba6b
commit cfae051109
12 changed files with 23 additions and 16 deletions
@@ -65,7 +65,7 @@ object AppConfig {
const val PREF_GEO_FILES_SOURCES = "pref_geo_files_sources"
const val PREF_USE_HEV_TUNNEL = "pref_use_hev_tunnel"
const val PREF_HEV_TUNNEL_LOGLEVEL = "pref_hev_tunnel_loglevel"
const val PREF_HEV_TUNNEL_RW_TIMEOUT = "pref_hev_tunnel_rw_timeout"
const val PREF_HEV_TUNNEL_RW_TIMEOUT = "pref_hev_tunnel_rw_timeout_v2"
/** Cache keys. */
const val CACHE_SUBSCRIPTION_ID = "cache_subscription_id"
@@ -173,7 +173,7 @@ object AppConfig {
const val VPN_MTU = 1500
/** hev-sock5-tunnel read-write-timeout value */
const val HEVTUN_RW_TIMEOUT = "300000"
const val HEVTUN_RW_TIMEOUT = "300,60"
// Google API rule constants
const val GOOGLEAPIS_CN_DOMAIN = "domain:googleapis.cn"
@@ -71,9 +71,17 @@ class TProxyService(
appendLine(" address: ${AppConfig.LOOPBACK}")
appendLine(" udp: 'udp'")
// Read-write timeout settings
val timeoutSetting = MmkvManager.decodeSettingsString(AppConfig.PREF_HEV_TUNNEL_RW_TIMEOUT) ?: AppConfig.HEVTUN_RW_TIMEOUT
val parts = timeoutSetting.split(",")
.map { it.trim() }
.filter { it.isNotEmpty() }
val tcpTimeout = parts.getOrNull(0)?.toIntOrNull() ?: 300
val udpTimeout = parts.getOrNull(1)?.toIntOrNull() ?: 60
appendLine("misc:")
appendLine(" tcp-read-write-timeout: ${MmkvManager.decodeSettingsString(AppConfig.PREF_HEV_TUNNEL_RW_TIMEOUT) ?: AppConfig.HEVTUN_RW_TIMEOUT}")
appendLine(" udp-read-write-timeout: ${MmkvManager.decodeSettingsString(AppConfig.PREF_HEV_TUNNEL_RW_TIMEOUT) ?: AppConfig.HEVTUN_RW_TIMEOUT}")
appendLine(" tcp-read-write-timeout: ${tcpTimeout * 1000}")
appendLine(" udp-read-write-timeout: ${udpTimeout * 1000}")
appendLine(" log-level: ${MmkvManager.decodeSettingsString(AppConfig.PREF_HEV_TUNNEL_LOGLEVEL) ?: "warn"}")
}
}