Skip to content

Commit ae4a92b

Browse files
Q7DF12dustCopilot
authored
add finalmask into share link and support import manually (#5429)
* add finalmask into share link and support import manually * remove temp test code * Update V2rayNG/app/src/main/res/values/strings.xml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update V2rayNG/app/src/main/java/com/v2ray/ang/ui/ServerActivity.kt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update V2rayNG/app/src/main/java/com/v2ray/ang/fmt/FmtBase.kt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Make finalmask Any and parse as raw string --------- Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 55c0ccf commit ae4a92b

File tree

8 files changed

+68
-5
lines changed

8 files changed

+68
-5
lines changed

V2rayNG/app/src/main/java/com/v2ray/ang/dto/ProfileItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ data class ProfileItem(
3636
var authority: String? = null,
3737
var xhttpMode: String? = null,
3838
var xhttpExtra: String? = null,
39-
39+
var finalMask: String? = null,
4040
var security: String? = null,
4141
var sni: String? = null,
4242
var alpn: String? = null,

V2rayNG/app/src/main/java/com/v2ray/ang/dto/V2rayConfig.kt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ data class V2rayConfig(
162162
var realitySettings: TlsSettingsBean? = null,
163163
var grpcSettings: GrpcSettingsBean? = null,
164164
var hysteriaSettings: HysteriaSettingsBean? = null,
165-
var finalmask: FinalMaskBean? = null,
165+
var finalmask: Any? = null,
166166
val dsSettings: Any? = null,
167167
var sockopt: SockoptBean? = null
168168
) {
@@ -303,9 +303,11 @@ data class V2rayConfig(
303303
)
304304
}
305305

306+
//https://xtls.github.io/config/transport.html#finalmaskobject
306307
data class FinalMaskBean(
307308
var tcp: List<MaskBean>? = null,
308-
var udp: List<MaskBean>? = null
309+
var udp: List<MaskBean>? = null,
310+
var quicParams: QuicParamsBean? = null
309311
) {
310312
data class MaskBean(
311313
var type: String,
@@ -316,6 +318,28 @@ data class V2rayConfig(
316318
var domain: String? = null
317319
)
318320
}
321+
data class QuicParamsBean(
322+
var congestion: String? = null,
323+
var debug: Boolean? = null,
324+
var brutalUp: String? = null,
325+
var brutalDown: Int? = null,
326+
var udpHop: UdpHopBean? = null,
327+
// Using Long for large memory/window size values
328+
var initStreamReceiveWindow: Long? = null,
329+
var maxStreamReceiveWindow: Long? = null,
330+
var initConnectionReceiveWindow: Long? = null,
331+
var maxConnectionReceiveWindow: Long? = null,
332+
var maxIdleTimeout: Int? = null,
333+
var keepAlivePeriod: Int? = null,
334+
var disablePathMTUDiscovery: Boolean? = null,
335+
var maxIncomingStreams: Int? = null
336+
) {
337+
// Nested data class for the udpHop JSON object
338+
data class UdpHopBean(
339+
var ports: String? = null,
340+
var interval: String? = null
341+
)
342+
}
319343
}
320344
}
321345

V2rayNG/app/src/main/java/com/v2ray/ang/fmt/FmtBase.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ open class FmtBase {
6767
config.authority = queryParam["authority"]
6868
config.xhttpMode = queryParam["mode"]
6969
config.xhttpExtra = queryParam["extra"]
70+
config.finalMask = queryParam["fm"]
7071

7172
config.security = queryParam["security"]
7273
if (config.security != AppConfig.TLS && config.security != AppConfig.REALITY) {
@@ -110,6 +111,7 @@ open class FmtBase {
110111
config.spiderX?.nullIfBlank()?.let { dicQuery["spx"] = it }
111112
config.mldsa65Verify?.nullIfBlank()?.let { dicQuery["pqv"] = it }
112113
config.flow?.nullIfBlank()?.let { dicQuery["flow"] = it }
114+
config.finalMask?.nullIfBlank()?.let { dicQuery["fm"] = it }
113115
// Add two keys for compatibility: "insecure" and "allowInsecure"
114116
if (config.security == AppConfig.TLS) {
115117
val insecureFlag = if (config.insecure == true) "1" else "0"

V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2rayConfigManager.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,9 +1174,12 @@ object V2rayConfigManager {
11741174
val authority = profileItem.authority
11751175
val xhttpMode = profileItem.xhttpMode
11761176
val xhttpExtra = profileItem.xhttpExtra
1177-
1177+
val finalMask = profileItem.finalMask
11781178
var sni: String? = null
11791179
streamSettings.network = transport.ifEmpty { NetworkType.TCP.type }
1180+
finalMask?.let {
1181+
streamSettings.finalmask = JsonUtil.parseString(finalMask)
1182+
}
11801183
when (streamSettings.network) {
11811184
NetworkType.TCP.type -> {
11821185
val tcpSetting = StreamSettingsBean.TcpSettingsBean()

V2rayNG/app/src/main/java/com/v2ray/ang/ui/ServerActivity.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.v2ray.ang.dto.ProfileItem
2424
import com.v2ray.ang.enums.EConfigType
2525
import com.v2ray.ang.enums.NetworkType
2626
import com.v2ray.ang.extension.isNotNullEmpty
27+
import com.v2ray.ang.extension.nullIfBlank
2728
import com.v2ray.ang.extension.toast
2829
import com.v2ray.ang.extension.toastSuccess
2930
import com.v2ray.ang.handler.AngConfigManager
@@ -132,6 +133,7 @@ class ServerActivity : BaseActivity() {
132133
private val et_bandwidth_down: EditText? by lazy { findViewById(R.id.et_bandwidth_down) }
133134
private val et_bandwidth_up: EditText? by lazy { findViewById(R.id.et_bandwidth_up) }
134135
private val et_extra: EditText? by lazy { findViewById(R.id.et_extra) }
136+
private val et_fm: EditText? by lazy { findViewById(R.id.et_fm) }
135137
private val layout_extra: LinearLayout? by lazy { findViewById(R.id.layout_extra) }
136138
private val et_ech_config_list: EditText? by lazy { findViewById(R.id.et_ech_config_list) }
137139
private val container_ech_config_list: LinearLayout? by lazy { findViewById(R.id.lay_ech_config_list) }
@@ -241,6 +243,7 @@ class ServerActivity : BaseActivity() {
241243
else -> null
242244
}.orEmpty()
243245
)
246+
et_fm?.text = Utils.getEditable(config?.finalMask)
244247

245248
layout_extra?.visibility =
246249
when (networks[position]) {
@@ -489,6 +492,13 @@ class ServerActivity : BaseActivity() {
489492
}
490493
}
491494

495+
if (et_fm?.text?.toString().isNotNullEmpty()) {
496+
if (JsonUtil.parseString(et_fm?.text?.toString()) == null) {
497+
toast(R.string.server_lab_final_mask)
498+
return false
499+
}
500+
}
501+
492502
saveCommon(config)
493503
saveStreamSettings(config)
494504
saveTls(config)
@@ -557,7 +567,8 @@ class ServerActivity : BaseActivity() {
557567
profileItem.serviceName = path
558568
profileItem.authority = requestHost
559569
profileItem.xhttpMode = transportTypes(networks[network])[type]
560-
profileItem.xhttpExtra = et_extra?.text?.toString()?.trim()
570+
profileItem.xhttpExtra = et_extra?.text?.toString()?.trim().nullIfBlank()
571+
profileItem.finalMask = et_fm?.text?.toString()?.trim()?.nullIfBlank()
561572
}
562573

563574
private fun saveTls(config: ProfileItem) {

V2rayNG/app/src/main/res/layout/layout_transport.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,25 @@
118118
android:minLines="4" />
119119
</LinearLayout>
120120

121+
<LinearLayout
122+
android:id="@+id/layout_fm"
123+
android:layout_width="match_parent"
124+
android:layout_height="wrap_content"
125+
android:layout_marginTop="@dimen/padding_spacing_dp16"
126+
android:orientation="vertical">
127+
128+
<TextView
129+
android:layout_width="wrap_content"
130+
android:layout_height="wrap_content"
131+
android:text="@string/server_lab_final_mask" />
132+
133+
<EditText
134+
android:id="@+id/et_fm"
135+
android:layout_width="match_parent"
136+
android:layout_height="wrap_content"
137+
android:gravity="top"
138+
android:inputType="textMultiLine"
139+
android:maxLines="20"
140+
android:minLines="4" />
141+
</LinearLayout>
121142
</LinearLayout>

V2rayNG/app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
<string name="server_lab_bandwidth_up">带宽上行 (支持的单位 k/m/g/t)</string>
113113
<string name="server_lab_xhttp_mode">XHTTP 模式</string>
114114
<string name="server_lab_xhttp_extra">XHTTP Extra 原始 JSON,格式: { XHTTPObject }</string>
115+
<string name="server_lab_final_mask">FinalMask 原始 JSON 格式: { FinalMaskObject }</string>
115116
<string name="server_lab_ech_config_list">EchConfigList</string>
116117
<string name="server_lab_ech_force_query">EchForceQuery</string>
117118
<string name="server_lab_pinned_ca256">证书指纹 (SHA-256)</string>

V2rayNG/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
<string name="server_lab_bandwidth_up">Bandwidth up (Supported units: k/m/g/t)</string>
114114
<string name="server_lab_xhttp_mode">XHTTP Mode</string>
115115
<string name="server_lab_xhttp_extra">XHTTP Extra raw JSON, format: { XHTTPObject }</string>
116+
<string name="server_lab_final_mask">finalMask raw JSON, format: { FinalMaskObject }</string>
116117
<string name="server_lab_ech_config_list">EchConfigList</string>
117118
<string name="server_lab_ech_force_query">EchForceQuery</string>
118119
<string name="server_lab_pinned_ca256">Certificate fingerprint (SHA-256)</string>

0 commit comments

Comments
 (0)