This commit is contained in:
2dust
2024-11-28 16:49:06 +08:00
parent 75cc16c5e0
commit 49cd3a0494
5 changed files with 31 additions and 25 deletions

View File

@@ -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
}
@@ -391,7 +391,7 @@ 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
}
@@ -399,7 +399,7 @@ data class V2rayConfig(
NetworkType.HTTP_UPGRADE.type -> {
val httpupgradeSetting = HttpupgradeSettingsBean()
httpupgradeSetting.host = host.orEmpty()
sni = httpupgradeSetting.host
sni = host
httpupgradeSetting.path = path ?: "/"
httpupgradeSettings = httpupgradeSetting
}
@@ -407,7 +407,7 @@ data class V2rayConfig(
NetworkType.SPLIT_HTTP.type, NetworkType.XHTTP.type -> {
val xhttpSetting = XhttpSettingsBean()
xhttpSetting.host = host.orEmpty()
sni = xhttpSetting.host
sni = host
xhttpSetting.path = path ?: "/"
xhttpSettings = xhttpSetting
}
@@ -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
}
@@ -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
}
}
@@ -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

View File

@@ -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"]
}
}
@@ -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,
@@ -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,

View File

@@ -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,
@@ -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,

View File

@@ -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
}
@@ -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,
@@ -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,

View File

@@ -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,
@@ -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,