Giter Club home page Giter Club logo

dnsproxy's Introduction

##Proxy DNS query use TCP in go lang

苦于本地DNS污染,连github.com这种都经常解析不了。最近愈发频繁,所以写了这个程序。

  • 采用多个dns地址轮询。
  • dns 请求时,默认 read/write 都为 100ms 超时,实测已经足够,更长时间会导致网页访问变慢。
  • 使用 TCP 做 DNS 解析,转发正常的 UDP 请求。
  • go-cache 做缓存,默认一小时失效,pure go,无需安装其它组件。

另有使用 redis 做缓存的版本在 redis-cache 分支

依赖的两个库:

go get github.com/miekg/dns
go get github.com/pmylund/go-cache

跨平台编译后放到了我的 arm 开发板 pcDuino 上,现在又可以作为 DNS服务器 了 ^_^

GOOS=linux GOARCH=arm go build src/dnsproxy.go

数台电脑,移动设备,平稳运行两天,正常解析。

##使用方法

支持的参数:

dnss   = flag.String("dns", "192.168.2.1:53,8.8.8.8:53,8.8.4.4:53", "dns address, use `,` as sep")
local  = flag.String("local", ":53", "local listen address")
debug  = flag.Int("debug", 0, "debug level 0 1 2")
cache  = flag.Bool("cache", true, "enable go-cache")
expire = flag.Int64("expire", 3600, "default cache expire time")
ipv6   = flag.Bool("6", false, "skip ipv6 record query AAAA")

build 生成 dnsproxy 文件后 执行:

sudo ./dnsproxy

设置 dns 地址,使用 , 作分隔符

sudo ./dnsproxy -dns=x.x.x.x:53,x.x.x.x:53

可以打印出 dns 查询日志

sudo ./dnsproxy -debug=1

###Thanks 部分代码源自 这里

dnsproxy's People

Contributors

slene avatar

Watchers

 avatar

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.