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.
35 lines
502 B
Go
35 lines
502 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
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 {}
|
|
}
|