Split ConfigLoad()

This commit is contained in:
Frank Denis 2018-01-31 08:27:59 +01:00
parent bbfcb0c5bd
commit 16fc6b74e9

View file

@ -210,6 +210,22 @@ func ConfigLoad(proxy *Proxy, svcFlag *string, config_file string) error {
proxy.forwardFile = config.ForwardFile proxy.forwardFile = config.ForwardFile
if err := config.loadSources(proxy); err != nil {
return err
}
if len(proxy.registeredServers) == 0 {
return errors.New("No servers configured")
}
if *list {
for _, registeredServer := range proxy.registeredServers {
fmt.Println(registeredServer.name)
}
os.Exit(0)
}
return nil
}
func (config *Config) loadSources(proxy *Proxy) error {
requiredProps := ServerInformalProperties(0) requiredProps := ServerInformalProperties(0)
if config.SourceRequireDNSSEC { if config.SourceRequireDNSSEC {
requiredProps |= ServerInformalPropertyDNSSEC requiredProps |= ServerInformalPropertyDNSSEC
@ -220,7 +236,6 @@ func ConfigLoad(proxy *Proxy, svcFlag *string, config_file string) error {
if config.SourceRequireNoFilter { if config.SourceRequireNoFilter {
requiredProps |= ServerInformalPropertyNoFilter requiredProps |= ServerInformalPropertyNoFilter
} }
for cfgSourceName, cfgSource := range config.SourcesConfig { for cfgSourceName, cfgSource := range config.SourcesConfig {
if cfgSource.URL == "" { if cfgSource.URL == "" {
return fmt.Errorf("Missing URL for source [%s]", cfgSourceName) return fmt.Errorf("Missing URL for source [%s]", cfgSourceName)
@ -288,17 +303,7 @@ func ConfigLoad(proxy *Proxy, svcFlag *string, config_file string) error {
if err != nil { if err != nil {
return err return err
} }
proxy.registeredServers = append(proxy.registeredServers, proxy.registeredServers = append(proxy.registeredServers, RegisteredServer{name: serverName, stamp: stamp})
RegisteredServer{name: serverName, stamp: stamp})
}
if len(proxy.registeredServers) == 0 {
return errors.New("No servers configured")
}
if *list {
for _, registeredServer := range proxy.registeredServers {
fmt.Println(registeredServer.name)
}
os.Exit(0)
} }
return nil return nil
} }