func (ce *CtrlEngine) upkeepFetchconf( msgDB *msgdb.MsgDB, homedir string, show bool, outfp, statfp io.Writer, ) error { netDomain, pubkeyStr, configURL := def.ConfigParams() log.Infof("fetch config for '%s'", netDomain) fmt.Fprintf(statfp, "fetch config for '%s'\n", netDomain) publicKey, err := hex.DecodeString(pubkeyStr) if err != nil { log.Error(err) } ce.config.PublicKey = publicKey ce.config.URLList = "10," + configURL ce.config.Timeout = 0 // use default timeout if err := ce.config.Update(); err != nil { return log.Error(err) } jsn, err := json.Marshal(ce.config) if err != nil { return log.Error(err) } if err := msgDB.AddValue(netDomain, string(jsn)); err != nil { return err } err = msgDB.AddValue("time."+netDomain, strconv.FormatInt(times.Now(), 10)) if err != nil { return err } // apply new configuration if err := def.InitMute(&ce.config); err != nil { return err } // format configuration nicely jsn, err = json.MarshalIndent(ce.config, "", " ") if err != nil { return log.Error(err) } // write new configuration file if err := writeConfigFile(homedir, netDomain, jsn); err != nil { return err } // show new configuration if show { fmt.Fprintf(outfp, string(jsn)+"\n") } return nil }