Git Product home page Git Product logo

0xerr0r / blocky Goto Github PK

View Code? Open in Web Editor NEW
4.2K 34.0 196.0 12.4 MB

Fast and lightweight DNS proxy as ad-blocker for local network with many features

Home Page: https://0xERR0R.github.io/blocky/

License: Apache License 2.0

Go 99.03% Makefile 0.37% Dockerfile 0.27% HTML 0.10% Shell 0.22%
ad-blocker adblocker dns self-hosted golang selfhosted pihole dns-over-https dns-server parental-control

blocky's People

Contributors

0xerr0r avatar aman207 avatar amigan avatar benmch avatar coolguy1771 avatar dependabot-preview[bot] avatar dependabot[bot] avatar derrockwolf avatar desolatorxxl avatar donald-art avatar filego avatar grilix avatar harnish avatar kwitsch avatar lakestonelabs avatar moolex avatar nicolas-martin avatar ohemmali avatar onedr0p avatar ornias1993 avatar peterdavehello avatar rich7690 avatar schlamar avatar shizunge avatar soulteary avatar suhaibmalik avatar thinkchaos avatar tmuellerleile avatar vvelox avatar zc-devs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blocky's Issues

Netflix on firetv is blocked by default

I just discovered that Netflix on my firetv gets blocked. It is working on my Panasonic smart TV.

Obviously this is not a real big but in a pihole setup that would work just fine.

I would advise to have a default config which does not block popular services.

Enhancement: Configuration of different upstream DNS servers for different clients

I really like Blocky and the great configuration options. Because it is so slim and fast I changed my LAN setup from Adguard to Blocky. There is only one feature missing in Blocky for me: The possibility to have different upstream DNS servers for different clients. For my understanding it is currently not possible in Blocky to have something like:

externalResolvers:  
      default:     # Default for all requests
         - tcp: 46.182.19.48
         - tcp: 80.241.218.68
      desktop.fritz.box:   # Requests coming from desktop.fritz.box will be forwarded to
          - tcp-tls:fdns1.dismail.de:853
          - https://dns.digitale-gesellschaft.ch/dns-query

Or maybe I missed something in the configuration options?

add additional prometheus metrics for dashboard

add metrics for useful dashboard:

  • query count per client and type
  • error count
  • request duration as histogram
  • response count by reason, response code and response time
  • count black/whitelist per group

Error on processing empty query

If blocky runs in docker, following error occurs, if "empty" query (dig without parameter) is executed:
error on processing request: dns: unknown RR type: "<nil>" at line: 1:17

According to dig manual, empty query param is equivalent to "."

Temporary deactivation of blocking

User should be able to temporarily deactivate blocking against the blacklist by:

  • Using the CLI tool
  • Calling REST API from external tool (OpenHAB, Home Assistant, ...)
  • Using Grafana dashboard for blocky

Could not access /swagger endpoint

Hello, thanks for this nice little piece of software.

I face a small issue. i can access /metrics and /debug/pprof/ endpoints. but i could not access /swagger endpoint.

I did disable_sanitize_html = true in grafana, but still text panel is not loading script. What should i set the blocky_url variable in panel ? my installation is at 192.168.1.2

thank you

Subdomain matching / regex support

Hello,

It looks like the current implementation does exact matching on the domain name. I'm wondering if you would be open to a change that adds suffix matching, such that a blacklist entry of foo.com would also block *.foo.com, *.*.foo.com, etc.

I would probably implement it using a trie data structure to minimize the memory cost and lookups would probably be O(n) where n is the length of the search string.

This behavior could be configurable so that the default behavior remains the same unless this feature is enabled.

Fine grained locking on list update

List refresh sets lock on internal map structure, any incoming request must wait until list refresh is completed. This should be avoided by setting fine grained locking (only on map modification)

wildcards for custom dns mapping

I have some internal services like foo.home.internal and bar.home.internal... it would be cool if I could define *.home.internal to 10.1.1.1

Is this already possible?

make config path/name configurable

As a user of blocky,
I want to specify the path & name of the config file instead of expecting it to be hardcoded to /app/config.yml
So that I can use my own path design for config files

The reason behind this ask is that within kubernetes, leveraging a configMap to define the config file will result in the /app directory being clobbered when mounting the config.yml in that directory meaning that there won't be a blocky binary to run. If we can define the config file to be in a non-shared path, that would be great!

CLI tool for blocky

Blocky should provide REST API to control components and query the status. A CLI tool should use this API too. First implementation should allow the user to enable and disable the blocking of blacklisted domains.

Queries doesn't seem to be cached

After 24 hours of turning it ON i do not see caching in response list of grafana dashboard, i checked my docker logs. and CachingResolver seems to be deactivated. I just use the default config.yml on the readme. any specific lines to be added in config ?

