mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-20 07:00:05 +08:00
chore: imporve parsing
This commit is contained in:
parent
c4932a339b
commit
e376369493
@ -20,6 +20,7 @@ fun parseSOCKS(link: String): SOCKSBean {
|
|||||||
link.startsWith("socks4a://") -> SOCKSBean.PROTOCOL_SOCKS4A
|
link.startsWith("socks4a://") -> SOCKSBean.PROTOCOL_SOCKS4A
|
||||||
else -> SOCKSBean.PROTOCOL_SOCKS5
|
else -> SOCKSBean.PROTOCOL_SOCKS5
|
||||||
}
|
}
|
||||||
|
name = url.fragment
|
||||||
serverAddress = url.host
|
serverAddress = url.host
|
||||||
serverPort = url.port
|
serverPort = url.port
|
||||||
username = url.username
|
username = url.username
|
||||||
|
|||||||
@ -328,9 +328,16 @@ object RawUpdater : GroupUpdater() {
|
|||||||
"tls" -> bean.security =
|
"tls" -> bean.security =
|
||||||
if (opt.value.toString() == "true") "tls" else ""
|
if (opt.value.toString() == "true") "tls" else ""
|
||||||
|
|
||||||
|
"servername" -> bean.host = opt.value.toString()
|
||||||
|
|
||||||
"skip-cert-verify" -> bean.allowInsecure =
|
"skip-cert-verify" -> bean.allowInsecure =
|
||||||
opt.value.toString() == "true"
|
opt.value.toString() == "true"
|
||||||
|
|
||||||
|
"alpn" -> {
|
||||||
|
val alpn = (opt.value as? (List<String>))
|
||||||
|
bean.alpn = alpn?.joinToString("\n")
|
||||||
|
}
|
||||||
|
|
||||||
"ws-path" -> bean.path = opt.value.toString()
|
"ws-path" -> bean.path = opt.value.toString()
|
||||||
"ws-headers" -> for (wsHeader in (opt.value as Map<String, Any>)) {
|
"ws-headers" -> for (wsHeader in (opt.value as Map<String, Any>)) {
|
||||||
when (wsHeader.key.lowercase()) {
|
when (wsHeader.key.lowercase()) {
|
||||||
@ -360,7 +367,6 @@ object RawUpdater : GroupUpdater() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"servername" -> bean.host = opt.value.toString()
|
|
||||||
// The format of the VMessBean is wrong, so the `host` `path` has some strange transformations here.
|
// The format of the VMessBean is wrong, so the `host` `path` has some strange transformations here.
|
||||||
"h2-opts", "h2-opt" -> for (h2Opt in (opt.value as Map<String, Any>)) {
|
"h2-opts", "h2-opt" -> for (h2Opt in (opt.value as Map<String, Any>)) {
|
||||||
when (h2Opt.key.lowercase()) {
|
when (h2Opt.key.lowercase()) {
|
||||||
@ -426,6 +432,11 @@ object RawUpdater : GroupUpdater() {
|
|||||||
"skip-cert-verify" -> bean.allowInsecure =
|
"skip-cert-verify" -> bean.allowInsecure =
|
||||||
opt.value.toString() == "true"
|
opt.value.toString() == "true"
|
||||||
|
|
||||||
|
"alpn" -> {
|
||||||
|
val alpn = (opt.value as? (List<String>))
|
||||||
|
bean.alpn = alpn?.joinToString("\n")
|
||||||
|
}
|
||||||
|
|
||||||
"network" -> when (opt.value) {
|
"network" -> when (opt.value) {
|
||||||
"ws", "grpc" -> bean.type = opt.value.toString()
|
"ws", "grpc" -> bean.type = opt.value.toString()
|
||||||
}
|
}
|
||||||
@ -457,12 +468,14 @@ object RawUpdater : GroupUpdater() {
|
|||||||
|
|
||||||
"hysteria" -> {
|
"hysteria" -> {
|
||||||
val bean = HysteriaBean()
|
val bean = HysteriaBean()
|
||||||
|
var hopPorts = ""
|
||||||
for (opt in proxy) {
|
for (opt in proxy) {
|
||||||
if (opt.value == null) continue
|
if (opt.value == null) continue
|
||||||
when (opt.key.replace("_", "-")) {
|
when (opt.key.replace("_", "-")) {
|
||||||
"name" -> bean.name = opt.value.toString()
|
"name" -> bean.name = opt.value.toString()
|
||||||
"server" -> bean.serverAddress = opt.value as String
|
"server" -> bean.serverAddress = opt.value as String
|
||||||
"port" -> bean.serverPort = opt.value.toString().toInt()
|
"port" -> bean.serverPort = opt.value.toString().toInt()
|
||||||
|
"ports" -> hopPorts = opt.value.toString()
|
||||||
|
|
||||||
"obfs" -> bean.obfuscation = opt.value.toString()
|
"obfs" -> bean.obfuscation = opt.value.toString()
|
||||||
|
|
||||||
@ -500,6 +513,10 @@ object RawUpdater : GroupUpdater() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (hopPorts.isNotBlank()) {
|
||||||
|
bean.serverAddress =
|
||||||
|
bean.serverAddress.wrapIPV6Host() + ":" + hopPorts
|
||||||
|
}
|
||||||
proxies.add(bean)
|
proxies.add(bean)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user