diff --git a/app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt b/app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt index d709eff8..d7b3d973 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt @@ -535,7 +535,7 @@ fun buildConfig( makeSingBoxRule(rule.ip.listByLineOrComma(), true) } - if (rule_set != null) generateRuleSet(ruleSets) + if (rule_set != null) generateRuleSet(rule_set, ruleSets) if (rule.port.isNotBlank()) { port = mutableListOf() diff --git a/app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java b/app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java index 6148ced6..2e609f2b 100644 --- a/app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java +++ b/app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java @@ -4418,8 +4418,7 @@ public static class DNSRule_DefaultOptions extends DNSRule { // Generate note: Listable public List domain_regex; - // Generate note: Listable - public List geosite; + public List rule_set; // Generate note: Listable public List source_ip_cidr; diff --git a/app/src/main/java/moe/matsuri/nb4a/SingBoxOptionsUtil.kt b/app/src/main/java/moe/matsuri/nb4a/SingBoxOptionsUtil.kt index f24fb1ff..de6de7e9 100644 --- a/app/src/main/java/moe/matsuri/nb4a/SingBoxOptionsUtil.kt +++ b/app/src/main/java/moe/matsuri/nb4a/SingBoxOptionsUtil.kt @@ -30,14 +30,14 @@ object SingBoxOptionsUtil { } fun SingBoxOptions.DNSRule_DefaultOptions.makeSingBoxRule(list: List) { - geosite = mutableListOf() + rule_set = mutableListOf() domain = mutableListOf() domain_suffix = mutableListOf() domain_regex = mutableListOf() domain_keyword = mutableListOf() list.forEach { if (it.startsWith("geosite:")) { - geosite.plusAssign(it.removePrefix("geosite:")) + rule_set.plusAssign(it) } else if (it.startsWith("full:")) { domain.plusAssign(it.removePrefix("full:").lowercase()) } else if (it.startsWith("domain:")) { @@ -51,12 +51,12 @@ fun SingBoxOptions.DNSRule_DefaultOptions.makeSingBoxRule(list: List) { domain.plusAssign(it.lowercase()) } } - geosite?.removeIf { it.isNullOrBlank() } + rule_set?.removeIf { it.isNullOrBlank() } domain?.removeIf { it.isNullOrBlank() } domain_suffix?.removeIf { it.isNullOrBlank() } domain_regex?.removeIf { it.isNullOrBlank() } domain_keyword?.removeIf { it.isNullOrBlank() } - if (geosite?.isEmpty() == true) geosite = null + if (rule_set?.isEmpty() == true) rule_set = null if (domain?.isEmpty() == true) domain = null if (domain_suffix?.isEmpty() == true) domain_suffix = null if (domain_regex?.isEmpty() == true) domain_regex = null @@ -64,7 +64,7 @@ fun SingBoxOptions.DNSRule_DefaultOptions.makeSingBoxRule(list: List) { } fun SingBoxOptions.DNSRule_DefaultOptions.checkEmpty(): Boolean { - if (geosite?.isNotEmpty() == true) return false + if (rule_set?.isNotEmpty() == true) return false if (domain?.isNotEmpty() == true) return false if (domain_suffix?.isNotEmpty() == true) return false if (domain_regex?.isNotEmpty() == true) return false @@ -73,8 +73,8 @@ fun SingBoxOptions.DNSRule_DefaultOptions.checkEmpty(): Boolean { return true } -fun SingBoxOptions.Rule_DefaultOptions.generateRuleSet(ruleSet: MutableList) { - rule_set?.forEach { +fun generateRuleSet(ruleSetString: List, ruleSet: MutableList) { + ruleSetString.forEach { when { it.startsWith("geoip") -> { val geoipPath = GeoipUtils.generateRuleSet(country = it.removePrefix("geoip:"))