Added proxy module callbacks for session init and started (#7976)

This commit is contained in:
akallabeth 2022-06-20 13:02:25 +02:00 committed by GitHub
parent 44582f821b
commit f44554e16d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View File

@ -76,8 +76,10 @@ struct proxy_plugin
proxyHookFn ServerChannelsInit; /* 98 custom=freerdp_peer* */ proxyHookFn ServerChannelsInit; /* 98 custom=freerdp_peer* */
proxyHookFn ServerChannelsFree; /* 99 custom=freerdp_peer* */ proxyHookFn ServerChannelsFree; /* 99 custom=freerdp_peer* */
proxyHookFn ServerSessionEnd; /* 100 custom=freerdp_peer* */ proxyHookFn ServerSessionEnd; /* 100 custom=freerdp_peer* */
proxyHookFn ServerSessionInitialize; /* 101 custom=freerdp_peer* */
proxyHookFn ServerSessionStarted; /* 102 custom=freerdp_peer* */
UINT64 reserved4[128 - 101]; /* 101 - 127 */ UINT64 reserved4[128 - 103]; /* 103 - 127 */
/* proxy filters. a module can set these function pointers to register filters */ /* proxy filters. a module can set these function pointers to register filters */
proxyFilterFn KeyboardEvent; /* 128 */ proxyFilterFn KeyboardEvent; /* 128 */

View File

@ -105,6 +105,10 @@ static const char* pf_modules_get_hook_type_string(PF_HOOK_TYPE result)
return "HOOK_TYPE_SERVER_CHANNELS_FREE"; return "HOOK_TYPE_SERVER_CHANNELS_FREE";
case HOOK_TYPE_SERVER_SESSION_END: case HOOK_TYPE_SERVER_SESSION_END:
return "HOOK_TYPE_SERVER_SESSION_END"; return "HOOK_TYPE_SERVER_SESSION_END";
case HOOK_TYPE_SERVER_SESSION_INITIALIZE:
return "HOOK_TYPE_SERVER_SESSION_INITIALIZE";
case HOOK_TYPE_SERVER_SESSION_STARTED:
return "HOOK_TYPE_SERVER_SESSION_STARTED";
case HOOK_LAST: case HOOK_LAST:
return "HOOK_LAST"; return "HOOK_LAST";
default: default:
@ -184,6 +188,14 @@ static BOOL pf_modules_proxy_ArrayList_ForEachFkt(void* data, size_t index, va_l
ok = IFCALLRESULT(TRUE, plugin->ServerSessionEnd, plugin, pdata, custom); ok = IFCALLRESULT(TRUE, plugin->ServerSessionEnd, plugin, pdata, custom);
break; break;
case HOOK_TYPE_SERVER_SESSION_INITIALIZE:
ok = IFCALLRESULT(TRUE, plugin->ServerSessionInitialize, plugin, pdata, custom);
break;
case HOOK_TYPE_SERVER_SESSION_STARTED:
ok = IFCALLRESULT(TRUE, plugin->ServerSessionStarted, plugin, pdata, custom);
break;
case HOOK_LAST: case HOOK_LAST:
default: default:
WLog_ERR(TAG, "invalid hook called"); WLog_ERR(TAG, "invalid hook called");

View File

@ -572,12 +572,16 @@ static DWORD WINAPI pf_server_handle_peer(LPVOID arg)
pdata = ps->pdata; pdata = ps->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
pf_modules_run_hook(pdata->module, HOOK_TYPE_SERVER_SESSION_INITIALIZE, pdata, client);
WINPR_ASSERT(client->Initialize); WINPR_ASSERT(client->Initialize);
client->Initialize(client); client->Initialize(client);
PROXY_LOG_INFO(TAG, ps, "new connection: proxy address: %s, client address: %s", PROXY_LOG_INFO(TAG, ps, "new connection: proxy address: %s, client address: %s",
pdata->config->Host, client->hostname); pdata->config->Host, client->hostname);
pf_modules_run_hook(pdata->module, HOOK_TYPE_SERVER_SESSION_STARTED, pdata, client);
while (1) while (1)
{ {
HANDLE ChannelEvent = INVALID_HANDLE_VALUE; HANDLE ChannelEvent = INVALID_HANDLE_VALUE;
@ -676,7 +680,6 @@ fail:
pf_modules_run_hook(pdata->module, HOOK_TYPE_SERVER_SESSION_END, pdata, client); pf_modules_run_hook(pdata->module, HOOK_TYPE_SERVER_SESSION_END, pdata, client);
PROXY_LOG_INFO(TAG, ps, "freeing server's channels"); PROXY_LOG_INFO(TAG, ps, "freeing server's channels");
WINPR_ASSERT(client->Close); WINPR_ASSERT(client->Close);

View File

@ -57,6 +57,8 @@ typedef enum
HOOK_TYPE_SERVER_CHANNELS_INIT, HOOK_TYPE_SERVER_CHANNELS_INIT,
HOOK_TYPE_SERVER_CHANNELS_FREE, HOOK_TYPE_SERVER_CHANNELS_FREE,
HOOK_TYPE_SERVER_SESSION_END, HOOK_TYPE_SERVER_SESSION_END,
HOOK_TYPE_SERVER_SESSION_INITIALIZE,
HOOK_TYPE_SERVER_SESSION_STARTED,
HOOK_LAST HOOK_LAST
} PF_HOOK_TYPE; } PF_HOOK_TYPE;