Skip to content

Commit

Permalink
Add xhttp extra
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Nov 19, 2024
1 parent f67af69 commit 1ba5c5a
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 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 @@ -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,
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/java/com/v2ray/ang/dto/V2rayConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/java/com/v2ray/ang/fmt/FmtBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
3 changes: 3 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 @@ -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

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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(),
Expand Down
17 changes: 16 additions & 1 deletion V2rayNG/app/src/main/java/com/v2ray/ang/ui/ServerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down Expand Up @@ -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<*>?) {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 22 additions & 0 deletions V2rayNG/app/src/main/res/layout/layout_transport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,26 @@
android:inputType="text" />
</LinearLayout>

<LinearLayout
android:id="@+id/layout_extra"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_lab_xhttp_extra" />

<EditText
android:id="@+id/et_extra"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:inputType="textMultiLine"
android:maxLines="20"
android:minLines="4" />
</LinearLayout>

</LinearLayout>
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 @@ -120,6 +120,7 @@
<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>
<string name="server_lab_xhttp_extra">XHTTP Extra raw JSON, format: { XHTTPObject }</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 @@ -119,6 +119,7 @@
<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>
<string name="server_lab_xhttp_extra">XHTTP Extra raw JSON, format: { XHTTPObject }</string>

<!-- PerAppProxyActivity -->
<string name="msg_dialog_progress">লোড হচ্ছে</string>
Expand Down
2 changes: 2 additions & 0 deletions V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<string name="menu_item_add_asset">ازاف کردن دارایی</string>
<string name="menu_item_add_file">ازاف کردن فایل</string>
<string name="menu_item_add_url">ازاف کردن آدرس اینترنتی</string>
<string name="menu_item_scan_qrcode">Scan QRcode</string>
<string name="title_url">آدرس اینترنتی</string>
<string name="menu_item_download_file">دانلود فایلا</string>
<string name="title_user_asset_add_url">آدرس اینترنتی دارایین ازاف کۊنین</string>
Expand All @@ -118,6 +119,7 @@
<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>
<string name="server_lab_xhttp_extra">XHTTP Extra raw JSON, format: { XHTTPObject }</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 @@ -113,6 +113,7 @@
<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>
<string name="server_lab_xhttp_extra">XHTTP Extra raw JSON, format: { XHTTPObject }</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 @@ -118,6 +118,7 @@
<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>
<string name="server_lab_xhttp_extra">XHTTP Extra raw JSON, format: { XHTTPObject }</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 @@ -113,6 +113,7 @@
<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>
<string name="server_lab_xhttp_extra">XHTTP Extra raw JSON, format: { XHTTPObject }</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 @@ -113,6 +113,7 @@
<string name="server_lab_port_hop_interval">端口跳跃间隔(秒)</string>
<string name="server_lab_stream_pinsha256">SHA256证书指纹</string>
<string name="server_lab_xhttp_mode">XHTTP 模式</string>
<string name="server_lab_xhttp_extra">XHTTP Extra 原始 JSON,格式: { XHTTPObject }</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 @@ -113,6 +113,7 @@
<string name="server_lab_port_hop_interval">連接埠跳躍間隔(秒)</string>
<string name="server_lab_stream_pinsha256">SHA256憑證指紋</string>
<string name="server_lab_xhttp_mode">XHTTP 模式</string>
<string name="server_lab_xhttp_extra">XHTTP Extra 原始 JSON,格式: { XHTTPObject }</string>

<!-- PerAppProxyActivity -->
<string name="title_user_asset_add_url">新增資產網址</string>
Expand Down
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 @@ -119,6 +119,7 @@
<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>
<string name="server_lab_xhttp_extra">XHTTP Extra raw JSON, format: { XHTTPObject }</string>

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

0 comments on commit 1ba5c5a

Please sign in to comment.