Unified auto_reconnect functions for all clients.
This commit is contained in:
parent
040d14b673
commit
897c0c72a7
@ -333,10 +333,10 @@ static BOOL wf_post_connect(freerdp* instance)
|
||||
_snwprintf_s(lpWindowName, ARRAYSIZE(lpWindowName), _TRUNCATE, L"%S", settings->WindowTitle);
|
||||
else if (settings->ServerPort == 3389)
|
||||
_snwprintf_s(lpWindowName, ARRAYSIZE(lpWindowName), _TRUNCATE, L"FreeRDP: %S",
|
||||
settings->ServerHostname);
|
||||
settings->ServerHostname);
|
||||
else
|
||||
_snwprintf_s(lpWindowName, ARRAYSIZE(lpWindowName), _TRUNCATE, L"FreeRDP: %S:%u",
|
||||
settings->ServerHostname, settings->ServerPort);
|
||||
settings->ServerHostname, settings->ServerPort);
|
||||
|
||||
if (settings->EmbeddedWindow)
|
||||
settings->Decorations = FALSE;
|
||||
@ -541,48 +541,6 @@ static DWORD wf_verify_changed_certificate(freerdp* instance,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static BOOL wf_auto_reconnect(freerdp* instance)
|
||||
{
|
||||
wfContext* wfc = (wfContext*)instance->context;
|
||||
UINT32 num_retries = 0;
|
||||
UINT32 max_retries = instance->settings->AutoReconnectMaxRetries;
|
||||
|
||||
/* Only auto reconnect on network disconnects. */
|
||||
if (freerdp_error_info(instance) != 0)
|
||||
return FALSE;
|
||||
|
||||
/* A network disconnect was detected */
|
||||
WLog_ERR(TAG, "Network disconnect!");
|
||||
|
||||
if (!instance->settings->AutoReconnectionEnabled)
|
||||
{
|
||||
/* No auto-reconnect - just quit */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Perform an auto-reconnect. */
|
||||
for (;;)
|
||||
{
|
||||
/* Quit retrying if max retries has been exceeded */
|
||||
if (num_retries++ >= max_retries)
|
||||
return FALSE;
|
||||
|
||||
/* Attempt the next reconnect */
|
||||
WLog_INFO(TAG, "Attempting reconnect (%lu of %lu)", num_retries, max_retries);
|
||||
|
||||
if (freerdp_reconnect(instance))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Sleep(5000);
|
||||
}
|
||||
|
||||
WLog_ERR(TAG, "Maximum reconnect retries exceeded");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static DWORD WINAPI wf_input_thread(LPVOID arg)
|
||||
{
|
||||
int status;
|
||||
@ -683,7 +641,7 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam)
|
||||
{
|
||||
if (!freerdp_check_event_handles(context))
|
||||
{
|
||||
if (wf_auto_reconnect(instance))
|
||||
if (client_auto_reconnect(instance))
|
||||
continue;
|
||||
|
||||
WLog_ERR(TAG, "Failed to check FreeRDP file descriptor");
|
||||
|
@ -1413,48 +1413,6 @@ static DWORD WINAPI xf_input_thread(LPVOID arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL xf_auto_reconnect(freerdp* instance)
|
||||
{
|
||||
UINT32 maxRetries;
|
||||
UINT32 numRetries = 0;
|
||||
rdpSettings* settings = instance->settings;
|
||||
maxRetries = settings->AutoReconnectMaxRetries;
|
||||
|
||||
/* Only auto reconnect on network disconnects. */
|
||||
if (freerdp_error_info(instance) != 0)
|
||||
return FALSE;
|
||||
|
||||
/* A network disconnect was detected */
|
||||
WLog_INFO(TAG, "Network disconnect!");
|
||||
|
||||
if (!settings->AutoReconnectionEnabled)
|
||||
{
|
||||
/* No auto-reconnect - just quit */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Perform an auto-reconnect. */
|
||||
while (TRUE)
|
||||
{
|
||||
/* Quit retrying if max retries has been exceeded */
|
||||
if ((maxRetries > 0) && (numRetries++ >= maxRetries))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Attempt the next reconnect */
|
||||
WLog_INFO(TAG, "Attempting reconnect (%"PRIu32" of %"PRIu32")", numRetries, maxRetries);
|
||||
|
||||
if (freerdp_reconnect(instance))
|
||||
return TRUE;
|
||||
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
WLog_ERR(TAG, "Maximum reconnect retries exceeded");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/** Main loop for the rdp connection.
|
||||
* It will be run from the thread's entry point (thread_func()).
|
||||
* It initiates the connection, and will continue to run until the session ends,
|
||||
@ -1590,7 +1548,7 @@ static DWORD WINAPI xf_client_thread(LPVOID param)
|
||||
{
|
||||
if (!freerdp_check_event_handles(context))
|
||||
{
|
||||
if (xf_auto_reconnect(instance))
|
||||
if (client_auto_reconnect(instance))
|
||||
continue;
|
||||
else
|
||||
{
|
||||
|
@ -553,4 +553,51 @@ DWORD client_cli_verify_changed_certificate(freerdp* instance,
|
||||
return client_cli_accept_certificate(instance->settings);
|
||||
}
|
||||
|
||||
BOOL client_auto_reconnect(freerdp* instance)
|
||||
{
|
||||
UINT32 maxRetries;
|
||||
UINT32 numRetries = 0;
|
||||
rdpSettings* settings;
|
||||
|
||||
if (!instance || !instance->settings)
|
||||
return FALSE;
|
||||
|
||||
settings = instance->settings;
|
||||
maxRetries = settings->AutoReconnectMaxRetries;
|
||||
|
||||
/* Only auto reconnect on network disconnects. */
|
||||
if (freerdp_error_info(instance) != 0)
|
||||
return FALSE;
|
||||
|
||||
/* A network disconnect was detected */
|
||||
WLog_INFO(TAG, "Network disconnect!");
|
||||
|
||||
if (!settings->AutoReconnectionEnabled)
|
||||
{
|
||||
/* No auto-reconnect - just quit */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Perform an auto-reconnect. */
|
||||
while (TRUE)
|
||||
{
|
||||
/* Quit retrying if max retries has been exceeded */
|
||||
if ((maxRetries > 0) && (numRetries++ >= maxRetries))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Attempt the next reconnect */
|
||||
WLog_INFO(TAG, "Attempting reconnect (%"PRIu32" of %"PRIu32")", numRetries, maxRetries);
|
||||
|
||||
if (freerdp_reconnect(instance))
|
||||
return TRUE;
|
||||
|
||||
Sleep(5000);
|
||||
}
|
||||
|
||||
WLog_ERR(TAG, "Maximum reconnect retries exceeded");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,26 +86,34 @@ FREERDP_API freerdp* freerdp_client_get_instance(rdpContext* context);
|
||||
FREERDP_API HANDLE freerdp_client_get_thread(rdpContext* context);
|
||||
|
||||
FREERDP_API int freerdp_client_settings_parse_command_line(rdpSettings* settings,
|
||||
int argc, char** argv, BOOL allowUnknown);
|
||||
int argc, char** argv, BOOL allowUnknown);
|
||||
|
||||
FREERDP_API int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const char* filename);
|
||||
FREERDP_API int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, const BYTE* buffer, size_t size);
|
||||
FREERDP_API int freerdp_client_settings_write_connection_file(const rdpSettings* settings, const char* filename, BOOL unicode);
|
||||
FREERDP_API int freerdp_client_settings_parse_connection_file(rdpSettings* settings,
|
||||
const char* filename);
|
||||
FREERDP_API int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings,
|
||||
const BYTE* buffer, size_t size);
|
||||
FREERDP_API int freerdp_client_settings_write_connection_file(const rdpSettings* settings,
|
||||
const char* filename, BOOL unicode);
|
||||
|
||||
FREERDP_API int freerdp_client_settings_parse_assistance_file(rdpSettings* settings, const char* filename);
|
||||
FREERDP_API int freerdp_client_settings_parse_assistance_file(rdpSettings* settings,
|
||||
const char* filename);
|
||||
|
||||
FREERDP_API BOOL client_cli_authenticate(freerdp* instance, char** username, char** password, char** domain);
|
||||
FREERDP_API BOOL client_cli_gw_authenticate(freerdp* instance, char** username, char** password, char** domain);
|
||||
FREERDP_API BOOL client_cli_authenticate(freerdp* instance, char** username, char** password,
|
||||
char** domain);
|
||||
FREERDP_API BOOL client_cli_gw_authenticate(freerdp* instance, char** username, char** password,
|
||||
char** domain);
|
||||
|
||||
FREERDP_API DWORD client_cli_verify_certificate(freerdp* instance, const char* common_name,
|
||||
const char* subject, const char* issuer,
|
||||
const char* fingerprint, BOOL host_mismatch);
|
||||
const char* subject, const char* issuer,
|
||||
const char* fingerprint, BOOL host_mismatch);
|
||||
|
||||
FREERDP_API DWORD client_cli_verify_changed_certificate(freerdp* instance, const char* common_name,
|
||||
const char* subject, const char* issuer,
|
||||
const char* fingerprint,
|
||||
const char* old_subject, const char* old_issuer,
|
||||
const char* old_fingerprint);
|
||||
const char* subject, const char* issuer,
|
||||
const char* fingerprint,
|
||||
const char* old_subject, const char* old_issuer,
|
||||
const char* old_fingerprint);
|
||||
FREERDP_API BOOL client_auto_reconnect(freerdp* instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user