[server,proxy] allow reading arbitrary keys from config
Allow the proxy configuration to contain arbitrary section/key/value entries which can be used by plugins for configuration.
This commit is contained in:
parent
b8a0091c92
commit
fd338c3bd4
@ -107,6 +107,8 @@ extern "C"
|
||||
/* Data extracted from PrivateKeyContent or PrivateKeyFile (evaluation in this order) */
|
||||
char* PrivateKeyPEM;
|
||||
size_t PrivateKeyPEMLength;
|
||||
|
||||
wIniFile* ini;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -213,6 +215,17 @@ extern "C"
|
||||
*/
|
||||
FREERDP_API BOOL pf_config_plugin(proxyPluginsManager* plugins_manager, void* userdata);
|
||||
|
||||
/**
|
||||
* @brief pf_config_get get a value for a section/key
|
||||
* @param config A pointer to the proxyConfig. Must NOT be NULL.
|
||||
* @param section The name of the section the key is in, must not be \b NULL
|
||||
* @param key The name of the key to look for. Must not be \b NULL
|
||||
*
|
||||
* @return A pointer to the value for \b section/key or \b NULL if not found
|
||||
*/
|
||||
FREERDP_API const char* pf_config_get(const proxyConfig* config, const char* section,
|
||||
const char* key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -602,6 +602,9 @@ proxyConfig* server_config_load_ini(wIniFile* ini)
|
||||
|
||||
if (!pf_config_load_certificates(ini, config))
|
||||
goto out;
|
||||
config->ini = IniFile_Clone(ini);
|
||||
if (!config->ini)
|
||||
goto out;
|
||||
}
|
||||
return config;
|
||||
out:
|
||||
@ -897,6 +900,7 @@ void pf_server_config_free(proxyConfig* config)
|
||||
if (config->PrivateKeyPEM)
|
||||
memset(config->PrivateKeyPEM, 0, config->PrivateKeyPEMLength);
|
||||
free(config->PrivateKeyPEM);
|
||||
IniFile_Free(config->ini);
|
||||
free(config);
|
||||
}
|
||||
|
||||
@ -1022,6 +1026,10 @@ BOOL pf_config_clone(proxyConfig** dst, const proxyConfig* config)
|
||||
config->PrivateKeyPEMLength))
|
||||
goto fail;
|
||||
|
||||
tmp->ini = IniFile_Clone(config->ini);
|
||||
if (!tmp->ini)
|
||||
goto fail;
|
||||
|
||||
*dst = tmp;
|
||||
return TRUE;
|
||||
|
||||
@ -1326,3 +1334,13 @@ BOOL pf_config_plugin(proxyPluginsManager* plugins_manager, void* userdata)
|
||||
|
||||
return plugins_manager->RegisterPlugin(plugins_manager, &plugin);
|
||||
}
|
||||
|
||||
const char* pf_config_get(const proxyConfig* config, const char* section, const char* key)
|
||||
{
|
||||
WINPR_ASSERT(config);
|
||||
WINPR_ASSERT(config->ini);
|
||||
WINPR_ASSERT(section);
|
||||
WINPR_ASSERT(key);
|
||||
|
||||
return IniFile_GetKeyValueString(config->ini, section, key);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user