Merge pull request #5404 from m4ntis/feat/proxy-errors
Proxy: Redirect errors back to client
This commit is contained in:
commit
1cb8ed96e2
@ -453,6 +453,7 @@ FREERDP_API int freerdp_message_queue_process_pending_messages(
|
||||
|
||||
FREERDP_API UINT32 freerdp_error_info(freerdp* instance);
|
||||
FREERDP_API void freerdp_set_error_info(rdpRdp* rdp, UINT32 error);
|
||||
FREERDP_API BOOL freerdp_send_error_info(rdpRdp* rdp);
|
||||
|
||||
FREERDP_API void freerdp_get_version(int* major, int* minor, int* revision);
|
||||
FREERDP_API const char* freerdp_get_version_string(void);
|
||||
|
@ -789,6 +789,14 @@ void freerdp_set_error_info(rdpRdp* rdp, UINT32 error)
|
||||
rdp_set_error_info(rdp, error);
|
||||
}
|
||||
|
||||
BOOL freerdp_send_error_info(rdpRdp* rdp)
|
||||
{
|
||||
if (!rdp)
|
||||
return FALSE;
|
||||
|
||||
return rdp_send_error_info(rdp);
|
||||
}
|
||||
|
||||
UINT32 freerdp_get_last_error(rdpContext* context)
|
||||
{
|
||||
return context->LastError;
|
||||
|
@ -90,6 +90,23 @@ static BOOL pf_client_end_paint(rdpContext* context)
|
||||
return ps->update->EndPaint(ps);
|
||||
}
|
||||
|
||||
static void pf_OnErrorInfo(void* ctx, ErrorInfoEventArgs* e)
|
||||
{
|
||||
pClientContext* pc = (pClientContext*) ctx;
|
||||
proxyData* pdata = pc->pdata;
|
||||
rdpContext* ps = (rdpContext*)pdata->ps;
|
||||
|
||||
if (e->code != ERRINFO_NONE)
|
||||
{
|
||||
const char* errorMessage = freerdp_get_error_info_string(e->code);
|
||||
WLog_DBG(TAG, "Client received error info (0x%08"PRIu32"): %s", e->code, errorMessage);
|
||||
/* forward error back to client */
|
||||
freerdp_set_error_info(ps->rdp, e->code);
|
||||
freerdp_send_error_info(ps->rdp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called before a connection is established.
|
||||
*
|
||||
@ -114,6 +131,7 @@ static BOOL pf_client_pre_connect(freerdp* instance)
|
||||
pf_OnChannelConnectedEventHandler);
|
||||
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
|
||||
pf_OnChannelDisconnectedEventHandler);
|
||||
PubSub_SubscribeErrorInfo(instance->context->pubSub, pf_OnErrorInfo);
|
||||
/**
|
||||
* Load all required plugins / channels / libraries specified by current
|
||||
* settings.
|
||||
@ -219,18 +237,20 @@ static void pf_client_post_disconnect(freerdp* instance)
|
||||
|
||||
context = (pClientContext*) instance->context;
|
||||
pdata = context->pdata;
|
||||
ps = (rdpContext*) pdata->ps;
|
||||
peer = ps->peer;
|
||||
|
||||
PubSub_UnsubscribeChannelConnected(instance->context->pubSub,
|
||||
pf_OnChannelConnectedEventHandler);
|
||||
PubSub_UnsubscribeChannelDisconnected(instance->context->pubSub,
|
||||
pf_OnChannelDisconnectedEventHandler);
|
||||
PubSub_UnsubscribeErrorInfo(instance->context->pubSub, pf_OnErrorInfo);
|
||||
gdi_free(instance);
|
||||
ps = (rdpContext*) pdata->ps;
|
||||
|
||||
if (!pf_common_connection_aborted_by_peer(pdata))
|
||||
{
|
||||
SetEvent(pdata->connectionClosed);
|
||||
WLog_INFO(TAG, "connectionClosed event is not set; closing connection with client");
|
||||
peer = ps->peer;
|
||||
peer->Disconnect(peer);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user