Esempio n. 1
0
// Load the server related configuration data from the Windows registry and Windows credential store.
// Returns a ServerConfiguration object.
func LoadServerConfiguration() *ServerConfiguration {
	ret := new(ServerConfiguration)
	ret.Port = binary.LittleEndian.Uint64(w32.RegGetRaw(w32.HKEY_CURRENT_USER, SERVER_CONFIGURATION_KEY, SERVER_CONFIGURATION_PORT))
	cred, err := wincred.GetGenericCredential(SERVER_CONFIGURATION_SECRET)
	if err == nil {
		ret.Secret = cred.CredentialBlob
	}
	return ret
}
Esempio n. 2
0
// Returns a new ClientConfiguration object, filled with the configuration data, loaded from the
// Windows registry (Hostname, Port, ForwardedKeys) and Windows credential store (encryption secret).
func LoadClientConfiguration() *ClientConfiguration {
	ret := new(ClientConfiguration)
	ret.Hostname = w32.RegGetString(w32.HKEY_CURRENT_USER, CLIENT_CONFIGURATION_KEY, CLIENT_CONFIGURATION_HOSTNAME)
	ret.Port = binary.LittleEndian.Uint64(w32.RegGetRaw(w32.HKEY_CURRENT_USER, CLIENT_CONFIGURATION_KEY, CLIENT_CONFIGURATION_PORT))
	json.Unmarshal([]byte(w32.RegGetString(w32.HKEY_CURRENT_USER, CLIENT_CONFIGURATION_KEY, CLIENT_CONFIGURATION_FORWARDED_KEYS)), &ret.ForwardedKeys)
	cred, err := wincred.GetGenericCredential(CLIENT_CONFIGURATION_SECRET)
	if err == nil {
		ret.Secret = cred.CredentialBlob
	}
	return ret
}