Example #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)
}
Example #2
0
func defaultConfig(name string) *Config {
	ip, err := getFirstLocalIPAddr()
	if err != nil {
		log.Info.Panic(err)
	}

	return &Config{
		StoragePath:  name,
		Pin:          "00102003", // default pin
		Port:         "",         // empty string means that we get port from assigned by the system
		IP:           ip.String(),
		name:         name,
		id:           util.MAC48Address(util.RandomHexString()),
		version:      1,
		state:        1,
		protocol:     "1.0",
		discoverable: true,
		mfiCompliant: false,
	}
}
Example #3
0
// generateKeyPairs generates random public and private key pairs
func generateKeyPairs() ([]byte, []byte, error) {
	str := util.RandomHexString()
	public, private, err := crypto.ED25519GenerateKey(str)
	return public, private, err
}