Factor out LoadConfig
This commit is contained in:
parent
2ed92fadf9
commit
4c56825359
@ -28,6 +28,14 @@ func parseNetworks(networksconf string) (map[string]*net.IPNet, error) {
|
||||
return networks, nil
|
||||
}
|
||||
|
||||
func loadConfig(s *meshname.MeshnameServer, confPath string) error {
|
||||
zoneConf, err := meshname.ParseConfigFile(confPath)
|
||||
if err == nil {
|
||||
s.SetZoneConfig(zoneConf)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
var (
|
||||
genconf, subdomain, useconffile, listenAddr, networksconf string
|
||||
debug bool
|
||||
@ -75,7 +83,9 @@ func main() {
|
||||
}
|
||||
|
||||
if useconffile != "" {
|
||||
s.LoadConfig(useconffile)
|
||||
if err := loadConfig(s, useconffile); err != nil {
|
||||
logger.Errorln(err)
|
||||
}
|
||||
}
|
||||
|
||||
s.Start()
|
||||
@ -91,7 +101,9 @@ func main() {
|
||||
return
|
||||
case _ = <-r:
|
||||
if useconffile != "" {
|
||||
s.LoadConfig(useconffile)
|
||||
if err := loadConfig(s, useconffile); err != nil {
|
||||
logger.Errorln(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,16 +68,6 @@ func (s *MeshnameServer) Start() error {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MeshnameServer) LoadConfig(confPath string) {
|
||||
if zoneConf, err := ParseConfigFile(confPath); err == nil {
|
||||
s.zoneConfigLock.Lock()
|
||||
s.zoneConfig = zoneConf
|
||||
s.zoneConfigLock.Unlock()
|
||||
} else {
|
||||
s.log.Errorln("Can't parse config file:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MeshnameServer) SetZoneConfig(zoneConfig map[string][]dns.RR) {
|
||||
s.zoneConfigLock.Lock()
|
||||
s.zoneConfig = zoneConfig
|
||||
|
Loading…
Reference in New Issue
Block a user