From 5d47777307c11546686b7ba3d2fc53fe5115c232 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:25:13 +0800 Subject: [PATCH] Add xhttp mode --- .../java/com/v2ray/ang/dto/ProfileItem.kt | 2 ++ .../java/com/v2ray/ang/dto/V2rayConfig.kt | 3 +-- .../main/java/com/v2ray/ang/fmt/FmtBase.kt | 9 ++++++-- .../main/java/com/v2ray/ang/fmt/VlessFmt.kt | 2 ++ .../java/com/v2ray/ang/ui/ServerActivity.kt | 23 +++++++++++++++---- .../app/src/main/res/values-ar/strings.xml | 1 + .../app/src/main/res/values-bn/strings.xml | 1 + .../src/main/res/values-bqi-rIR/strings.xml | 1 + .../app/src/main/res/values-fa/strings.xml | 1 + .../app/src/main/res/values-ru/strings.xml | 1 + .../app/src/main/res/values-vi/strings.xml | 1 + .../src/main/res/values-zh-rCN/strings.xml | 1 + .../src/main/res/values-zh-rTW/strings.xml | 1 + V2rayNG/app/src/main/res/values/arrays.xml | 8 ++++++- V2rayNG/app/src/main/res/values/strings.xml | 1 + 15 files changed, 46 insertions(+), 10 deletions(-) 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 4eaac0b5..0b7f3430 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 @@ -30,6 +30,7 @@ data class ProfileItem( var mode: String? = null, var serviceName: String? = null, var authority: String? = null, + var xhttpMode: String? = null, var security: String? = null, var sni: String? = null, @@ -87,6 +88,7 @@ data class ProfileItem( && this.mode == obj.mode && this.serviceName == obj.serviceName && this.authority == obj.authority + && this.xhttpMode == obj.xhttpMode && this.security == obj.security && this.sni == obj.sni diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/dto/V2rayConfig.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/dto/V2rayConfig.kt index e1bc13dd..31a50561 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/dto/V2rayConfig.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/dto/V2rayConfig.kt @@ -278,8 +278,7 @@ data class V2rayConfig( data class XhttpSettingsBean( var path: String? = null, var host: String? = null, - val maxUploadSize: Int? = null, - val maxConcurrentUploads: Int? = null + var mode: String? = null, ) data class HttpSettingsBean( diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/FmtBase.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/FmtBase.kt index eb0a0c97..d4d76161 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/FmtBase.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/FmtBase.kt @@ -1,6 +1,5 @@ package com.v2ray.ang.fmt -import com.v2ray.ang.AppConfig import com.v2ray.ang.dto.NetworkType import com.v2ray.ang.dto.ProfileItem import com.v2ray.ang.extension.isNotNullEmpty @@ -55,11 +54,17 @@ open class FmtBase { config.seed.let { if (it.isNotNullEmpty()) dicQuery["seed"] = it.orEmpty() } } - NetworkType.WS, NetworkType.HTTP_UPGRADE, NetworkType.SPLIT_HTTP, NetworkType.XHTTP -> { + NetworkType.WS, NetworkType.HTTP_UPGRADE -> { config.host.let { if (it.isNotNullEmpty()) dicQuery["host"] = it.orEmpty() } config.path.let { if (it.isNotNullEmpty()) dicQuery["path"] = it.orEmpty() } } + NetworkType.SPLIT_HTTP, NetworkType.XHTTP -> { + config.host.let { if (it.isNotNullEmpty()) dicQuery["host"] = it.orEmpty() } + config.path.let { if (it.isNotNullEmpty()) dicQuery["path"] = it.orEmpty() } + config.xhttpMode.let { if (it.isNotNullEmpty()) dicQuery["mode"] = it.orEmpty() } + } + NetworkType.HTTP, NetworkType.H2 -> { dicQuery["type"] = "http" config.host.let { if (it.isNotNullEmpty()) dicQuery["host"] = it.orEmpty() } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/VlessFmt.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/VlessFmt.kt index 477c101d..b828ffac 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/VlessFmt.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/fmt/VlessFmt.kt @@ -36,6 +36,7 @@ object VlessFmt : FmtBase() { config.mode = queryParam["mode"] config.serviceName = queryParam["serviceName"] config.authority = queryParam["authority"] + config.xhttpMode = queryParam["mode"] config.security = queryParam["security"] config.insecure = if (queryParam["allowInsecure"].isNullOrEmpty()) { @@ -85,6 +86,7 @@ object VlessFmt : FmtBase() { profileItem.serviceName, profileItem.authority, ) + outboundBean?.streamSettings?.xhttpSettings?.mode = profileItem.xhttpMode outboundBean?.streamSettings?.populateTlsSettings( profileItem.security.orEmpty(), 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 4fca2c37..dad69f32 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 @@ -79,6 +79,10 @@ class ServerActivity : BaseActivity() { private val alpns: Array by lazy { resources.getStringArray(R.array.streamsecurity_alpn) } + private val xhttpMode: Array by lazy { + resources.getStringArray(R.array.xhttp_mode) + } + // Kotlin synthetics was used, but since it is removed in 1.8. We switch to old manual approach. // We don't use AndroidViewBinding because, it is better to share similar logics for different @@ -150,14 +154,18 @@ class ServerActivity : BaseActivity() { ArrayAdapter(this@ServerActivity, android.R.layout.simple_spinner_item, types) adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) sp_header_type?.adapter = adapter - sp_header_type_title?.text = if (networks[position] == "grpc") - getString(R.string.server_lab_mode_type) else - getString(R.string.server_lab_head_type) + sp_header_type_title?.text = + when (networks[position]) { + "grpc" -> getString(R.string.server_lab_mode_type) + "xhttp" -> getString(R.string.server_lab_xhttp_mode) + else -> getString(R.string.server_lab_head_type) + }.orEmpty() sp_header_type?.setSelection( Utils.arrayFind( types, when (networks[position]) { "grpc" -> config?.mode + "xhttp" -> config?.xhttpMode else -> config?.headerType }.orEmpty() ) @@ -185,7 +193,7 @@ class ServerActivity : BaseActivity() { "tcp" -> R.string.server_lab_request_host_http "ws" -> R.string.server_lab_request_host_ws "httpupgrade" -> R.string.server_lab_request_host_httpupgrade - "splithttp","xhttp" -> R.string.server_lab_request_host_xhttp + "splithttp", "xhttp" -> R.string.server_lab_request_host_xhttp "h2" -> R.string.server_lab_request_host_h2 //"quic" -> R.string.server_lab_request_host_quic "grpc" -> R.string.server_lab_request_host_grpc @@ -200,7 +208,7 @@ class ServerActivity : BaseActivity() { "kcp" -> R.string.server_lab_path_kcp "ws" -> R.string.server_lab_path_ws "httpupgrade" -> R.string.server_lab_path_httpupgrade - "splithttp","xhttp" -> R.string.server_lab_path_xhttp + "splithttp", "xhttp" -> R.string.server_lab_path_xhttp "h2" -> R.string.server_lab_path_h2 //"quic" -> R.string.server_lab_path_quic "grpc" -> R.string.server_lab_path_grpc @@ -509,6 +517,7 @@ class ServerActivity : BaseActivity() { profileItem.mode = transportTypes(networks[network])[type] profileItem.serviceName = path profileItem.authority = requestHost + profileItem.xhttpMode = transportTypes(networks[network])[type] } private fun saveTls(config: ProfileItem) { @@ -552,6 +561,10 @@ class ServerActivity : BaseActivity() { grpcModes } + "xhttp" -> { + xhttpMode + } + else -> { arrayOf("---") } diff --git a/V2rayNG/app/src/main/res/values-ar/strings.xml b/V2rayNG/app/src/main/res/values-ar/strings.xml index 45b7d054..41042e19 100644 --- a/V2rayNG/app/src/main/res/values-ar/strings.xml +++ b/V2rayNG/app/src/main/res/values-ar/strings.xml @@ -119,6 +119,7 @@ Port Hopping Port Hopping Interval pinSHA256 + 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 0bcd6ace..0c09b1cc 100644 --- a/V2rayNG/app/src/main/res/values-bn/strings.xml +++ b/V2rayNG/app/src/main/res/values-bn/strings.xml @@ -118,6 +118,7 @@ Port Hopping Port Hopping Interval pinSHA256 + 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 ed9ba6b2..8309964f 100644 --- a/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml +++ b/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml @@ -117,6 +117,7 @@ پورت گوم (درگا سرورن ز نۊ هؽل اکونه) فاسله پورت گوم (سانیه) pinSHA256 + XHTTP Mode هون بارونی بۊ diff --git a/V2rayNG/app/src/main/res/values-fa/strings.xml b/V2rayNG/app/src/main/res/values-fa/strings.xml index 183a119d..db7a91f5 100644 --- a/V2rayNG/app/src/main/res/values-fa/strings.xml +++ b/V2rayNG/app/src/main/res/values-fa/strings.xml @@ -112,6 +112,7 @@ پورت پرش (درگاه سرور را بازنویسی می کند) فاصله پورت پرش (ثانیه) pinSHA256 + XHTTP Mode URL را اضافه کنید diff --git a/V2rayNG/app/src/main/res/values-ru/strings.xml b/V2rayNG/app/src/main/res/values-ru/strings.xml index 3eb5dccf..fd9c59cf 100644 --- a/V2rayNG/app/src/main/res/values-ru/strings.xml +++ b/V2rayNG/app/src/main/res/values-ru/strings.xml @@ -117,6 +117,7 @@ Переключение портов Интервал переключения портов pinSHA256 + XHTTP Mode Загрузка… diff --git a/V2rayNG/app/src/main/res/values-vi/strings.xml b/V2rayNG/app/src/main/res/values-vi/strings.xml index f590f92a..27c78d8a 100644 --- a/V2rayNG/app/src/main/res/values-vi/strings.xml +++ b/V2rayNG/app/src/main/res/values-vi/strings.xml @@ -112,6 +112,7 @@ Port Hopping Port Hopping Interval pinSHA256 + XHTTP Mode Thêm URL nội dung 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 5424fa2b..dd82f33e 100644 --- a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml @@ -112,6 +112,7 @@ 跳跃端口(会覆盖服务器端口) 端口跳跃间隔(秒) SHA256证书指纹 + 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 a4f5778f..1e64aba0 100644 --- a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml @@ -112,6 +112,7 @@ 跳躍連接埠(會覆蓋伺服器連接埠) 連接埠跳躍間隔(秒) SHA256憑證指紋 + XHTTP 模式 新增資產網址 diff --git a/V2rayNG/app/src/main/res/values/arrays.xml b/V2rayNG/app/src/main/res/values/arrays.xml index 2f4d58d6..dce02b95 100644 --- a/V2rayNG/app/src/main/res/values/arrays.xml +++ b/V2rayNG/app/src/main/res/values/arrays.xml @@ -205,4 +205,10 @@ direct block - + + + auto + packet-up + stream-up + + \ No newline at end of file diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index 78bf0f75..3ac2cb29 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -118,6 +118,7 @@ Port Hopping(will override the port) Port Hopping Interval pinSHA256 + XHTTP Mode Loading