Skip to content

Commit

Permalink
Add xhttp mode
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Nov 18, 2024
1 parent ab22bb9 commit 5d47777
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 10 deletions.
2 changes: 2 additions & 0 deletions V2rayNG/app/src/main/java/com/v2ray/ang/dto/ProfileItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions V2rayNG/app/src/main/java/com/v2ray/ang/dto/V2rayConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 7 additions & 2 deletions V2rayNG/app/src/main/java/com/v2ray/ang/fmt/FmtBase.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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() }
Expand Down
2 changes: 2 additions & 0 deletions V2rayNG/app/src/main/java/com/v2ray/ang/fmt/VlessFmt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -85,6 +86,7 @@ object VlessFmt : FmtBase() {
profileItem.serviceName,
profileItem.authority,
)
outboundBean?.streamSettings?.xhttpSettings?.mode = profileItem.xhttpMode

outboundBean?.streamSettings?.populateTlsSettings(
profileItem.security.orEmpty(),
Expand Down
23 changes: 18 additions & 5 deletions V2rayNG/app/src/main/java/com/v2ray/ang/ui/ServerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class ServerActivity : BaseActivity() {
private val alpns: Array<out String> by lazy {
resources.getStringArray(R.array.streamsecurity_alpn)
}
private val xhttpMode: Array<out String> 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
Expand Down Expand Up @@ -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()
)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -552,6 +561,10 @@ class ServerActivity : BaseActivity() {
grpcModes
}

"xhttp" -> {
xhttpMode
}

else -> {
arrayOf("---")
}
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<string name="server_lab_port_hop">Port Hopping</string>
<string name="server_lab_port_hop_interval">Port Hopping Interval</string>
<string name="server_lab_stream_pinsha256">pinSHA256</string>
<string name="server_lab_xhttp_mode">XHTTP Mode</string>

<!-- PerAppProxyActivity -->
<string name="msg_dialog_progress">جار التحميل</string>
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/res/values-bn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<string name="server_lab_port_hop">Port Hopping</string>
<string name="server_lab_port_hop_interval">Port Hopping Interval</string>
<string name="server_lab_stream_pinsha256">pinSHA256</string>
<string name="server_lab_xhttp_mode">XHTTP Mode</string>

<!-- PerAppProxyActivity -->
<string name="msg_dialog_progress">লোড হচ্ছে</string>
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<string name="server_lab_port_hop">پورت گوم (درگا سرورن ز نۊ هؽل اکونه)</string>
<string name="server_lab_port_hop_interval">فاسله پورت گوم (سانیه)</string>
<string name="server_lab_stream_pinsha256">pinSHA256</string>
<string name="server_lab_xhttp_mode">XHTTP Mode</string>

<!-- PerAppProxyActivity -->
<string name="msg_dialog_progress">هون بارونی بۊ</string>
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<string name="server_lab_port_hop">پورت پرش (درگاه سرور را بازنویسی می کند)</string>
<string name="server_lab_port_hop_interval">فاصله پورت پرش (ثانیه)</string>
<string name="server_lab_stream_pinsha256">pinSHA256</string>
<string name="server_lab_xhttp_mode">XHTTP Mode</string>

<!-- PerAppProxyActivity -->
<string name="title_user_asset_add_url">URL را اضافه کنید</string>
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<string name="server_lab_port_hop">Переключение портов</string>
<string name="server_lab_port_hop_interval">Интервал переключения портов</string>
<string name="server_lab_stream_pinsha256">pinSHA256</string>
<string name="server_lab_xhttp_mode">XHTTP Mode</string>

<!-- PerAppProxyActivity -->
<string name="msg_dialog_progress">Загрузка…</string>
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<string name="server_lab_port_hop">Port Hopping</string>
<string name="server_lab_port_hop_interval">Port Hopping Interval</string>
<string name="server_lab_stream_pinsha256">pinSHA256</string>
<string name="server_lab_xhttp_mode">XHTTP Mode</string>

<!-- PerAppProxyActivity -->
<string name="title_user_asset_add_url">Thêm URL nội dung</string>
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<string name="server_lab_port_hop">跳跃端口(会覆盖服务器端口)</string>
<string name="server_lab_port_hop_interval">端口跳跃间隔(秒)</string>
<string name="server_lab_stream_pinsha256">SHA256证书指纹</string>
<string name="server_lab_xhttp_mode">XHTTP 模式</string>

<!-- PerAppProxyActivity -->
<string name="title_user_asset_add_url">添加资产网址</string>
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<string name="server_lab_port_hop">跳躍連接埠(會覆蓋伺服器連接埠)</string>
<string name="server_lab_port_hop_interval">連接埠跳躍間隔(秒)</string>
<string name="server_lab_stream_pinsha256">SHA256憑證指紋</string>
<string name="server_lab_xhttp_mode">XHTTP 模式</string>

<!-- PerAppProxyActivity -->
<string name="title_user_asset_add_url">新增資產網址</string>
Expand Down
8 changes: 7 additions & 1 deletion V2rayNG/app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,10 @@
<item>direct</item>
<item>block</item>
</string-array>
</resources>

<string-array name="xhttp_mode" translatable="false">
<item>auto</item>
<item>packet-up</item>
<item>stream-up</item>
</string-array>
</resources>
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<string name="server_lab_port_hop">Port Hopping(will override the port)</string>
<string name="server_lab_port_hop_interval">Port Hopping Interval</string>
<string name="server_lab_stream_pinsha256">pinSHA256</string>
<string name="server_lab_xhttp_mode">XHTTP Mode</string>

<!-- PerAppProxyActivity -->
<string name="msg_dialog_progress">Loading</string>
Expand Down

0 comments on commit 5d47777

Please sign in to comment.