Accept sources without an URL; use v2 format by default for remote sources

This commit is contained in:
Frank Denis 2018-01-31 14:23:44 +01:00
parent 2d291ecad6
commit d7ec318945
2 changed files with 7 additions and 2 deletions

View File

@ -300,7 +300,7 @@ func (config *Config) loadSources(proxy *Proxy) error {
func (config *Config) loadSource(proxy *Proxy, requiredProps ServerInformalProperties, cfgSourceName string, cfgSource *SourceConfig) error {
if cfgSource.URL == "" {
return fmt.Errorf("Missing URL for source [%s]", cfgSourceName)
dlog.Debugf("Missing URL for source [%s]", cfgSourceName)
}
if cfgSource.MinisignKeyStr == "" {
return fmt.Errorf("Missing Minisign key for source [%s]", cfgSourceName)
@ -309,7 +309,7 @@ func (config *Config) loadSource(proxy *Proxy, requiredProps ServerInformalPrope
return fmt.Errorf("Missing cache file for source [%s]", cfgSourceName)
}
if cfgSource.FormatStr == "" {
return fmt.Errorf("Missing format for source [%s]", cfgSourceName)
cfgSource.FormatStr = "v2"
}
if cfgSource.RefreshDelay <= 0 {
cfgSource.RefreshDelay = 24

View File

@ -67,6 +67,11 @@ func fetchWithCache(xTransport *XTransport, urlStr string, cacheFile string) (in
cached = true
return
}
if len(urlStr) == 0 {
err = fmt.Errorf("Cache file [%s] not present and no URL given to retrieve it", cacheFile)
return
}
var resp *http.Response
dlog.Infof("Loading source information from URL [%s]", urlStr)