}
static BOOL rdg_establish_data_connection(rdpRdg* rdg, rdpTls* tls,
- const char* method, const char* peerAddress, int timeout)
+ const char* method, const char* peerAddress, int timeout, BOOL* rpcFallback)
{
HttpResponse* response = NULL;
int statusCode;
if (!response)
return FALSE;
+ if (response->StatusCode == HTTP_STATUS_NOT_FOUND)
+ {
+ WLog_INFO(TAG, "RD Gateway does not support HTTP transport.");
+ if (rpcFallback) *rpcFallback = TRUE;
+ http_response_free(response);
+ return FALSE;
+ }
+
if (!rdg_handle_ntlm_challenge(rdg->ntlm, response))
{
http_response_free(response);
return TRUE;
}
-BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
+BOOL rdg_connect(rdpRdg* rdg, int timeout, BOOL* rpcFallback)
{
BOOL status;
int outConnSocket = 0;
assert(rdg != NULL);
status = rdg_establish_data_connection(
- rdg, rdg->tlsOut, "RDG_OUT_DATA", NULL, timeout);
+ rdg, rdg->tlsOut, "RDG_OUT_DATA", NULL, timeout, rpcFallback);
if (status)
{
peerAddress = freerdp_tcp_get_peer_address(outConnSocket);
status = rdg_establish_data_connection(
- rdg, rdg->tlsIn, "RDG_IN_DATA", peerAddress, timeout);
+ rdg, rdg->tlsIn, "RDG_IN_DATA", peerAddress, timeout, NULL);
free(peerAddress);
}
FREERDP_LOCAL rdpRdg* rdg_new(rdpTransport* transport);
FREERDP_LOCAL void rdg_free(rdpRdg* rdg);
-FREERDP_LOCAL BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port,
- int timeout);
+FREERDP_LOCAL BOOL rdg_connect(rdpRdg* rdg, int timeout, BOOL* rpcFallback);
FREERDP_LOCAL DWORD rdg_get_event_handles(rdpRdg* rdg, HANDLE* events,
DWORD count);
rdpSettings* settings = transport->settings;
rdpContext* context = transport->context;
transport->async = settings->AsyncTransport;
+ BOOL rpcFallback = !settings->GatewayHttpTransport;
if (transport->GatewayEnabled)
{
if (!transport->rdg)
return FALSE;
- status = rdg_connect(transport->rdg, hostname, port, timeout);
+ status = rdg_connect(transport->rdg, timeout, &rpcFallback);
if (status)
{
}
}
- if (!status && settings->GatewayRpcTransport)
+ if (!status && settings->GatewayRpcTransport && rpcFallback)
{
transport->tsg = tsg_new(transport);