diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt index e237ec8e0..1dd315ae2 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt @@ -5,6 +5,9 @@ import android.support.v7.app.AlertDialog import android.text.TextUtils import android.view.Menu import android.view.MenuItem +import android.view.View +import android.widget.AdapterView +import android.widget.ArrayAdapter import com.tencent.mmkv.MMKV import com.v2ray.ang.R import com.v2ray.ang.dto.EConfigType @@ -28,6 +31,7 @@ import kotlinx.android.synthetic.main.activity_server_vmess.et_remarks import kotlinx.android.synthetic.main.activity_server_vmess.et_request_host import kotlinx.android.synthetic.main.activity_server_vmess.sp_allow_insecure import kotlinx.android.synthetic.main.activity_server_vmess.sp_header_type +import kotlinx.android.synthetic.main.activity_server_vmess.sp_header_type_title import kotlinx.android.synthetic.main.activity_server_vmess.sp_network import kotlinx.android.synthetic.main.activity_server_vmess.sp_stream_security @@ -56,8 +60,14 @@ class ServerActivity : BaseActivity() { private val networks: Array by lazy { resources.getStringArray(R.array.networks) } - private val headertypes: Array by lazy { - resources.getStringArray(R.array.headertypes) + private val tcpTypes: Array by lazy { + resources.getStringArray(R.array.header_type_tcp) + } + private val kcpAndQuicTypes: Array by lazy { + resources.getStringArray(R.array.header_type_kcp_and_quic) + } + private val grpcModes: Array by lazy { + resources.getStringArray(R.array.mode_type_grpc) } private val streamSecuritys: Array by lazy { resources.getStringArray(R.array.streamsecurityxs) @@ -79,6 +89,26 @@ class ServerActivity : BaseActivity() { // EConfigType.VLESS -> setContentView(R.layout.activity_server_vless) // EConfigType.TROJAN -> setContentView(R.layout.activity_server_trojan) } + sp_network?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { + override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { + val types = transportTypes(networks[position]) + sp_header_type?.isEnabled = types.size > 1 + val adapter = 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) + config?.getProxyOutbound()?.getTransportSettingDetails()?.let { transportDetails -> + sp_header_type.setSelection(Utils.arrayFind(types, transportDetails[0])) + et_request_host.text = Utils.getEditable(transportDetails[1]) + et_path.text = Utils.getEditable(transportDetails[2]) + } + } + override fun onNothingSelected(parent: AdapterView<*>?) { + // do nothing + } + } if (config != null) { bindingServer(config) } else { @@ -129,11 +159,6 @@ class ServerActivity : BaseActivity() { if (network >= 0) { sp_network?.setSelection(network) } - outbound.getTransportSettingDetails()?.let { transportDetails -> - sp_header_type.setSelection(Utils.arrayFind(headertypes, transportDetails[0])) - et_request_host.text = Utils.getEditable(transportDetails[1]) - et_path.text = Utils.getEditable(transportDetails[2]) - } return true } @@ -246,11 +271,12 @@ class ServerActivity : BaseActivity() { } private fun saveStreamSettings(streamSetting: V2rayConfig.OutboundBean.StreamSettingsBean, config: ServerConfig) { + val network = if (sp_network != null) networks[sp_network.selectedItemPosition] else DEFAULT_NETWORK val requestHost = if (et_request_host != null) et_request_host.text.toString().trim() else "" val path = if (et_path != null) et_path.text.toString().trim() else "" var sni = streamSetting.populateTransportSettings( - if (sp_network != null) networks[sp_network.selectedItemPosition] else DEFAULT_NETWORK, - if (sp_header_type != null) headertypes[sp_header_type.selectedItemPosition] else "", + network, + if (sp_header_type != null) transportTypes(network)[sp_header_type.selectedItemPosition] else "", requestHost, path, path, @@ -270,6 +296,18 @@ class ServerActivity : BaseActivity() { ) } + private fun transportTypes(network: String?): Array { + return if (network == "tcp") { + tcpTypes + } else if (network == "kcp" || network == "quic") { + kcpAndQuicTypes + } else if (network == "grpc") { + grpcModes + } else { + arrayOf("---") + } + } + /** * save server config */ diff --git a/V2rayNG/app/src/main/res/layout/activity_server_vmess.xml b/V2rayNG/app/src/main/res/layout/activity_server_vmess.xml index 593cf3348..69fb9b586 100644 --- a/V2rayNG/app/src/main/res/layout/activity_server_vmess.xml +++ b/V2rayNG/app/src/main/res/layout/activity_server_vmess.xml @@ -174,6 +174,7 @@ android:orientation="vertical"> @@ -181,8 +182,7 @@ + android:layout_height="@dimen/edit_height" /> 传输协议(network) 功能设置(不清楚则保持默认值) 伪装类型(type) + gRPC 传输模式 (mode) 伪装域名(host)(host/ws host/h2 host)/QUIC 加密方式 - path(ws path/h2 path)/QUIC 加密密钥/kcp seed/grpc serviceName + path(ws path/h2 path)/QUIC 加密密钥/kcp seed/gRPC serviceName 底层传输安全(tls) 跳过证书验证(allowInsecure) 服务器地址 diff --git a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml index 416dbf7f6..dd6ac7117 100644 --- a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml @@ -43,8 +43,9 @@ 網路 更多功能 標頭類型 + gRPC 傳輸模式 (mode) 要求主機(host)(host/ws host/h2 host)/QUIC加密方式 - path(ws path/h2 path)/QUIC加密密鑰/kcp seed/grpc serviceName + path(ws path/h2 path)/QUIC加密密鑰/kcp seed/gRPC serviceName 傳輸層安全性(tls) 跳過證書驗證(allowInsecure) 伺服器位址 diff --git a/V2rayNG/app/src/main/res/values/arrays.xml b/V2rayNG/app/src/main/res/values/arrays.xml index 3a690f7be..98f2f609c 100644 --- a/V2rayNG/app/src/main/res/values/arrays.xml +++ b/V2rayNG/app/src/main/res/values/arrays.xml @@ -27,9 +27,13 @@ grpc - + none http + + + + none srtp utp wechat-video @@ -37,18 +41,10 @@ wireguard - - none - http - - - - none - srtp - utp - wechat-video - dtls - wireguard + + gun + multi + diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index 06782022b..334aecae9 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -40,11 +40,12 @@ id alterId security - network + Network more function head type + gRPC mode request host(host/ws host/h2 host)/QUIC security - path(ws path/h2 path)/QUIC key/kcp seed/grpc serviceName + path(ws path/h2 path)/QUIC key/kcp seed/gRPC serviceName tls allowInsecure address