server: proxy: refactor usage of pf_context_copy_settings

This commit is contained in:
kubistika 2019-09-08 15:18:45 +03:00
parent 7ed39ce724
commit f5d32f4617
3 changed files with 14 additions and 18 deletions

View File

@ -57,14 +57,18 @@
* Re-negotiate with original client after negotiation between the proxy
* and the target has finished.
*/
static void proxy_server_reactivate(rdpContext* ps, const rdpContext* target)
static BOOL proxy_server_reactivate(rdpContext* ps, const rdpContext* pc)
{
pf_context_copy_settings(ps->settings, target->settings, TRUE);
if (!pf_context_copy_settings(ps->settings, pc->settings))
return FALSE;
/* DesktopResize causes internal function rdp_server_reactivate to be called,
* which causes the reactivation.
*/
ps->update->DesktopResize(ps);
if (!ps->update->DesktopResize(ps))
return FALSE;
return TRUE;
}
static void pf_OnErrorInfo(void* ctx, ErrorInfoEventArgs* e)
@ -220,8 +224,7 @@ static BOOL pf_client_post_connect(freerdp* instance)
}
pf_client_register_update_callbacks(update);
proxy_server_reactivate(ps, context);
return TRUE;
return proxy_server_reactivate(ps, context);
}

View File

@ -75,7 +75,7 @@ BOOL init_p_server_context(freerdp_peer* client)
* when using this function, is_dst_server must be set to TRUE if the destination
* settings are server's settings. otherwise, they must be set to FALSE.
*/
BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src, BOOL is_dst_server)
BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src)
{
rdpSettings* before_copy = freerdp_settings_clone(dst);
if (!before_copy)
@ -97,7 +97,7 @@ BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src, BOOL is_
free(dst->CertificateContent);
/* adjust pointer to instance pointer */
dst->ServerMode = is_dst_server;
dst->ServerMode = before_copy->ServerMode;
/* revert some values that must not be changed */
dst->ConfigPath = _strdup(before_copy->ConfigPath);
@ -109,12 +109,7 @@ BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src, BOOL is_
dst->CertificateName = _strdup(before_copy->CertificateName);
dst->CertificateContent = _strdup(before_copy->CertificateContent);
if (is_dst_server)
{
free(dst->ServerCertificate);
dst->ServerCertificateLength = before_copy->ServerCertificateLength;
}
else
if (!dst->ServerMode)
{
/* adjust instance pointer for client's context */
dst->instance = before_copy->instance;
@ -137,9 +132,7 @@ rdpContext* p_client_context_create(rdpSettings* clientSettings)
if (!context)
return NULL;
pf_context_copy_settings(context->settings, clientSettings, FALSE);
if (!context->settings)
if (!pf_context_copy_settings(context->settings, clientSettings))
goto error;
return context;

View File

@ -107,9 +107,9 @@ rdpContext* p_client_context_create(rdpSettings* clientSettings);
proxyData* proxy_data_new(void);
void proxy_data_free(proxyData* pdata);
BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src, BOOL is_dst_server);
void proxy_data_abort_connect(proxyData* pdata);
BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src);
BOOL proxy_data_shall_disconnect(proxyData* pdata);
void proxy_data_abort_connect(proxyData* pdata);
/* server */
BOOL init_p_server_context(freerdp_peer* client);