Refactoring

This commit is contained in:
Joona Hoikkala
2016-11-27 21:21:38 +02:00
parent bff6310dc7
commit 74b82c87a6
6 changed files with 31 additions and 47 deletions

15
main.go
View File

@ -5,7 +5,6 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/iris-contrib/middleware/cors"
"github.com/kataras/iris"
"github.com/miekg/dns"
"os"
)
@ -27,7 +26,7 @@ func main() {
}
DNSConf = configTmp
setupLogging()
setupLogging(DNSConf.Logconfig.Format, DNSConf.Logconfig.Level)
// Read the default records in
RR.Parse(DNSConf.General.StaticRecords)
@ -40,16 +39,8 @@ func main() {
}
defer DB.DB.Close()
// DNS server part
dns.HandleFunc(".", handleRequest)
server := &dns.Server{Addr: ":53", Net: "udp"}
go func() {
err = server.ListenAndServe()
if err != nil {
log.Errorf("%v", err)
os.Exit(1)
}
}()
// DNS server
startDNS(DNSConf.General.Listen)
// API server and endpoints
api := iris.New()