diff options
| author | radhitya <alif@radhitya.org> | 2026-06-14 22:24:54 +0700 |
|---|---|---|
| committer | radhitya <alif@radhitya.org> | 2026-06-14 22:24:54 +0700 |
| commit | e05835493f821055e517a3988c6f9256abbc5c24 (patch) | |
| tree | 41c8f393df0a744e95d1eb7a91dc83f28d834941 /internal/blocklist | |
| parent | 55d452e8cc8e782345ab36f2f5e57a45068067f1 (diff) | |
fix block domain
Diffstat (limited to 'internal/blocklist')
| -rw-r--r-- | internal/blocklist/blocklist.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/internal/blocklist/blocklist.go b/internal/blocklist/blocklist.go index 364c492..f6e0592 100644 --- a/internal/blocklist/blocklist.go +++ b/internal/blocklist/blocklist.go @@ -94,16 +94,16 @@ func (b *Blocklist) parseRule(line string, blocked, exceptions *trie) bool { return false } func (b *Blocklist) load(scanner *bufio.Scanner) error { - blocked := newTrie() - exceptions := newTrie() - var n int32 + b.mu.Lock() + defer b.mu.Unlock() + var n int32 for scanner.Scan() { line := strings.TrimSpace(scanner.Text()) if line == "" || line[0] == '#' || line[0] == '!' { continue } - if b.parseRule(line, blocked, exceptions) { + if b.parseRule(line, b.blocked, b.exceptions) { n++ } } @@ -111,11 +111,7 @@ func (b *Blocklist) load(scanner *bufio.Scanner) error { return err } - b.mu.Lock() - b.blocked = blocked - b.exceptions = exceptions - b.mu.Unlock() - atomic.StoreInt32(&b.TotalRules, n) + b.TotalRules += n return nil } func (b *Blocklist) LoadURL(url string) error { |
