Add xhttp extra

This commit is contained in:
2dust
2024-11-19 10:17:03 +08:00
parent f67af69dda
commit 1ba5c5a7a6
15 changed files with 54 additions and 1 deletions

View File

@@ -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,

View File

@@ -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(

View File

@@ -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 -> {

View File

@@ -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(),

View File

@@ -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) {

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>
@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>