Try redirection FQDN first, but check if it is resolvable.
@@ -412,18 +412,36 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
}
else
{
- if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS)
+ BOOL useFQDN = FALSE;
+
+ if (settings->RedirectionFlags & LB_TARGET_FQDN)
+ {
+ int status;
+ struct addrinfo hints = { 0 };
+ struct addrinfo* result = NULL;
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ status = getaddrinfo(settings->RedirectionTargetFQDN, NULL, &hints, &result);
+
+ if (status == 0)
{
+ freeaddrinfo(result);
free(settings->ServerHostname);
- settings->ServerHostname = _strdup(settings->TargetNetAddress);
+ settings->ServerHostname = _strdup(settings->RedirectionTargetFQDN);
if (!settings->ServerHostname)
return FALSE;
+
+ useFQDN = TRUE;
}
- else if (settings->RedirectionFlags & LB_TARGET_FQDN)
+ }
+
+ if (!useFQDN)
+ {
+ if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS)
{
free(settings->ServerHostname);
- settings->ServerHostname = _strdup(settings->RedirectionTargetFQDN);
+ settings->ServerHostname = _strdup(settings->TargetNetAddress);
if (!settings->ServerHostname)
return FALSE;
@@ -437,6 +455,7 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
return FALSE;
}
}
+ }
if (settings->RedirectionFlags & LB_USERNAME)
{
