Giter Site home page Giter Site logo

godns's Introduction

GODNS

A simple and fast dns cache server written by go.

Similar as dnsmasq ,but support some difference features:

  • Keep hosts records in redis instead of the local file /etc/hosts

  • Atuo-Reload when hosts configuration changed. (Yes,dnsmasq need reload)

  • Cache records save in memory or redis configurable

Install & Running

  1. Install

     $ go get github.com/kenshinx/godns
    
  2. Build

     $ cd $GOPATH/src/github.com/kenshinx/godns 
     $ go build -o godns *.go
    
  3. Running

     $ sudo ./godns -c godns.conf
    

Use godns

	$ sudo vi /etc/resolv.conf
	nameserver #the ip of godns running

Configuration

All the configuration on godns.conf a TOML formating config file.
More about Toml :https://github.com/mojombo/toml

resolv.conf

Upstream server can be configuration by change file from somewhere other that "/etc/resolv.conf"

[resolv]
resolv-file = "/etc/resolv.conf"

If multi namerserver set at resolv.conf, the upsteam server will try in order of up to botton

cache

Only the local memory storage backend implemented now. The redis backend is in todo list

[cache]
backend = "memory"   
expire = 600  # default expire time 10 minutes
maxcount = 100000

hosts

Force resolv domain to assigned ip, support two types hosts configuration:

  • locale hosts file
  • remote redis hosts

hosts file

can be assigned at godns.conf,default : /etc/hosts

[hosts]
host-file = "/etc/hosts"

redis hosts

This is a espeical requirment in our system. Must maintain a gloab hosts configuration, and support update the hosts record from other remote server. so "redis-hosts" is be supported, and will query the reids when each dns request reached.

The hosts record is organized with redis hash map. and the key of the map is configured.

[hosts]
redis-key = "godns:hosts"

Insert hosts records into redis

redis > hset godns:hosts www.sina.com.cn 1.1.1.1

Benchmak

Debug close

$ go test -bench=.

testing: warning: no tests to run
PASS
BenchmarkDig-8     50000             57945 ns/op
ok      _/usr/home/keqiang/godns        3.259s

The result : 15342 queries/per second

The enviroment of test:

CentOS release 6.4

  • CPU:
    Intel Xeon 2.40GHZ 4 cores

  • MEM:
    46G

Web console

Joke: A web console for godns

https://github.com/kenshinx/joke

screenshot

joke

Deployment

Deployment in productive supervisord highly recommended.


[program:godns]
command=/usr/local/bin/godns -c /etc/godns.conf
autostart=true
autorestart=true
user=root
stdout_logfile_maxbytes = 50MB
stdoiut_logfile_backups = 20
stdout_logfile = /var/log/godns.log

TODO

  • The redis cache backend
  • Update ttl

godns's People

Contributors

kenshinx avatar mvrilo 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.