-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdnsgo.go
49 lines (41 loc) · 974 Bytes
/
dnsgo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/grt1st/dnsgo/handles"
"github.com/grt1st/dnsgo/service"
)
const versionNumber = "1.0.1#20180623"
func main() {
// lookup
// localhost
// log
version := flag.Bool("version", false, "Show program's version number and exit")
host := flag.String("host", "localhost", "Address to bind")
query := flag.Bool("query", false, "Whether to send dns request")
logFilename := flag.String("log", "", "Filename of log file")
help := flag.Bool("h", false, "Show usage")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage:\n %s [Options]\n\nOptions\n", os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
if *help {
flag.Usage()
os.Exit(0)
}
if *version {
fmt.Println(versionNumber)
os.Exit(0)
}
service.Init("./conf/default.conf")
server := &handles.Server{
Host: *host,
Port: 53,
RTimeout: 5 * time.Second,
WTimeout: 5 * time.Second,
}
server.Run(*query, *logFilename)
}