修复服务器对
This commit is contained in:
@@ -446,24 +446,6 @@ func (m *ShieldManager) addDomainRule(domain string, block bool, isLocal bool, s
|
||||
m.domainRules[domain] = true
|
||||
m.domainRulesIsLocal[domain] = isLocal
|
||||
m.domainRulesSource[domain] = source
|
||||
// 添加所有子域名的匹配支持
|
||||
parts := strings.Split(domain, ".")
|
||||
if len(parts) > 1 {
|
||||
// 为二级域名和顶级域名添加规则
|
||||
for i := 0; i < len(parts)-1; i++ {
|
||||
subdomain := strings.Join(parts[i:], ".")
|
||||
// 如果是远程规则,检查是否已经存在本地规则,如果存在则不覆盖
|
||||
if !isLocal {
|
||||
if _, exists := m.domainRulesIsLocal[subdomain]; exists && m.domainRulesIsLocal[subdomain] {
|
||||
// 已经存在本地规则,不覆盖
|
||||
continue
|
||||
}
|
||||
}
|
||||
m.domainRules[subdomain] = true
|
||||
m.domainRulesIsLocal[subdomain] = isLocal
|
||||
m.domainRulesSource[subdomain] = source
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 添加到排除规则
|
||||
// 如果是远程规则,检查是否已经存在本地规则,如果存在则不覆盖
|
||||
@@ -476,23 +458,6 @@ func (m *ShieldManager) addDomainRule(domain string, block bool, isLocal bool, s
|
||||
m.domainExceptions[domain] = true
|
||||
m.domainExceptionsIsLocal[domain] = isLocal
|
||||
m.domainExceptionsSource[domain] = source
|
||||
// 为子域名也添加排除规则
|
||||
parts := strings.Split(domain, ".")
|
||||
if len(parts) > 1 {
|
||||
for i := 0; i < len(parts)-1; i++ {
|
||||
subdomain := strings.Join(parts[i:], ".")
|
||||
// 如果是远程规则,检查是否已经存在本地规则,如果存在则不覆盖
|
||||
if !isLocal {
|
||||
if _, exists := m.domainExceptionsIsLocal[subdomain]; exists && m.domainExceptionsIsLocal[subdomain] {
|
||||
// 已经存在本地规则,不覆盖
|
||||
continue
|
||||
}
|
||||
}
|
||||
m.domainExceptions[subdomain] = true
|
||||
m.domainExceptionsIsLocal[subdomain] = isLocal
|
||||
m.domainExceptionsSource[subdomain] = source
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,7 +559,7 @@ func (m *ShieldManager) CheckDomainBlockDetails(domain string) map[string]interf
|
||||
}
|
||||
}
|
||||
|
||||
// 检查阻止规则
|
||||
// 检查阻止规则 - 先检查精确域名匹配,再检查子域名匹配
|
||||
// 检查精确域名匹配
|
||||
if m.domainRules[domain] {
|
||||
result["blocked"] = true
|
||||
|
||||
Reference in New Issue
Block a user