Skip to content

Commit

Permalink
add a flag for TTL
Browse files Browse the repository at this point in the history
  • Loading branch information
bamarni committed Apr 1, 2016
1 parent 0755f67 commit 547fd33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Prebuilt binaries are available in the [releases](https://github.com/bamarni/doc

Options:
-tld Top-level domain to use (defaults to "docker")
-ttl Time to Live for DNS records (defaults to 0)
-port Port to listen on (defaults to "53")
-server-only Server only, doesn't try to create a resolver configuration file
-user Execute the "docker-machine ip" command as a different user (defaults to "SUDO_USER")
Expand Down
4 changes: 3 additions & 1 deletion dockness.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strings"
)

var ttl uint
var user string

func lookup(w dns.ResponseWriter, r *dns.Msg) {
Expand Down Expand Up @@ -53,7 +54,7 @@ func lookup(w dns.ResponseWriter, r *dns.Msg) {
Name: q.Name,
Rrtype: dns.TypeA,
Class: dns.ClassINET,
Ttl: 0,
Ttl: uint32(ttl),
},
A: net.ParseIP(ip).To4(),
}
Expand All @@ -66,6 +67,7 @@ func lookup(w dns.ResponseWriter, r *dns.Msg) {

func main() {
tld := flag.String("tld", "docker", "Top-level domain to use")
flag.UintVar(&ttl, "ttl", 0, "Time to Live for DNS records")
port := flag.String("port", "53", "Port to listen on")
serverOnly := flag.Bool("server-only", false, "Server only, doesn't try to create a resolver configuration")
flag.StringVar(&user, "user", os.Getenv("SUDO_USER"), "Execute the 'docker-machine ip' command as this user")
Expand Down

0 comments on commit 547fd33

Please sign in to comment.