From b7359e1d45f505171356bcae3c7d5e2341ecc859 Mon Sep 17 00:00:00 2001 From: radhitya Date: Sun, 21 Jun 2026 09:48:42 +0700 Subject: forward mode, cache opt, ACL, rate limit, admin/health, systemd, fix UDP reply --- internal/blocklist/blocklist.go | 16 +++++++--------- internal/blocklist/blocklist_test.go | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'internal/blocklist') diff --git a/internal/blocklist/blocklist.go b/internal/blocklist/blocklist.go index f6e0592..8925299 100644 --- a/internal/blocklist/blocklist.go +++ b/internal/blocklist/blocklist.go @@ -2,9 +2,9 @@ package blocklist import ( "bufio" + "fmt" "net/http" "os" - "fmt" "strings" "sync" "sync/atomic" @@ -18,19 +18,19 @@ const ( ) type Blocklist struct { - mu sync.RWMutex - blocked *trie + mu sync.RWMutex + blocked *trie exceptions *trie - response ResponseAction + response ResponseAction TotalRules int32 - Hits int64 + Hits int64 } func New(action ResponseAction) *Blocklist { return &Blocklist{ - blocked: newTrie(), + blocked: newTrie(), exceptions: newTrie(), - response: action, + response: action, } } @@ -128,8 +128,6 @@ func (b *Blocklist) LoadURL(url string) error { return b.load(bufio.NewScanner(resp.Body)) } - - func splitDomain(domain string) []string { domain = strings.TrimSuffix(domain, ".") return strings.Split(domain, ".") diff --git a/internal/blocklist/blocklist_test.go b/internal/blocklist/blocklist_test.go index b6d4e83..874744c 100644 --- a/internal/blocklist/blocklist_test.go +++ b/internal/blocklist/blocklist_test.go @@ -7,7 +7,7 @@ import ( ) func TestBlockZeroIP(t *testing.T) { -dir := t.TempDir() + dir := t.TempDir() p := filepath.Join(dir, "block.txt") os.WriteFile(p, []byte("||example.com^\n0.0.0.0 doubleclick.net\n"), 0644) -- cgit v1.2.3