mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 22:50:05 +08:00
style: rule_set for dns
This commit is contained in:
parent
4c8d098de3
commit
b46dbc8c46
@ -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<Int>()
|
||||
|
||||
@ -4418,8 +4418,7 @@ public class SingBoxOptions {
|
||||
// Generate note: Listable
|
||||
public List<String> domain_regex;
|
||||
|
||||
// Generate note: Listable
|
||||
public List<String> geosite;
|
||||
public List<String> rule_set;
|
||||
|
||||
// Generate note: Listable
|
||||
public List<String> source_ip_cidr;
|
||||
|
||||
@ -30,14 +30,14 @@ object SingBoxOptionsUtil {
|
||||
}
|
||||
|
||||
fun SingBoxOptions.DNSRule_DefaultOptions.makeSingBoxRule(list: List<String>) {
|
||||
geosite = mutableListOf<String>()
|
||||
rule_set = mutableListOf<String>()
|
||||
domain = mutableListOf<String>()
|
||||
domain_suffix = mutableListOf<String>()
|
||||
domain_regex = mutableListOf<String>()
|
||||
domain_keyword = mutableListOf<String>()
|
||||
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<String>) {
|
||||
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<String>) {
|
||||
}
|
||||
|
||||
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<RuleSet>) {
|
||||
rule_set?.forEach {
|
||||
fun generateRuleSet(ruleSetString: List<String>, ruleSet: MutableList<RuleSet>) {
|
||||
ruleSetString.forEach {
|
||||
when {
|
||||
it.startsWith("geoip") -> {
|
||||
val geoipPath = GeoipUtils.generateRuleSet(country = it.removePrefix("geoip:"))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user