Subscription: parse sing-box outbound

This commit is contained in:
armv9 2025-02-23 19:35:41 +09:00
parent 89c1dab989
commit 4483a85df2
2 changed files with 23 additions and 3 deletions

View File

@ -760,9 +760,25 @@ object RawUpdater : GroupUpdater() {
}
json.has("outbounds") -> {
return listOf(ConfigBean().applyDefaultValues().apply {
config = json.toStringPretty()
})
return json.getJSONArray("outbounds")
.filterIsInstance<JSONObject>()
.mapNotNull {
val ty = it.getStr("type")
if (ty == null || ty == "" ||
ty == "dns" || ty == "block" || ty == "direct" || ty == "selector" || ty == "urltest"
) {
null
} else {
it
}
}.map {
ConfigBean().apply {
applyDefaultValues()
type = 1
config = it.toStringPretty()
name = it.getStr("tag")
}
}
}
json.has("server") && json.has("server_port") -> {

View File

@ -6,6 +6,7 @@ import io.nekohasekai.sagernet.database.ProxyEntity.Companion.TYPE_NEKO
import io.nekohasekai.sagernet.fmt.AbstractBean
import io.nekohasekai.sagernet.ktx.app
import io.nekohasekai.sagernet.ktx.getColorAttr
import moe.matsuri.nb4a.proxy.config.ConfigBean
// Settings for all protocols, built-in or plugin
object Protocols {
@ -17,6 +18,9 @@ object Protocols {
) {
fun hash(): String {
if (bean is ConfigBean) {
return bean.config
}
return bean.serverAddress + bean.serverPort + type
}