diff --git a/coolDns.go b/coolDns.go index 28f8392..1e1a913 100644 --- a/coolDns.go +++ b/coolDns.go @@ -1,6 +1,7 @@ package main import ( + "flag" "io/ioutil" "log" "net" @@ -57,8 +58,8 @@ var anyRecordTypes = []uint16{ dns.TypeCAA, } -func loadConfig() (*config, error) { - file, err := ioutil.ReadFile("config.yml") +func loadConfig(configPath string) (*config, error) { + file, err := ioutil.ReadFile(configPath) if err != nil { return nil, err } @@ -324,7 +325,11 @@ func handleRequest(w dns.ResponseWriter, r *dns.Msg, zone zoneView) { } func main() { - config, err := loadConfig() + + configPath := flag.String("c", "/etc/cool-dns/config.yaml", "path to the config file") + flag.Parse() + + config, err := loadConfig(*configPath) if err != nil { log.Fatalf("Failed to load config: %s", err.Error()) }