From 1ba5c5a7a63c545f5632148e4cccf44abfb98651 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:17:03 +0800 Subject: [PATCH] Add xhttp extra --- .../java/com/v2ray/ang/dto/ProfileItem.kt | 1 + .../java/com/v2ray/ang/dto/V2rayConfig.kt | 1 + .../main/java/com/v2ray/ang/fmt/FmtBase.kt | 1 + .../main/java/com/v2ray/ang/fmt/VlessFmt.kt | 3 +++ .../java/com/v2ray/ang/ui/ServerActivity.kt | 17 +++++++++++++- .../src/main/res/layout/layout_transport.xml | 22 +++++++++++++++++++ .../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 | 2 ++ .../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/strings.xml | 1 + 15 files changed, 54 insertions(+), 1 deletion(-) 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 0b7f3430..2112d306 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 @@ -31,6 +31,7 @@ data class ProfileItem( var serviceName: String? = null, var authority: String? = null, var xhttpMode: String? = null, + var xhttpExtra: String? = null, var security: String? = null, var sni: String? = null, 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 31a50561..b3d9fb13 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 @@ -279,6 +279,7 @@ data class V2rayConfig( var path: String? = null, var host: String? = null, var mode: String? = null, + var extra: Any? = 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 d4d76161..1b07a8ad 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 @@ -63,6 +63,7 @@ open class FmtBase { 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() } + config.xhttpExtra.let { if (it.isNotNullEmpty()) dicQuery["extra"] = it.orEmpty() } } NetworkType.HTTP, NetworkType.H2 -> { 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 b828ffac..e4e3bd55 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 @@ -6,6 +6,7 @@ import com.v2ray.ang.dto.ProfileItem import com.v2ray.ang.dto.V2rayConfig.OutboundBean import com.v2ray.ang.extension.idnHost import com.v2ray.ang.handler.MmkvManager +import com.v2ray.ang.util.JsonUtil import com.v2ray.ang.util.Utils import java.net.URI @@ -37,6 +38,7 @@ object VlessFmt : FmtBase() { config.serviceName = queryParam["serviceName"] config.authority = queryParam["authority"] config.xhttpMode = queryParam["mode"] + config.xhttpExtra = queryParam["extra"] config.security = queryParam["security"] config.insecure = if (queryParam["allowInsecure"].isNullOrEmpty()) { @@ -87,6 +89,7 @@ object VlessFmt : FmtBase() { profileItem.authority, ) outboundBean?.streamSettings?.xhttpSettings?.mode = profileItem.xhttpMode + outboundBean?.streamSettings?.xhttpSettings?.extra = JsonUtil.parseString(profileItem.xhttpExtra) 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 dad69f32..e0b2714a 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 @@ -123,6 +123,8 @@ class ServerActivity : BaseActivity() { 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_extra: EditText? by lazy { findViewById(R.id.et_extra) } + private val layout_extra: LinearLayout? by lazy { findViewById(R.id.layout_extra) } override fun onCreate(savedInstanceState: Bundle?) { @@ -216,6 +218,18 @@ class ServerActivity : BaseActivity() { } ) ) + et_extra?.text = Utils.getEditable( + when (networks[position]) { + "splithttp", "xhttp" -> JsonUtil.toJsonPretty(JsonUtil.parseString(config?.xhttpExtra)) + else -> null + }.orEmpty() + ) + + layout_extra?.visibility = + when (networks[position]) { + "splithttp", "xhttp" -> View.VISIBLE + else -> View.GONE + } } override fun onNothingSelected(parent: AdapterView<*>?) { @@ -461,7 +475,7 @@ class ServerActivity : BaseActivity() { if (config.subscriptionId.isEmpty() && !subscriptionId.isNullOrEmpty()) { config.subscriptionId = subscriptionId.orEmpty() } - Log.d(ANG_PACKAGE, JsonUtil.toJsonPretty(config)) + Log.d(ANG_PACKAGE, JsonUtil.toJsonPretty(config)?:"") MmkvManager.encodeServerConfig(editGuid, config) toast(R.string.toast_success) finish() @@ -518,6 +532,7 @@ class ServerActivity : BaseActivity() { profileItem.serviceName = path profileItem.authority = requestHost profileItem.xhttpMode = transportTypes(networks[network])[type] + profileItem.xhttpExtra = et_extra?.text?.toString()?.trim() } private fun saveTls(config: ProfileItem) { diff --git a/V2rayNG/app/src/main/res/layout/layout_transport.xml b/V2rayNG/app/src/main/res/layout/layout_transport.xml index 103a36d3..bda1e11c 100644 --- a/V2rayNG/app/src/main/res/layout/layout_transport.xml +++ b/V2rayNG/app/src/main/res/layout/layout_transport.xml @@ -92,4 +92,26 @@ android:inputType="text" /> + + + + + + + \ No newline at end of file diff --git a/V2rayNG/app/src/main/res/values-ar/strings.xml b/V2rayNG/app/src/main/res/values-ar/strings.xml index 41042e19..eebe57a9 100644 --- a/V2rayNG/app/src/main/res/values-ar/strings.xml +++ b/V2rayNG/app/src/main/res/values-ar/strings.xml @@ -120,6 +120,7 @@ Port Hopping Interval pinSHA256 XHTTP Mode + XHTTP Extra raw JSON, format: { XHTTPObject } جار التحميل diff --git a/V2rayNG/app/src/main/res/values-bn/strings.xml b/V2rayNG/app/src/main/res/values-bn/strings.xml index 0c09b1cc..620796d4 100644 --- a/V2rayNG/app/src/main/res/values-bn/strings.xml +++ b/V2rayNG/app/src/main/res/values-bn/strings.xml @@ -119,6 +119,7 @@ Port Hopping Interval pinSHA256 XHTTP Mode + XHTTP Extra raw JSON, format: { XHTTPObject } লোড হচ্ছে 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 8309964f..9e5d3974 100644 --- a/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml +++ b/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml @@ -107,6 +107,7 @@ ازاف کردن دارایی ازاف کردن فایل ازاف کردن آدرس اینترنتی + Scan QRcode آدرس اینترنتی دانلود فایلا آدرس اینترنتی دارایین ازاف کۊنین @@ -118,6 +119,7 @@ فاسله پورت گوم (سانیه) pinSHA256 XHTTP Mode + XHTTP Extra raw JSON, format: { XHTTPObject } هون بارونی بۊ diff --git a/V2rayNG/app/src/main/res/values-fa/strings.xml b/V2rayNG/app/src/main/res/values-fa/strings.xml index db7a91f5..fb83fe40 100644 --- a/V2rayNG/app/src/main/res/values-fa/strings.xml +++ b/V2rayNG/app/src/main/res/values-fa/strings.xml @@ -113,6 +113,7 @@ فاصله پورت پرش (ثانیه) pinSHA256 XHTTP Mode + XHTTP Extra raw JSON, format: { XHTTPObject } URL را اضافه کنید diff --git a/V2rayNG/app/src/main/res/values-ru/strings.xml b/V2rayNG/app/src/main/res/values-ru/strings.xml index fd9c59cf..e32a1e38 100644 --- a/V2rayNG/app/src/main/res/values-ru/strings.xml +++ b/V2rayNG/app/src/main/res/values-ru/strings.xml @@ -118,6 +118,7 @@ Интервал переключения портов pinSHA256 XHTTP Mode + XHTTP Extra raw JSON, format: { XHTTPObject } Загрузка… diff --git a/V2rayNG/app/src/main/res/values-vi/strings.xml b/V2rayNG/app/src/main/res/values-vi/strings.xml index 27c78d8a..1cdcd98c 100644 --- a/V2rayNG/app/src/main/res/values-vi/strings.xml +++ b/V2rayNG/app/src/main/res/values-vi/strings.xml @@ -113,6 +113,7 @@ Port Hopping Interval pinSHA256 XHTTP Mode + XHTTP Extra raw JSON, format: { XHTTPObject } 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 dd82f33e..3254fc9d 100644 --- a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml @@ -113,6 +113,7 @@ 端口跳跃间隔(秒) SHA256证书指纹 XHTTP 模式 + XHTTP Extra 原始 JSON,格式: { XHTTPObject } 添加资产网址 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 1e64aba0..5334ef07 100644 --- a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml @@ -113,6 +113,7 @@ 連接埠跳躍間隔(秒) SHA256憑證指紋 XHTTP 模式 + XHTTP Extra 原始 JSON,格式: { XHTTPObject } 新增資產網址 diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index 3ac2cb29..df17f257 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -119,6 +119,7 @@ Port Hopping Interval pinSHA256 XHTTP Mode + XHTTP Extra raw JSON, format: { XHTTPObject } Loading