Files
acme-dns/main.go

48 lines
883 B
Go
Raw Normal View History

2016-11-11 16:48:00 +02:00
package main
import (
"fmt"
2016-11-26 15:42:35 +02:00
log "github.com/Sirupsen/logrus"
2016-11-11 16:48:00 +02:00
"os"
)
2016-11-23 18:07:38 +02:00
// DNSConf is global configuration struct
2016-11-16 19:15:36 +02:00
var DNSConf DNSConfig
2016-11-11 16:48:00 +02:00
2016-11-23 18:07:38 +02:00
// DB is used to access the database functions in acme-dns
var DB database
2016-11-11 16:48:00 +02:00
2016-11-23 18:07:38 +02:00
// RR holds the static DNS records
2016-11-11 16:48:00 +02:00
var RR Records
func main() {
2016-11-13 14:50:44 +02:00
// Read global config
2016-11-16 19:15:36 +02:00
configTmp, err := readConfig("config.cfg")
2016-11-11 16:48:00 +02:00
if err != nil {
2016-11-26 15:42:35 +02:00
fmt.Printf("Got error %v\n", err)
2016-11-11 16:48:00 +02:00
os.Exit(1)
}
2016-11-16 19:15:36 +02:00
DNSConf = configTmp
2016-11-23 17:11:31 +02:00
2016-11-27 21:21:38 +02:00
setupLogging(DNSConf.Logconfig.Format, DNSConf.Logconfig.Level)
2016-11-13 14:50:44 +02:00
// Read the default records in
2016-11-16 19:15:36 +02:00
RR.Parse(DNSConf.General.StaticRecords)
2016-11-11 16:48:00 +02:00
// Open database
2016-11-17 17:52:55 +02:00
err = DB.Init(DNSConf.Database.Engine, DNSConf.Database.Connection)
2016-11-11 16:48:00 +02:00
if err != nil {
log.Errorf("Could not open database [%v]", err)
os.Exit(1)
}
defer DB.DB.Close()
2016-11-27 21:21:38 +02:00
// DNS server
startDNS(DNSConf.General.Listen)
2016-11-11 16:48:00 +02:00
2016-11-27 22:09:13 +02:00
// HTTP API
startHTTPAPI()
2016-11-11 16:48:00 +02:00
log.Debugf("Shutting down...")
}