freerdp: fix remote assistance mode, add multi-address connection
This commit is contained in:
parent
8ee097a8dd
commit
6b1fefea40
@ -51,6 +51,7 @@ rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
||||
pEntryPoints->GlobalInit();
|
||||
|
||||
instance = freerdp_new();
|
||||
|
||||
if (!instance)
|
||||
return NULL;
|
||||
|
||||
@ -59,11 +60,12 @@ rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
||||
instance->ContextNew = freerdp_client_common_new;
|
||||
instance->ContextFree = freerdp_client_common_free;
|
||||
instance->pClientEntryPoints = (RDP_CLIENT_ENTRY_POINTS*) malloc(pEntryPoints->Size);
|
||||
|
||||
if (!instance->pClientEntryPoints)
|
||||
goto out_fail;
|
||||
|
||||
|
||||
CopyMemory(instance->pClientEntryPoints, pEntryPoints, pEntryPoints->Size);
|
||||
|
||||
if (!freerdp_context_new(instance))
|
||||
goto out_fail2;
|
||||
|
||||
@ -202,7 +204,7 @@ int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc,
|
||||
|
||||
/* This function will call logic that is applicable to the settings
|
||||
* from command line parsing AND the rdp file parsing */
|
||||
if(!freerdp_client_settings_post_process(settings))
|
||||
if (!freerdp_client_settings_post_process(settings))
|
||||
status = -1;
|
||||
|
||||
return status;
|
||||
|
@ -932,33 +932,39 @@ int freerdp_map_keyboard_layout_name_to_id(char* name)
|
||||
RDP_KEYBOARD_LAYOUT* layouts;
|
||||
|
||||
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
|
||||
|
||||
for (i = 0; layouts[i].code; i++)
|
||||
{
|
||||
if (_stricmp(layouts[i].name, name) == 0)
|
||||
id = layouts[i].code;
|
||||
}
|
||||
|
||||
free(layouts);
|
||||
|
||||
if (id)
|
||||
return id;
|
||||
|
||||
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
|
||||
|
||||
for (i = 0; layouts[i].code; i++)
|
||||
{
|
||||
if (_stricmp(layouts[i].name, name) == 0)
|
||||
id = layouts[i].code;
|
||||
}
|
||||
|
||||
free(layouts);
|
||||
|
||||
if (id)
|
||||
return id;
|
||||
|
||||
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME);
|
||||
|
||||
for (i = 0; layouts[i].code; i++)
|
||||
{
|
||||
if (_stricmp(layouts[i].name, name) == 0)
|
||||
id = layouts[i].code;
|
||||
}
|
||||
|
||||
free(layouts);
|
||||
|
||||
if (id)
|
||||
@ -982,6 +988,14 @@ int freerdp_detect_command_line_pre_filter(void* context, int index, int argc, L
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (length > 13)
|
||||
{
|
||||
if (_stricmp(&(argv[index])[length - 13], ".msrcIncident") == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -997,6 +1011,7 @@ int freerdp_detect_windows_style_command_line_syntax(int argc, char** argv,
|
||||
|
||||
flags = COMMAND_LINE_SEPARATOR_COLON;
|
||||
flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
|
||||
|
||||
if (ignoreUnknown)
|
||||
{
|
||||
flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
|
||||
@ -1040,6 +1055,7 @@ int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv,
|
||||
flags = COMMAND_LINE_SEPARATOR_SPACE;
|
||||
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
||||
flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
|
||||
|
||||
if (ignoreUnknown)
|
||||
{
|
||||
flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
|
||||
|
@ -47,6 +47,11 @@ struct rdp_assistance_file
|
||||
|
||||
char* MachineAddress;
|
||||
UINT32 MachinePort;
|
||||
|
||||
UINT32 MachineCount;
|
||||
char** MachineAddresses;
|
||||
UINT32* MachinePorts;
|
||||
|
||||
char* RASessionId;
|
||||
char* RASpecificParams;
|
||||
};
|
||||
|
@ -1032,7 +1032,8 @@ struct rdp_settings
|
||||
ALIGN64 UINT32 RedirectionTsvUrlLength; /* 1227 */
|
||||
ALIGN64 UINT32 TargetNetAddressCount; /* 1228 */
|
||||
ALIGN64 char** TargetNetAddresses; /* 1229 */
|
||||
UINT64 padding1280[1280 - 1230]; /* 1230 */
|
||||
ALIGN64 UINT32* TargetNetPorts; /* 1230 */
|
||||
UINT64 padding1280[1280 - 1231]; /* 1231 */
|
||||
|
||||
/**
|
||||
* Security
|
||||
|
@ -153,6 +153,36 @@ int freerdp_assistance_parse_address_list(rdpAssistanceFile* file, char* list)
|
||||
}
|
||||
}
|
||||
|
||||
file->MachineCount = count;
|
||||
file->MachineAddresses = (char**) calloc(count, sizeof(char*));
|
||||
file->MachinePorts = (UINT32*) calloc(count, sizeof(UINT32));
|
||||
|
||||
if (!file->MachineAddresses || !file->MachinePorts)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
length = strlen(tokens[i]);
|
||||
|
||||
p = tokens[i];
|
||||
|
||||
q = strchr(p, ':');
|
||||
|
||||
if (!q)
|
||||
{
|
||||
free(tokens);
|
||||
return -1;
|
||||
}
|
||||
|
||||
q[0] = '\0';
|
||||
q++;
|
||||
|
||||
file->MachineAddresses[i] = _strdup(p);
|
||||
file->MachinePorts[i] = (UINT32) atoi(q);
|
||||
|
||||
q[-1] = ':';
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
length = strlen(tokens[i]);
|
||||
@ -181,8 +211,10 @@ int freerdp_assistance_parse_address_list(rdpAssistanceFile* file, char* list)
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (tokens)
|
||||
free(tokens);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1056,6 +1088,10 @@ int freerdp_assistance_parse_file(rdpAssistanceFile* file, const char* name)
|
||||
}
|
||||
|
||||
buffer = (BYTE*) malloc(fileSize + 2);
|
||||
|
||||
if (!buffer)
|
||||
return -1;
|
||||
|
||||
readSize = fread(buffer, fileSize, 1, fp);
|
||||
|
||||
if (!readSize)
|
||||
@ -1084,6 +1120,8 @@ int freerdp_assistance_parse_file(rdpAssistanceFile* file, const char* name)
|
||||
|
||||
int freerdp_client_populate_settings_from_assistance_file(rdpAssistanceFile* file, rdpSettings* settings)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
freerdp_set_param_bool(settings, FreeRDP_RemoteAssistanceMode, TRUE);
|
||||
|
||||
if (!file->RASessionId)
|
||||
@ -1103,6 +1141,21 @@ int freerdp_client_populate_settings_from_assistance_file(rdpAssistanceFile* fil
|
||||
freerdp_set_param_string(settings, FreeRDP_ServerHostname, file->MachineAddress);
|
||||
freerdp_set_param_uint32(settings, FreeRDP_ServerPort, file->MachinePort);
|
||||
|
||||
freerdp_target_net_addresses_free(settings);
|
||||
|
||||
settings->TargetNetAddressCount = file->MachineCount;
|
||||
settings->TargetNetAddresses = (char**) calloc(file->MachineCount, sizeof(char*));
|
||||
settings->TargetNetPorts = (UINT32*) calloc(file->MachineCount, sizeof(UINT32));
|
||||
|
||||
for (i = 0; i < settings->TargetNetAddressCount; i++)
|
||||
{
|
||||
settings->TargetNetAddresses[i] = _strdup(file->MachineAddresses[i]);
|
||||
settings->TargetNetPorts[i] = file->MachinePorts[i];
|
||||
|
||||
fprintf(stderr, "count: %d index: %d address: %s port: %d\n",
|
||||
settings->TargetNetAddressCount, i, settings->TargetNetAddresses[i], settings->TargetNetPorts[i]);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1122,6 +1175,8 @@ rdpAssistanceFile* freerdp_assistance_file_new()
|
||||
|
||||
void freerdp_assistance_file_free(rdpAssistanceFile* file)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
if (!file)
|
||||
return;
|
||||
|
||||
@ -1137,5 +1192,13 @@ void freerdp_assistance_file_free(rdpAssistanceFile* file)
|
||||
free(file->MachineAddress);
|
||||
free(file->EncryptedPassStub);
|
||||
|
||||
for (i = 0; i < file->MachineCount; i++)
|
||||
{
|
||||
free(file->MachineAddresses[i]);
|
||||
}
|
||||
|
||||
free(file->MachineAddresses);
|
||||
free(file->MachinePorts);
|
||||
|
||||
free(file);
|
||||
}
|
||||
|
@ -610,9 +610,11 @@ void freerdp_target_net_addresses_free(rdpSettings* settings)
|
||||
free(settings->TargetNetAddresses[index]);
|
||||
|
||||
free(settings->TargetNetAddresses);
|
||||
free(settings->TargetNetPorts);
|
||||
|
||||
settings->TargetNetAddressCount = 0;
|
||||
settings->TargetNetAddresses = NULL;
|
||||
settings->TargetNetPorts = NULL;
|
||||
}
|
||||
|
||||
void freerdp_performance_flags_make(rdpSettings* settings)
|
||||
|
@ -590,6 +590,7 @@ rdpSettings* freerdp_settings_clone(rdpSettings* settings)
|
||||
_settings->RedirectionTsvUrlLength = 0;
|
||||
_settings->TargetNetAddressCount = 0;
|
||||
_settings->TargetNetAddresses = NULL;
|
||||
_settings->TargetNetPorts = NULL;
|
||||
|
||||
if (settings->LoadBalanceInfo && settings->LoadBalanceInfoLength)
|
||||
{
|
||||
@ -664,6 +665,14 @@ rdpSettings* freerdp_settings_clone(rdpSettings* settings)
|
||||
|
||||
for (index = 0; index < settings->TargetNetAddressCount; index++)
|
||||
_settings->TargetNetAddresses[index] = _strdup(settings->TargetNetAddresses[index]);
|
||||
|
||||
if (settings->TargetNetPorts)
|
||||
{
|
||||
_settings->TargetNetPorts = (UINT32*) malloc(sizeof(UINT32) * settings->TargetNetAddressCount);
|
||||
|
||||
for (index = 0; index < settings->TargetNetAddressCount; index++)
|
||||
_settings->TargetNetPorts[index] = settings->TargetNetPorts[index];
|
||||
}
|
||||
}
|
||||
|
||||
_settings->DeviceCount = settings->DeviceCount;
|
||||
|
@ -816,7 +816,7 @@ BOOL freerdp_tcp_connect_timeout(int sockfd, struct sockaddr* addr, socklen_t ad
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
int freerdp_tcp_connect_multi(char** hostnames, int count, int port, int timeout)
|
||||
int freerdp_tcp_connect_multi(char** hostnames, UINT32* ports, int count, int port, int timeout)
|
||||
{
|
||||
int index;
|
||||
int sindex;
|
||||
@ -849,6 +849,9 @@ int freerdp_tcp_connect_multi(char** hostnames, int count, int port, int timeout
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
if (ports)
|
||||
sprintf_s(port_str, sizeof(port_str) - 1, "%u", ports[index]);
|
||||
|
||||
status = getaddrinfo(hostnames[index], port_str, &hints, &result);
|
||||
|
||||
if (status)
|
||||
@ -1088,13 +1091,13 @@ int freerdp_tcp_connect(rdpSettings* settings, const char* hostname, int port, i
|
||||
|
||||
if (!settings->GatewayEnabled)
|
||||
{
|
||||
if (!freerdp_tcp_resolve_hostname(hostname))
|
||||
if (!freerdp_tcp_resolve_hostname(hostname) || settings->RemoteAssistanceMode)
|
||||
{
|
||||
if (settings->TargetNetAddressCount > 0)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
sockfd = freerdp_tcp_connect_multi(settings->TargetNetAddresses,
|
||||
settings->TargetNetAddressCount, port, timeout);
|
||||
settings->TargetNetPorts, settings->TargetNetAddressCount, port, timeout);
|
||||
#else
|
||||
hostname = settings->TargetNetAddresses[0];
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user