aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 7741c08c65434c7a1257f905d96d1762d18936b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Unbound Ads Generator

A tool to generate Unbound DNS server configuration for blocking advertising domains.

## Overview

This program fetches lists of advertising domains from multiple sources and generates a configuration file for the Unbound DNS server to block these domains. It supports multiple input formats and automatically deduplicates domains.

## Usage

```bash
unbound-ads-generator <url-list> <output-file>
```

Where:
- `url-list` is a URL pointing to a text file containing a list of URLs (one per line) that provide domain lists
- `output-file` is the path where the Unbound configuration will be written

### Input Format

The URL list file should contain URLs (one per line) pointing to domain lists. Lines starting with # are treated as comments.

Example URL list file:
```
# Ad blocking lists
https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt
https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts
```

The domain lists can be in either of these formats:
```
# IP and domain format
0.0.0.0 advertising.example.com

# Plain domain format
advertising.example.com
```

### Output Format

The program generates Unbound configuration in this format:
```
local-zone: "advertising.example.com" refuse
local-zone: "another-ad.example.com" refuse
```

## Features

- Supports multiple domain list formats
- Automatically deduplicates domains
- Case-insensitive domain matching
- Progress logging
- Comment handling
- Basic domain validation

## Building

```bash
go build
```

## Testing

```bash
go test -v
```
# unbound-ads

A tool to generate [Unbound DNS server](https://nlnetlabs.nl/projects/unbound/about/) configuration for domain blocking. It fetches domain lists from URLs and converts them into Unbound's local-zone configuration format for DNS-based ad and malware blocking.

## Features

- Fetches domain lists from multiple URLs
- Supports various domain list formats (hosts file format, plain domain lists)
- Deduplicates domains automatically
- Generates Unbound-compatible configuration
- Progress logging with slog
- Docker support

## Installation


### Using Docker

```bash
docker pull public.ecr.aws/s0f9o2k5/unbound-ads:latest
```

## Usage

### Binary

```bash
unbound-ads <url-list> <output-file>
```

Where:
- `url-list` is a URL containing a list of domain list URLs (one per line)
- `output-file` is the path where the Unbound configuration will be written

Example:
```bash
unbound-ads https://v.firebog.net/hosts/lists.php?type=tick blocking.conf
```

### Docker

```bash
docker run --rm -v "$PWD:/data" ghcr.io/yourusername/unbound-ads \
  https://v.firebog.net/hosts/lists.php?type=tick /data/blocking.conf
```

## Building from Source

Requirements:
- Go 1.21 or later
- just command runner
- Docker (optional)

```bash
# Build binary
just build

# Build Docker image
just docker-build

# Run tests
just test
```

## Output Format

The tool generates Unbound configuration in this format:

```
local-zone: "example.com" refuse
local-zone: "ads.example.com" refuse
```

When added to your Unbound configuration, these entries will cause Unbound to return NXDOMAIN for queries to blocked domains.