Total Pageviews

Friday 13 March 2020

Blocky:一个支持DoT/DoH的DNS代理程序

在本地机器mac上,首先搭建go1.13环境。
然后,
cd $GOPATH
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)

遇到了unrecognized import path错误。
解决办法:
cd src/github.com/0xERR0R/blocky/
go install
安装完成。
which blocky
it shows:
$GOBIN/blocky

新建默认的配置文件:
nano config.yml
cat config.yml
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-tls:yourdomain.com:853

# Port, should be 53 (UDP and TCP)
port: 53

注:dot服务器yourdomain.com:853的搭建详见https://briteming.blogspot.com/2020/01/unbounddns-over-tls.html ,这里的yourdomain.com不能替换为your-vps-ip.

然后,运行:
sudo blocky (不要关闭此terminal)
这样,dns proxy程序blocky就成功运行了。

运用例子:
sudo wg-quick down wg0
sudo networksetup -setdnsservers "Wi-Fi" 127.0.0.1
sudo wg-quick up wg0
sudo networksetup -setdnsservers "Wi-Fi" 127.0.0.1
sudo blocky

项目地址:
https://github.com/0xERR0R/blocky/
https://github.com/0xERR0R/blocky/issues/25

相关帖子: