示例#1
0
// Saves the given ServerConfiguration object to the Windows registry and Windows credential store.
func StoreServerConfiguration(configuration *ServerConfiguration) {
	regKey := w32.RegCreateKey(w32.HKEY_CURRENT_USER, SERVER_CONFIGURATION_KEY)
	regSetQWORD(regKey, SERVER_CONFIGURATION_PORT, configuration.Port)

	cred := wincred.NewGenericCredential(SERVER_CONFIGURATION_SECRET)
	cred.CredentialBlob = configuration.Secret
	cred.Write()
}
示例#2
0
// Saves the given ClientConfiguration object to the Windows registry and Windows credential store.
func StoreClientConfiguration(configuration *ClientConfiguration) {
	jsonForwardedKeys, _ := json.Marshal(configuration.ForwardedKeys)

	regKey := w32.RegCreateKey(w32.HKEY_CURRENT_USER, CLIENT_CONFIGURATION_KEY)
	regSetString(regKey, CLIENT_CONFIGURATION_HOSTNAME, configuration.Hostname)
	regSetQWORD(regKey, CLIENT_CONFIGURATION_PORT, configuration.Port)
	regSetString(regKey, CLIENT_CONFIGURATION_FORWARDED_KEYS, string(jsonForwardedKeys))

	cred := wincred.NewGenericCredential(CLIENT_CONFIGURATION_SECRET)
	cred.CredentialBlob = configuration.Secret
	cred.Write()
}