https://github.com/brodyhoskins/dns-sniper
Combine DNS blacklists into desired configuration format
https://github.com/brodyhoskins/dns-sniper
adblocking adblocking-dns dns ruby ruby-gem
Last synced: about 1 month ago
JSON representation
Combine DNS blacklists into desired configuration format
- Host: GitHub
- URL: https://github.com/brodyhoskins/dns-sniper
- Owner: brodyhoskins
- License: mit
- Created: 2020-08-10T03:32:12.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T13:57:29.000Z (over 3 years ago)
- Last Synced: 2025-12-25T21:54:45.457Z (6 months ago)
- Topics: adblocking, adblocking-dns, dns, ruby, ruby-gem
- Language: Ruby
- Homepage:
- Size: 60.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# dns-sniper
dns-sniper is a command line utility that combines online DNS blacklists and combines them into the desired configuration format.
## Supported Formats
### Input formats
* HOSTS
* plaintext (hostnames as newline-seperated list)
### Output formats
* bind 8
* dnsmasq
* HOSTS
* plaintext (hostnames as newline-seperated list)
* unbound
## Installation
Using bundler, add to the `Gemfile`:
```ruby
gem 'dns-sniper'
```
Or standalone:
```
$ gem install dns-sniper
```
## Sample Usage
### From within Ruby
```ruby
require 'dns-sniper'
hostnames = DNSSniper::Hostnames.new
# Manually add blacklisted or whitelisted domains
hostnames.blacklist += 'ads.yahoo.com'
hostnames.whitelist += 'favoritewebsite.com'
# Use an Importer to process external lists
hostnames.blacklist += DNSSniper::DomainsImporter.new('https://raw.githubusercontent.com/brodyhoskins/dns-blocklists/master/tracking.list').hostnames
hostnames.blacklist += DNSSniper::HostsImporter.new('https://pgl.yoyo.org/as/serverlist.php?hostformat=hosts;showintro=0;mimetype=plaintext').hostnames
# Blocklist is accessible as an Array
hostnames.blocklist
# List available formats
DNSSniper::Exporters.all
# Convert to desired format
hostnames.to_unbound
```
### From CLI
See `dns-sniper --help`
Using the CLI version makes it easy to update configuration formats automatically. For example:
```bash
#!/usr/bin/env bash
/path/to/dns-sniper --conf ~/.config/dns-sniper/dns-sniper.yml --output unbound > /etc/unbound/unbound.conf.d/blocklist.conf
service unbound reload
```