diff options
| author | radhitya <alif@radhitya.org> | 2026-06-21 09:48:42 +0700 |
|---|---|---|
| committer | radhitya <alif@radhitya.org> | 2026-06-21 09:48:42 +0700 |
| commit | b7359e1d45f505171356bcae3c7d5e2341ecc859 (patch) | |
| tree | f91d4a4b08ce279d488a76e9b7141e69fc844ea9 /internal/blocklist | |
| parent | 2b1f613c42de3861141eb6f93c1740b6937ee183 (diff) | |
forward mode, cache opt, ACL, rate limit, admin/health, systemd, fix UDP reply
Diffstat (limited to 'internal/blocklist')
| -rw-r--r-- | internal/blocklist/blocklist.go | 16 | ||||
| -rw-r--r-- | internal/blocklist/blocklist_test.go | 2 |
2 files changed, 8 insertions, 10 deletions
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) |
