远程列表web

This commit is contained in:
Alex Yang
2025-11-23 23:50:04 +08:00
parent 30795ae767
commit fcd4fc9e68
15 changed files with 84600 additions and 3811 deletions

View File

@@ -132,10 +132,12 @@ func (m *ShieldManager) loadLocalRules() error {
// loadRemoteRules 加载远程规则
func (m *ShieldManager) loadRemoteRules() error {
for _, url := range m.config.RemoteRules {
if err := m.fetchRemoteRules(url); err != nil {
logger.Error("获取远程规则失败", "url", url, "error", err)
continue
for _, blacklist := range m.config.Blacklists {
if blacklist.Enabled {
if err := m.fetchRemoteRules(blacklist.URL); err != nil {
logger.Error("获取远程规则失败", "url", blacklist.URL, "error", err)
continue
}
}
}
return nil
@@ -1007,6 +1009,16 @@ func (m *ShieldManager) startAutoSaveStats() {
}
}
// GetBlacklists 获取所有黑名单配置
func (m *ShieldManager) GetBlacklists() []config.BlacklistEntry {
return m.config.Blacklists
}
// UpdateBlacklist 更新黑名单配置
func (m *ShieldManager) UpdateBlacklist(blacklists []config.BlacklistEntry) {
m.config.Blacklists = blacklists
}
// GetRules 获取所有规则
func (m *ShieldManager) GetRules() map[string]interface{} {
m.rulesMutex.RLock()
@@ -1047,5 +1059,6 @@ func (m *ShieldManager) GetRules() map[string]interface{} {
"regexRules": regexRulesList,
"regexExceptions": regexExceptionsList,
"hostsRules": hostsRulesList,
"blacklists": m.config.Blacklists,
}
}