Expunji - DNS Sinkhole ala PiHole

Hi all, I’ve just finished making a simple DNS sinkhole in Elixir:
https://github.com/volroom/expunji
Basically how it works is:

  1. Application tree starts up main GenServer
  2. Genserver loads hosts files into an ETS table
  3. Genserver listens for incoming DNS requests on port 53, and opens another UDP socket for communicating with a nameserver
  4. If the domain is found in the ETS table respond to the client with an IP of 0.0.0.0, otherwise check the Cachex cache of previously forwarded responses.
  5. If no response is found in the cache, forward the request to the nameserver and log the client’s address & request in an ETS table, otherwise respond to the client instantly with the cached response.
  6. When the response from the nameserver comes back, check the ETS table to see which client requested that domain and send them the response. The response gets cached for future requests.

Any feedback/suggestions/PRs are more than welcome!

7 Likes

A description of how the hostname file should look like would help. For example, here GitHub - notracking/hosts-blocklists: Automatically updated, moderated and optimized lists for blocking ads, trackers, malware and other garbage we have some different formats for different DNS server and blockers.