[core,gateway] migrate rpc gateway to use new transport layer.

This commit is contained in:
Vic Lee 2024-09-18 15:39:34 +08:00
parent b738cf01b9
commit 5f37b54847
1 changed files with 23 additions and 30 deletions

View File

@ -707,49 +707,42 @@ fail:
static BOOL rpc_channel_tls_connect(RpcChannel* channel, UINT32 timeout)
{
int sockfd = 0;
rdpTls* tls = NULL;
int tlsStatus = 0;
BIO* socketBio = NULL;
BIO* bufferedBio = NULL;
rdpContext* context = NULL;
rdpSettings* settings = NULL;
const char* proxyUsername = NULL;
const char* proxyPassword = NULL;
if (!channel || !channel->client || !channel->client->context ||
!channel->client->context->settings)
return FALSE;
context = channel->client->context;
settings = context->settings;
proxyUsername = freerdp_settings_get_string(settings, FreeRDP_ProxyUsername);
proxyPassword = freerdp_settings_get_string(settings, FreeRDP_ProxyPassword);
{
sockfd =
freerdp_tcp_connect(context, channel->client->host, channel->client->port, timeout);
rdpContext* context = channel->client->context;
WINPR_ASSERT(context);
if (sockfd < 0)
return FALSE;
}
socketBio = BIO_new(BIO_s_simple_socket());
rdpSettings* settings = context->settings;
WINPR_ASSERT(settings);
if (!socketBio)
const char* proxyUsername = freerdp_settings_get_string(settings, FreeRDP_ProxyUsername);
const char* proxyPassword = freerdp_settings_get_string(settings, FreeRDP_ProxyPassword);
rdpTransport* transport = freerdp_get_transport(context);
rdpTransportLayer* layer =
transport_connect_layer(transport, channel->client->host, channel->client->port, timeout);
if (!layer)
return FALSE;
BIO* layerBio = BIO_new(BIO_s_transport_layer());
if (!layerBio)
{
closesocket(sockfd);
transport_layer_free(layer);
return FALSE;
}
BIO_set_data(layerBio, layer);
BIO_set_fd(socketBio, sockfd, BIO_CLOSE);
bufferedBio = BIO_new(BIO_s_buffered_socket());
BIO* bufferedBio = BIO_new(BIO_s_buffered_socket());
if (!bufferedBio)
{
BIO_free_all(socketBio);
BIO_free_all(layerBio);
return FALSE;
}
bufferedBio = BIO_push(bufferedBio, socketBio);
bufferedBio = BIO_push(bufferedBio, layerBio);
if (!BIO_set_nonblock(bufferedBio, TRUE))
{
@ -768,7 +761,7 @@ static BOOL rpc_channel_tls_connect(RpcChannel* channel, UINT32 timeout)
}
channel->bio = bufferedBio;
tls = channel->tls = freerdp_tls_new(context);
rdpTls* tls = channel->tls = freerdp_tls_new(context);
if (!tls)
return FALSE;
@ -776,7 +769,7 @@ static BOOL rpc_channel_tls_connect(RpcChannel* channel, UINT32 timeout)
tls->hostname = settings->GatewayHostname;
tls->port = settings->GatewayPort;
tls->isGatewayTransport = TRUE;
tlsStatus = freerdp_tls_connect(tls, bufferedBio);
int tlsStatus = freerdp_tls_connect(tls, bufferedBio);
if (tlsStatus < 1)
{