added config path as parameter
This commit is contained in:
parent
85db27cdde
commit
5ce381f370
11
coolDns.go
11
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())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user