@@ -14,7 +14,7 @@ import okhttp3.HttpUrl.Companion.toHttpUrl
1414import org.json.JSONObject
1515
1616private val supportedKcpHeaderType = arrayOf(
17- " none" , " srtp" , " utp" , " wechat-video" , " dtls" , " wireguard"
17+ " none" , " srtp" , " utp" , " wechat-video" , " dtls" , " wireguard" , " dns "
1818)
1919
2020data class VmessQRCode (
@@ -221,8 +221,19 @@ fun StandardV2RayBean.parseDuckSoft(url: HttpUrl) {
221221 mKcpSeed = it
222222 }
223223 url.queryParameter(" headerType" )?.let {
224- if (it !in supportedKcpHeaderType) error(" unsupported headerType" )
225- headerType = it
224+ if (it.isNotBlank()) {
225+ if (it !in supportedKcpHeaderType) error(" unsupported headerType" )
226+ headerType = it
227+ }
228+ }
229+ url.queryParameter(" mtu" )?.let {
230+ kcpMtu = it.toIntOrNull()
231+ }
232+ url.queryParameter(" tti" )?.let {
233+ kcpTti = it.toIntOrNull()
234+ }
235+ url.queryParameter(" cwnd" )?.let {
236+ kcpCwndMultiplier = it.toIntOrNull()
226237 }
227238 }
228239
@@ -532,6 +543,15 @@ fun StandardV2RayBean.toUriVMessVLESSTrojan(isTrojan: Boolean): String {
532543 if (mKcpSeed.isNotBlank()) {
533544 builder.addQueryParameter(" seed" , mKcpSeed)
534545 }
546+ if (kcpMtu != null && kcpMtu!! > 0 ) {
547+ builder.addQueryParameter(" mtu" , kcpMtu.toString())
548+ }
549+ if (kcpTti != null && kcpTti!! > 0 ) {
550+ builder.addQueryParameter(" tti" , kcpTti.toString())
551+ }
552+ if (kcpCwndMultiplier != null && kcpCwndMultiplier!! > 0 ) {
553+ builder.addQueryParameter(" cwnd" , kcpCwndMultiplier.toString())
554+ }
535555 }
536556
537557 " xhttp" -> {
@@ -637,13 +657,16 @@ fun buildSingBoxOutboundStreamSettings(bean: StandardV2RayBean): V2RayTransportO
637657 " kcp" -> {
638658 return V2RayTransportOptions_KCPOptions ().apply {
639659 type = " kcp"
640- mtu = 1350
641- tti = 50
660+ mtu = if (bean.kcpMtu != null && bean.kcpMtu !! > 0 ) bean.kcpMtu !! else 1350
661+ tti = if (bean.kcpTti != null && bean.kcpTti !! > 0 ) bean.kcpTti !! else 50
642662 uplink_capacity = 12
643663 downlink_capacity = 100
644664 congestion = false
645665 read_buffer_size = 1
646666 write_buffer_size = 1
667+ if (bean.kcpCwndMultiplier != null && bean.kcpCwndMultiplier!! > 0 ) {
668+ cwnd_multiplier = bean.kcpCwndMultiplier!!
669+ }
647670 header_type = bean.headerType.takeIf { it.isNotBlank() } ? : " none"
648671 if (bean.mKcpSeed.isNotBlank()) {
649672 seed = bean.mKcpSeed
0 commit comments