[2020-05-14 21:38:41] INFO server: -> resolver: 'CachingResolver' [2020-05-14 21:38:41] INFO server: deactivated [2020-05-14 21:38:41] INFO server: -> resolver: 'ParallelBestResolver' [2020-05-14 21:38:41] INFO server: upstream resolvers: [2020-05-14 21:38:41] INFO server: - upstream '208.67.222.222:853' [2020-05-14 21:38:41] INFO server: - upstream '1.1.1.2:853' [2020-05-14 21:38:41] INFO server: - upstream '1.1.1.1:853' [2020-05-14 21:38:41] INFO server: - upstream '1.0.0.1:853'

Warning when requesting from the same machine

For testing purpose I made some request from blocky query cli tool at the same machine as the server's and I get this warning :

WARN client_names_resolver: can't create reverse address for <nil> client_ip=<nil> question=A

Maybe a smarter log message would be nicer ?

json log output mode

It would be cool if we could switch the log output mode in stdout to json... this would allow us to parse it easily.

Can blocky listen in local network?

Hey there. Blocky is really nice DNS for me but recently I found large DNS resolved request which was not requested by me in my server and it cause a lot of log in my disk. But I cant find any solution to listen only in local network such as 127.0.0.1 or 192.168.x.x and log deletion circulation.
So can Blocky do those thing? Thanks a lot

Update binary from cli

Would be nice to be able to update the binary from the cli, something like this for example;

blocky update

Bonus points if we could execute a command depending on if the update succeeded or not. For example I run Blocky from a systemd service file I made so I would wanna restart that if the update succeded. I guess you could configure that in the .yml file.

AXFR fails most times

Assume you have this snippet beneath in your config with two identically DNS Server but different protocols.
If the DNS client is sending an AXFR query to transfer a zone, it uses the TCP Protocol and the UDP.

Because Blocky randomly selects two external upstream DNS server from the list (UDP+TCP), the fastest response wins, which is usually the UDP response.

However, UDP is always denied by Auth. DNS Server when trying to perform Zone Transfer over UDP and sends back a Servfail DNS Message.

Blocky must honor this and must forward TCP based DNS Queries (like AXFR/IXFR) to TCP Upstream DNS Server only.

Otherwise, any AXFR Queries over UDP will fail.

https://tools.ietf.org/html/rfc1035#section-4.2.1

UDP is not acceptable for zone transfers, ....

https://tools.ietf.org/html/rfc5936#section-2

An important aspect to keep in mind is that the definition of AXFR is
restricted to TCP [RFC0793] (see Section 4 for details). The design
of the AXFR process has certain inherent features that are not easily
ported to UDP [RFC0768].

Example

upstream:

    # these external DNS resolvers will be used. Blocky picks 2 random resolvers from the list for each query
    # format for resolver: net:host:[port][/path]. net could be tcp, udp, tcp-tls or https (DoH). If port is empty, default port will be used (53 for udp and tcp, 853 for tcp-tls, 443 for https (Doh))
    externalResolvers:
      **- tcp:80.241.218.68**
      **- udp:80.241.218.68**
      

dnssec support

it would be great of blocky would validate dnssec signatures...

Running on windows docker?

I'm trying to run this on windows docker but when I inser the path to the config file i get loads of errors any help or does this not work on windows?

List download: Improve error handling

Error handling on (periodic) list download should be improved:

  • Rerty on temporary errors (Timeout, ...)
  • Leave elements in cache for the group, if a temporary error occurs

Disable Caching

This project looks like a perfect replacement for Stubby on my network. However, as Iโ€™d have dnsmasq forward requests to Blocky this would result in caching the response in two locations which is less than ideal.

Can a config option be added to disable caching within Blocky?

Windows Support

The current Blocky code is unable to complile on windows due to some *nix specific code like

