server: proxy: refactor pf_context_create_client_context

This commit is contained in:
kubistika 2019-09-25 16:09:36 +03:00 committed by akallabeth
parent b6730ea31e
commit 4d175f6008
3 changed files with 16 additions and 10 deletions

View File

@ -138,9 +138,10 @@ BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src)
return TRUE;
}
rdpContext* pf_context_create_client_context(rdpSettings* clientSettings)
pClientContext* pf_context_create_client_context(rdpSettings* clientSettings)
{
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
pClientContext* pc;
rdpContext* context;
RdpClientEntry(&clientEntryPoints);
context = freerdp_client_context_new(&clientEntryPoints);
@ -148,10 +149,12 @@ rdpContext* pf_context_create_client_context(rdpSettings* clientSettings)
if (!context)
return NULL;
pc = (pClientContext*) context;
if (!pf_context_copy_settings(context->settings, clientSettings))
goto error;
return context;
return pc;
error:
freerdp_client_context_free(context);
return NULL;

View File

@ -101,7 +101,7 @@ struct proxy_data
BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src);
BOOL pf_context_init_server_context(freerdp_peer* client);
rdpContext* pf_context_create_client_context(rdpSettings* clientSettings);
pClientContext* pf_context_create_client_context(rdpSettings* clientSettings);
proxyData* proxy_data_new(void);
void proxy_data_free(proxyData* pdata);

View File

@ -138,7 +138,8 @@ static BOOL pf_server_get_target_info(rdpContext* context, rdpSettings* settings
static BOOL pf_server_post_connect(freerdp_peer* client)
{
pServerContext* ps;
rdpContext* pc;
pClientContext* pc;
rdpSettings* client_settings;
proxyData* pdata;
ps = (pServerContext*)client->context;
pdata = ps->pdata;
@ -150,18 +151,20 @@ static BOOL pf_server_post_connect(freerdp_peer* client)
return FALSE;
}
/* keep both sides of the connection in pdata */
((pClientContext*)pc)->pdata = ps->pdata;
pdata->pc = (pClientContext*)pc;
client_settings = pc->context.settings;
if (!pf_server_get_target_info(client->context, pc->settings, pdata->config))
/* keep both sides of the connection in pdata */
pc->pdata = ps->pdata;
pdata->pc = pc;
if (!pf_server_get_target_info(client->context, client_settings, pdata->config))
{
WLog_ERR(TAG, "pf_server_post_connect(): pf_server_get_target_info failed!");
return FALSE;
}
WLog_INFO(TAG, "pf_server_post_connect(): target == %s:%"PRIu16"", pc->settings->ServerHostname,
pc->settings->ServerPort);
WLog_INFO(TAG, "pf_server_post_connect(): target == %s:%"PRIu16"",
client_settings->ServerHostname, client_settings->ServerPort);
if (!pf_server_channels_init(ps))
{