Beispiel #1
0
// transportUUIDInStorage returns the uuid stored in storage or
// creates a new random uuid and stores it.
func transportUUIDInStorage(storage util.Storage) string {
	uuid, err := storage.Get("uuid")
	if len(uuid) == 0 || err != nil {
		str := util.RandomHexString()
		uuid = []byte(netio.MAC48Address(str))
		err := storage.Set("uuid", uuid)
		if err != nil {
			log.Fatal(err)
		}
	}
	return string(uuid)
}
Beispiel #2
0
// loads load the id, version and config hash
func (cfg *Config) load(storage util.Storage) {
	if b, err := storage.Get("uuid"); err == nil {
		cfg.id = string(b)
	}

	if b, err := storage.Get("version"); err == nil {
		cfg.version = to.Int64(string(b))
	}

	if b, err := storage.Get("configHash"); err == nil {
		cfg.configHash = b
	}
}