if cfg.Dir != "" && unix.Access(cfg.Dir, unix.W_OK) != nil {

and some more.
Having these parts rewritten to os agnostic code, Blocky would join the Windows family.

Client name mapping

Because of problems with reverse DNS with ipv6, I have to make two entries for each client when specifying a blocking group (once with its hostname and once with it ipv6 address). In addition, the device is also displayed with these two names in the grafana client statistic.

So I would like to map client names to specific ip addresses:

clients:
laptop:
- 192.168.1.2
- ...
- fd00::532b:9bda:45b5:123

The name "laptop" defined in this way will replace the actual DNS name of the device and can be used in the blocking group specification and is used as client name in the static overview,

CLI command to perform a DNS query

It would be useful to have a CLI command to perform a DNS query (Simple replacement for dig). The output should contain blocky specific information (for example: Query was blocked etc.)

Usage:
./blocky query google.com or ./blocky query google.com --type AAAA

Documentation of config.yml file not correct anymore

Based on the description in README.md

upstream:
    # these external DNS resolvers will be used. Blocky picks 2 random resolvers from the list for each query
    # format for resolver: [net:]host:[port][/path]. net could be empty (default, shortcut for tcp+udp), tcp+udp, tcp, udp, tcp-tls or https (DoH). If port is empty, default port will be used (53 for udp and tcp, 853 for tcp-tls, 443 for https (Doh))
  

I tried the configuration as described above:

     externalResolvers:  
       - 46.182.19.48
       - 80.241.218.68

This leads to the following error when starting blocky:
level=fatal msg="wrong file structure: wrong configuration, couldn't parse input '46.182.19.48', please enter net:host[:port][/path]"

So "net:" is not optional anymore. Right?

Changing the config to

     externalResolvers:  
       - tcp:46.182.19.48
       - tcp.80.241.218.68

solved the problem.

Especially for new users it would be great to adapt the documentation.

Client/cidr specific upstream dns server configuration

Is there a way to set upstream DNS servers for a specific client or cidr address range? Use case is most clients I want going to Opendns, but some I want going to a geo location spoofing dns (mlb blackout workaround).

Log to stdout

It would be cool if there would be an option to enable query log to stdout.

helm chart

Hi, I made this into a helm chart which is also hosted on helm hub for consumption in kubernetes workloads.

If you're interested in hosting it here, I'm happy to PR the necessary changes to have the chart hosted with associated github actions for linting, testing, and publishing the chart.

Support for multiple conditional forwarders per domain

Attempting to add multiple resolvers for conditional forwards gives an error. It would be good if Blocky supported to the ability to query multiple forwarders.

level=fatal msg="wrong file structure: yaml: unmarshal errors:\n line 31: key \"ipa.example.com\" already set in map\n line 33: key \"ad.example.com\" already set in map\n

conditional:
    mapping:
      ipa.example.com: udp:10.0.0.11
      ipa.example.com: udp:10.0.0.12
      ad.example.com: udp:10.0.1.11
      ad.example.com: udp:10.0.1.12

make log to disk optional

I use Loki and Promtail to gather logs in my Kubernetes cluster which gather logs from the containers stdout.

For me I don't need to logs being stored on disk unless there is a certain need Blocky uses it for.

why "go get" failed?

hi.

yudeMacBook-Air:gopath brite$ go get -u -v github.com/0xERR0R/blocky
github.com/0xERR0R/blocky (download)
package blocky/config: unrecognized import path "blocky/config" (import path does not begin with hostname)
package blocky/server: unrecognized import path "blocky/server" (import path does not begin with hostname)
github.com/sirupsen/logrus (download)
get "golang.org/x/sys/unix": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at //golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
golang.org/x/sys (download)
github.com/x-cray/logrus-prefixed-formatter (download)
github.com/mgutz/ansi (download)
github.com/mattn/go-colorable (download)
github.com/mattn/go-isatty (download)
get "golang.org/x/crypto/ssh/terminal": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at //golang.org/x/crypto/ssh/terminal?go-get=1
get "golang.org/x/crypto/ssh/terminal": verifying non-authoritative meta tag
golang.org/x/crypto (download)
yudeMacBook-Air:gopath brite$

how to fix the "unrecognized import path" error?

Cannot retrieve any lists all of a sudden

First of all, blocky works pretty well for my network. Thank you for making/releasing it! I have my blocky instance on my raspberrypi4 via docker and after a little configuration issues, had it up and running beautifully. For the last couple of days, since the latest update (I think), blocky cannot update any list. It throws this error for each list:

WARN list_cache: Temporary network error / Timeout occurred, retrying... Get "https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist": dial tcp: lookup zeustracker.abuse.ch on 127.0.0.11:53: read udp 127.0.0.1:57929->127.0.0.11:53: i/o timeout attempt=3 link=https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist

I've checked that my rp4 has network and that DNS requests for the rp4 go directly to a DNS provider (OpenDNS). I can browse and update other things on the rp4 so I know it's not it's core connectivity. Restarting the rp4 and/or the container does not fix the issue.

Question: Is blocky supposed to be using 127.0.0.11? Right now, blocky is working with cached lists but some of the lists I use are updated daily.

Thank you for your time!

prometheus metrics for queries

It would be nice to have a metric of the top queries per domain so you know if something weird is blocked or not blocked.

  • top queries per domain
  • label if blocked or not

Add CustomIP block type to allow forwarding to IPs other that ZeroIP

I use a null server and would love the ability to forward to it's IP, but currently the only types supported are NxDomain and ZeroIP. This speeds up responses that have been blocked and bypasses some checks in applications checking if any content was returned.

I can take a stab at adding and submitting a PR, but thought I'd see what your thoughts are on adding that functionality.

ip lists?

hello,

will list with ip's can be blocked?

https://feodotracker.abuse.ch/downloads/ipblocklist.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.