39 lines
746 B
Go
39 lines
746 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"log/syslog"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
var err error
|
|
|
|
// default configuration file is /etc/pdns-proxy.conf
|
|
configFile := flag.String("config", "/etc/pdns-proxy.conf", "configuration file")
|
|
logToSyslog := flag.Bool("syslog", false, "Log to syslog")
|
|
debug := flag.Bool("debug", false, "log every message received")
|
|
flag.Parse()
|
|
|
|
// in the production environnement, redirect every lgo() call to syslog
|
|
if *logToSyslog {
|
|
log.SetFlags(0)
|
|
logWriter, e := syslog.New(syslog.LOG_NOTICE, "pdnsProxy")
|
|
if e == nil {
|
|
log.SetOutput(logWriter)
|
|
defer logWriter.Close()
|
|
}
|
|
}
|
|
h, err := loadConfig(*configFile)
|
|
if err != nil {
|
|
log.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if *debug {
|
|
h.Debug()
|
|
}
|
|
h.Run()
|
|
}
|