Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Nov 28, 2024
1 parent 75cc16c commit 49cd3a0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
24 changes: 12 additions & 12 deletions V2rayNG/app/src/main/java/com/v2ray/ang/dto/V2rayConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,11 @@ data class V2rayConfig(
requestObj.headers.Host = host.orEmpty().split(",").map { it.trim() }.filter { it.isNotEmpty() }
requestObj.path = path.orEmpty().split(",").map { it.trim() }.filter { it.isNotEmpty() }
tcpSetting.header.request = requestObj
sni = requestObj.headers.Host?.getOrNull(0) ?: sni
sni = requestObj.headers.Host?.getOrNull(0)
}
} else {
tcpSetting.header.type = "none"
sni = host.orEmpty()
sni = host
}
tcpSettings = tcpSetting
}
Expand All @@ -391,23 +391,23 @@ data class V2rayConfig(
NetworkType.WS.type -> {
val wssetting = WsSettingsBean()
wssetting.headers.Host = host.orEmpty()
sni = wssetting.headers.Host
sni = host
wssetting.path = path ?: "/"
wsSettings = wssetting
}

NetworkType.HTTP_UPGRADE.type -> {
val httpupgradeSetting = HttpupgradeSettingsBean()
httpupgradeSetting.host = host.orEmpty()
sni = httpupgradeSetting.host
sni = host
httpupgradeSetting.path = path ?: "/"
httpupgradeSettings = httpupgradeSetting
}

NetworkType.SPLIT_HTTP.type, NetworkType.XHTTP.type -> {
val xhttpSetting = XhttpSettingsBean()
xhttpSetting.host = host.orEmpty()
sni = xhttpSetting.host
sni = host
xhttpSetting.path = path ?: "/"
xhttpSettings = xhttpSetting
}
Expand All @@ -416,7 +416,7 @@ data class V2rayConfig(
network = NetworkType.H2.type
val h2Setting = HttpSettingsBean()
h2Setting.host = host.orEmpty().split(",").map { it.trim() }.filter { it.isNotEmpty() }
sni = h2Setting.host.getOrNull(0) ?: sni
sni = h2Setting.host.getOrNull(0)
h2Setting.path = path ?: "/"
httpSettings = h2Setting
}
Expand All @@ -436,7 +436,7 @@ data class V2rayConfig(
grpcSetting.authority = authority.orEmpty()
grpcSetting.idle_timeout = 60
grpcSetting.health_check_timeout = 20
sni = authority.orEmpty()
sni = authority
grpcSettings = grpcSetting
}
}
Expand All @@ -457,12 +457,12 @@ data class V2rayConfig(
if (security == null) return
val tlsSetting = TlsSettingsBean(
allowInsecure = allowInsecure,
serverName = sni,
fingerprint = fingerprint,
serverName = if (sni.isNullOrEmpty()) null else sni,
fingerprint = if (fingerprint.isNullOrEmpty()) null else fingerprint,
alpn = if (alpns.isNullOrEmpty()) null else alpns.split(",").map { it.trim() }.filter { it.isNotEmpty() },
publicKey = publicKey,
shortId = shortId,
spiderX = spiderX
publicKey = if (publicKey.isNullOrEmpty()) null else publicKey,
shortId = if (shortId.isNullOrEmpty()) null else shortId,
spiderX = if (spiderX.isNullOrEmpty()) null else spiderX,
)
if (security == AppConfig.TLS) {
tlsSettings = tlsSetting
Expand Down
18 changes: 12 additions & 6 deletions V2rayNG/app/src/main/java/com/v2ray/ang/fmt/ShadowsocksFmt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ object ShadowsocksFmt : FmtBase() {

if (!uri.rawQuery.isNullOrEmpty()) {
val queryParam = getQueryParam(uri)

if (queryParam["plugin"] == "obfs-local" && queryParam["obfs"] == "http") {
if (queryParam["plugin"]?.contains("obfs=http") == true) {
val queryPairs = HashMap<String, String>()
for (pair in queryParam["plugin"]?.split(";") ?: listOf()) {
val idx = pair.split("=")
if (idx.count() == 2) {
queryPairs.put(idx.first(), idx.last())
}
}
config.network = NetworkType.TCP.type
config.headerType = "http"
config.host = queryParam["obfs-host"]
config.path = queryParam["path"]
config.host = queryPairs["obfs-host"]
config.path = queryPairs["path"]
}
}

Expand Down Expand Up @@ -102,7 +108,7 @@ object ShadowsocksFmt : FmtBase() {
server.method = profileItem.method
}

outboundBean?.streamSettings?.populateTransportSettings(
val sni = outboundBean?.streamSettings?.populateTransportSettings(
profileItem.network.orEmpty(),
profileItem.headerType,
profileItem.host,
Expand All @@ -118,7 +124,7 @@ object ShadowsocksFmt : FmtBase() {
outboundBean?.streamSettings?.populateTlsSettings(
profileItem.security.orEmpty(),
profileItem.insecure == true,
profileItem.sni,
if (profileItem.sni.isNullOrEmpty()) sni else profileItem.sni,
profileItem.fingerPrint,
profileItem.alpn,
profileItem.publicKey,
Expand Down
4 changes: 2 additions & 2 deletions V2rayNG/app/src/main/java/com/v2ray/ang/fmt/TrojanFmt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object TrojanFmt : FmtBase() {
server.flow = profileItem.flow
}

outboundBean?.streamSettings?.populateTransportSettings(
val sni = outboundBean?.streamSettings?.populateTransportSettings(
profileItem.network.orEmpty(),
profileItem.headerType,
profileItem.host,
Expand All @@ -68,7 +68,7 @@ object TrojanFmt : FmtBase() {
outboundBean?.streamSettings?.populateTlsSettings(
profileItem.security.orEmpty(),
profileItem.insecure == true,
profileItem.sni,
if (profileItem.sni.isNullOrEmpty()) sni else profileItem.sni,
profileItem.fingerPrint,
profileItem.alpn,
profileItem.publicKey,
Expand Down
6 changes: 3 additions & 3 deletions V2rayNG/app/src/main/java/com/v2ray/ang/fmt/VlessFmt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object VlessFmt : FmtBase() {
config.password = uri.userInfo
config.method = queryParam["encryption"] ?: "none"

getItemFormQuery(config, queryParam, allowInsecure)
getItemFormQuery(config, queryParam, allowInsecure)

return config
}
Expand All @@ -50,7 +50,7 @@ object VlessFmt : FmtBase() {
vnext.users[0].flow = profileItem.flow
}

outboundBean?.streamSettings?.populateTransportSettings(
val sni = outboundBean?.streamSettings?.populateTransportSettings(
profileItem.network.orEmpty(),
profileItem.headerType,
profileItem.host,
Expand All @@ -68,7 +68,7 @@ object VlessFmt : FmtBase() {
outboundBean?.streamSettings?.populateTlsSettings(
profileItem.security.orEmpty(),
profileItem.insecure == true,
profileItem.sni,
if (profileItem.sni.isNullOrEmpty()) sni else profileItem.sni,
profileItem.fingerPrint,
profileItem.alpn,
profileItem.publicKey,
Expand Down
4 changes: 2 additions & 2 deletions V2rayNG/app/src/main/java/com/v2ray/ang/fmt/VmessFmt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ object VmessFmt : FmtBase() {
vnext.users[0].security = profileItem.method
}

outboundBean?.streamSettings?.populateTransportSettings(
val sni = outboundBean?.streamSettings?.populateTransportSettings(
profileItem.network.orEmpty(),
profileItem.headerType,
profileItem.host,
Expand All @@ -169,7 +169,7 @@ object VmessFmt : FmtBase() {
outboundBean?.streamSettings?.populateTlsSettings(
profileItem.security.orEmpty(),
profileItem.insecure == true,
profileItem.sni,
if (profileItem.sni.isNullOrEmpty()) sni else profileItem.sni,
profileItem.fingerPrint,
profileItem.alpn,
null,
Expand Down

0 comments on commit 49cd3a0

Please sign in to comment.