diff options
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) |
