You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
501 B
Go
34 lines
501 B
Go
8 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"flag"
|
||
|
"fmt"
|
||
|
"github.com/miekg/dns"
|
||
|
"log"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
var configfile string
|
||
|
|
||
|
flag.StringVar(&configfile, "c", "config.yaml", "config file")
|
||
|
flag.Parse()
|
||
|
|
||
|
config, err := loadConfig(configfile)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
h := newDNSHandler(config)
|
||
|
|
||
|
for _, l := range config.Listen {
|
||
|
go func(l addr) {
|
||
|
if err := dns.ListenAndServe(
|
||
|
fmt.Sprintf("%s:%d", l.Host, l.Port), l.Network, h); err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
}(l)
|
||
|
}
|
||
|
|
||
|
select {}
|
||
|
}
|