Skip to content

Commit

Permalink
Merge pull request #468 from yuhan6665/cleanup-config
Browse files Browse the repository at this point in the history
Remove legacy "connectionReuse" in config
  • Loading branch information
2dust authored Jul 18, 2020
2 parents ca254b2 + ad56106 commit 28639cc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 36 deletions.
31 changes: 15 additions & 16 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,21 @@ data class V2rayConfig(

data class StreamSettingsBean(var network: String,
var security: String,
var tcpSettings: TcpsettingsBean?,
var kcpsettings: KcpsettingsBean?,
var wssettings: WssettingsBean?,
var httpsettings: HttpsettingsBean?,
var tlssettings: TlssettingsBean?,
var quicsettings: QuicsettingBean?
var tcpSettings: TcpSettingsBean?,
var kcpSettings: KcpSettingsBean?,
var wsSettings: WsSettingsBean?,
var httpSettings: HttpSettingsBean?,
var tlsSettings: TlsSettingsBean?,
var quicSettings: QuicSettingBean?
) {

data class TcpsettingsBean(var connectionReuse: Boolean = true,
var header: HeaderBean = HeaderBean()) {
data class TcpSettingsBean(var header: HeaderBean = HeaderBean()) {
data class HeaderBean(var type: String = "none",
var request: Any? = null,
var response: Any? = null)
}

data class KcpsettingsBean(var mtu: Int = 1350,
data class KcpSettingsBean(var mtu: Int = 1350,
var tti: Int = 20,
var uplinkCapacity: Int = 12,
var downlinkCapacity: Int = 100,
Expand All @@ -90,20 +89,20 @@ data class V2rayConfig(
data class HeaderBean(var type: String = "none")
}

data class WssettingsBean(var connectionReuse: Boolean = true,
var path: String = "",
data class WsSettingsBean(var path: String = "",
var headers: HeadersBean = HeadersBean()) {
data class HeadersBean(var Host: String = "")
}

data class HttpsettingsBean(var host: List<String> = ArrayList<String>(), var path: String = "")
data class HttpSettingsBean(var host: List<String> = ArrayList(),
var path: String = "")

data class TlssettingsBean(var allowInsecure: Boolean = true,
data class TlsSettingsBean(var allowInsecure: Boolean = true,
var serverName: String = "")

data class QuicsettingBean(var security: String = "none",
var key: String = "",
var header: HeaderBean = HeaderBean()) {
data class QuicSettingBean(var security: String = "none",
var key: String = "",
var header: HeaderBean = HeaderBean()) {
data class HeaderBean(var type: String = "none")
}
}
Expand Down
37 changes: 17 additions & 20 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.v2ray.ang.AngApplication
import com.v2ray.ang.AppConfig
import com.v2ray.ang.dto.AngConfig.VmessBean
import com.v2ray.ang.dto.V2rayConfig
import com.v2ray.ang.extension.defaultDPreference
import com.v2ray.ang.ui.SettingsActivity
import org.json.JSONException
import org.json.JSONObject
Expand Down Expand Up @@ -246,74 +245,72 @@ object V2rayConfigUtil {
//streamSettings
when (streamSettings.network) {
"kcp" -> {
val kcpsettings = V2rayConfig.OutboundBean.StreamSettingsBean.KcpsettingsBean()
val kcpsettings = V2rayConfig.OutboundBean.StreamSettingsBean.KcpSettingsBean()
kcpsettings.mtu = 1350
kcpsettings.tti = 50
kcpsettings.uplinkCapacity = 12
kcpsettings.downlinkCapacity = 100
kcpsettings.congestion = false
kcpsettings.readBufferSize = 1
kcpsettings.writeBufferSize = 1
kcpsettings.header = V2rayConfig.OutboundBean.StreamSettingsBean.KcpsettingsBean.HeaderBean()
kcpsettings.header = V2rayConfig.OutboundBean.StreamSettingsBean.KcpSettingsBean.HeaderBean()
kcpsettings.header.type = vmess.headerType
streamSettings.kcpsettings = kcpsettings
streamSettings.kcpSettings = kcpsettings
}
"ws" -> {
val wssettings = V2rayConfig.OutboundBean.StreamSettingsBean.WssettingsBean()
wssettings.connectionReuse = true
val wssettings = V2rayConfig.OutboundBean.StreamSettingsBean.WsSettingsBean()
val host = vmess.requestHost.trim()
val path = vmess.path.trim()

if (!TextUtils.isEmpty(host)) {
wssettings.headers = V2rayConfig.OutboundBean.StreamSettingsBean.WssettingsBean.HeadersBean()
wssettings.headers = V2rayConfig.OutboundBean.StreamSettingsBean.WsSettingsBean.HeadersBean()
wssettings.headers.Host = host
}
if (!TextUtils.isEmpty(path)) {
wssettings.path = path
}
streamSettings.wssettings = wssettings
streamSettings.wsSettings = wssettings

val tlssettings = V2rayConfig.OutboundBean.StreamSettingsBean.TlssettingsBean()
val tlssettings = V2rayConfig.OutboundBean.StreamSettingsBean.TlsSettingsBean()
tlssettings.allowInsecure = true
if (!TextUtils.isEmpty(host)) {
tlssettings.serverName = host
}
streamSettings.tlssettings = tlssettings
streamSettings.tlsSettings = tlssettings
}
"h2" -> {
val httpsettings = V2rayConfig.OutboundBean.StreamSettingsBean.HttpsettingsBean()
val httpsettings = V2rayConfig.OutboundBean.StreamSettingsBean.HttpSettingsBean()
val host = vmess.requestHost.trim()
val path = vmess.path.trim()

if (!TextUtils.isEmpty(host)) {
httpsettings.host = host.split(",").map { it.trim() }
}
httpsettings.path = path
streamSettings.httpsettings = httpsettings
streamSettings.httpSettings = httpsettings

val tlssettings = V2rayConfig.OutboundBean.StreamSettingsBean.TlssettingsBean()
val tlssettings = V2rayConfig.OutboundBean.StreamSettingsBean.TlsSettingsBean()
tlssettings.allowInsecure = true
streamSettings.tlssettings = tlssettings
streamSettings.tlsSettings = tlssettings
}
"quic" -> {
val quicsettings = V2rayConfig.OutboundBean.StreamSettingsBean.QuicsettingBean()
val quicsettings = V2rayConfig.OutboundBean.StreamSettingsBean.QuicSettingBean()
val host = vmess.requestHost.trim()
val path = vmess.path.trim()

quicsettings.security = host
quicsettings.key = path

quicsettings.header = V2rayConfig.OutboundBean.StreamSettingsBean.QuicsettingBean.HeaderBean()
quicsettings.header = V2rayConfig.OutboundBean.StreamSettingsBean.QuicSettingBean.HeaderBean()
quicsettings.header.type = vmess.headerType

streamSettings.quicsettings = quicsettings
streamSettings.quicSettings = quicsettings
}
else -> {
//tcp带http伪装
if (vmess.headerType == "http") {
val tcpSettings = V2rayConfig.OutboundBean.StreamSettingsBean.TcpsettingsBean()
tcpSettings.connectionReuse = true
tcpSettings.header = V2rayConfig.OutboundBean.StreamSettingsBean.TcpsettingsBean.HeaderBean()
val tcpSettings = V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean()
tcpSettings.header = V2rayConfig.OutboundBean.StreamSettingsBean.TcpSettingsBean.HeaderBean()
tcpSettings.header.type = vmess.headerType

// if (requestObj.has("headers")
Expand Down

0 comments on commit 28639cc

Please sign in to comment.