libfreerdp-core: remove TlsIn/TlsOut from rdpTransport
This commit is contained in:
parent
0d85dfd395
commit
889ccefe0d
@ -506,6 +506,18 @@ void rpc_in_channel_free(RpcInChannel* inChannel)
|
|||||||
|
|
||||||
rpc_in_channel_rpch_uninit(inChannel);
|
rpc_in_channel_rpch_uninit(inChannel);
|
||||||
|
|
||||||
|
if (inChannel->tls)
|
||||||
|
{
|
||||||
|
tls_free(inChannel->tls);
|
||||||
|
inChannel->tls = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inChannel->tcp)
|
||||||
|
{
|
||||||
|
freerdp_tcp_free(inChannel->tcp);
|
||||||
|
inChannel->tcp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
free(inChannel);
|
free(inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,6 +657,18 @@ void rpc_out_channel_free(RpcOutChannel* outChannel)
|
|||||||
|
|
||||||
rpc_out_channel_rpch_uninit(outChannel);
|
rpc_out_channel_rpch_uninit(outChannel);
|
||||||
|
|
||||||
|
if (outChannel->tls)
|
||||||
|
{
|
||||||
|
tls_free(outChannel->tls);
|
||||||
|
outChannel->tls = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outChannel->tcp)
|
||||||
|
{
|
||||||
|
freerdp_tcp_free(outChannel->tcp);
|
||||||
|
outChannel->tcp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
free(outChannel);
|
free(outChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1485,9 +1485,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port, int timeout)
|
|||||||
|
|
||||||
transport->frontBio = tsg->bio;
|
transport->frontBio = tsg->bio;
|
||||||
transport->TcpIn = inChannel->tcp;
|
transport->TcpIn = inChannel->tcp;
|
||||||
transport->TlsIn = inChannel->tls;
|
|
||||||
transport->TcpOut = outChannel->tcp;
|
transport->TcpOut = outChannel->tcp;
|
||||||
transport->TlsOut = outChannel->tls;
|
|
||||||
transport->GatewayEvent = rpc->client->PipeEvent;
|
transport->GatewayEvent = rpc->client->PipeEvent;
|
||||||
transport->SplitInputOutput = TRUE;
|
transport->SplitInputOutput = TRUE;
|
||||||
transport->layer = TRANSPORT_LAYER_TSG;
|
transport->layer = TRANSPORT_LAYER_TSG;
|
||||||
@ -1636,8 +1634,6 @@ void tsg_free(rdpTsg* tsg)
|
|||||||
{
|
{
|
||||||
if (tsg)
|
if (tsg)
|
||||||
{
|
{
|
||||||
rdpTransport* transport = tsg->transport;
|
|
||||||
|
|
||||||
if (tsg->bio)
|
if (tsg->bio)
|
||||||
{
|
{
|
||||||
BIO_free(tsg->bio);
|
BIO_free(tsg->bio);
|
||||||
@ -1653,18 +1649,6 @@ void tsg_free(rdpTsg* tsg)
|
|||||||
free(tsg->Hostname);
|
free(tsg->Hostname);
|
||||||
free(tsg->MachineName);
|
free(tsg->MachineName);
|
||||||
|
|
||||||
if (transport->TlsIn)
|
|
||||||
tls_free(transport->TlsIn);
|
|
||||||
|
|
||||||
if (transport->TcpIn)
|
|
||||||
freerdp_tcp_free(transport->TcpIn);
|
|
||||||
|
|
||||||
if (transport->TlsOut)
|
|
||||||
tls_free(transport->TlsOut);
|
|
||||||
|
|
||||||
if (transport->TcpOut)
|
|
||||||
freerdp_tcp_free(transport->TcpOut);
|
|
||||||
|
|
||||||
free(tsg);
|
free(tsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,11 +220,11 @@ int credssp_ntlm_client_init(rdpCredssp* credssp)
|
|||||||
|
|
||||||
int credssp_ntlm_server_init(rdpCredssp* credssp)
|
int credssp_ntlm_server_init(rdpCredssp* credssp)
|
||||||
{
|
{
|
||||||
freerdp* instance;
|
rdpTls* tls = credssp->transport->tls;
|
||||||
rdpSettings* settings = credssp->settings;
|
|
||||||
instance = (freerdp*) settings->instance;
|
sspi_SecBufferAlloc(&credssp->PublicKey, tls->PublicKeyLength);
|
||||||
sspi_SecBufferAlloc(&credssp->PublicKey, credssp->transport->TlsIn->PublicKeyLength);
|
CopyMemory(credssp->PublicKey.pvBuffer, tls->PublicKey, tls->PublicKeyLength);
|
||||||
CopyMemory(credssp->PublicKey.pvBuffer, credssp->transport->TlsIn->PublicKey, credssp->transport->TlsIn->PublicKeyLength);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,62 +74,6 @@ void transport_attach(rdpTransport* transport, int sockfd)
|
|||||||
transport->frontBio = transport->TcpIn->bufferedBio;
|
transport->frontBio = transport->TcpIn->bufferedBio;
|
||||||
}
|
}
|
||||||
|
|
||||||
void transport_stop(rdpTransport* transport)
|
|
||||||
{
|
|
||||||
if (transport->async)
|
|
||||||
{
|
|
||||||
if (transport->stopEvent)
|
|
||||||
{
|
|
||||||
SetEvent(transport->stopEvent);
|
|
||||||
WaitForSingleObject(transport->thread, INFINITE);
|
|
||||||
CloseHandle(transport->thread);
|
|
||||||
CloseHandle(transport->stopEvent);
|
|
||||||
transport->thread = NULL;
|
|
||||||
transport->stopEvent = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL transport_disconnect(rdpTransport* transport)
|
|
||||||
{
|
|
||||||
BOOL status = TRUE;
|
|
||||||
|
|
||||||
if (!transport)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
transport_stop(transport);
|
|
||||||
|
|
||||||
if (transport->tsg)
|
|
||||||
{
|
|
||||||
if (transport->TsgTls)
|
|
||||||
{
|
|
||||||
tls_free(transport->TsgTls);
|
|
||||||
transport->TsgTls = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tsg_free(transport->tsg);
|
|
||||||
transport->tsg = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (transport->TlsIn)
|
|
||||||
tls_free(transport->TlsIn);
|
|
||||||
|
|
||||||
if (transport->TcpIn)
|
|
||||||
freerdp_tcp_free(transport->TcpIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
transport->TlsIn = NULL;
|
|
||||||
transport->TlsOut = NULL;
|
|
||||||
|
|
||||||
transport->TcpIn = NULL;
|
|
||||||
transport->TcpOut = NULL;
|
|
||||||
|
|
||||||
transport->layer = TRANSPORT_LAYER_TCP;
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL transport_connect_rdp(rdpTransport* transport)
|
BOOL transport_connect_rdp(rdpTransport* transport)
|
||||||
{
|
{
|
||||||
/* RDP encryption */
|
/* RDP encryption */
|
||||||
@ -138,41 +82,39 @@ BOOL transport_connect_rdp(rdpTransport* transport)
|
|||||||
|
|
||||||
BOOL transport_connect_tls(rdpTransport* transport)
|
BOOL transport_connect_tls(rdpTransport* transport)
|
||||||
{
|
{
|
||||||
int tls_status;
|
int tlsStatus;
|
||||||
BIO* targetBio = NULL;
|
BIO* bio = NULL;
|
||||||
rdpTls* targetTls = NULL;
|
rdpTls* tls = NULL;
|
||||||
rdpContext* context = transport->context;
|
rdpContext* context = transport->context;
|
||||||
rdpSettings* settings = transport->settings;
|
rdpSettings* settings = transport->settings;
|
||||||
|
|
||||||
if (transport->GatewayEnabled)
|
if (transport->GatewayEnabled)
|
||||||
{
|
{
|
||||||
transport->TsgTls = tls_new(transport->settings);
|
tls = transport->tls = tls_new(transport->settings);
|
||||||
transport->layer = TRANSPORT_LAYER_TSG_TLS;
|
transport->layer = TRANSPORT_LAYER_TSG_TLS;
|
||||||
targetTls = transport->TsgTls;
|
bio = transport->frontBio;
|
||||||
targetBio = transport->frontBio;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
transport->TlsIn = tls_new(settings);
|
transport->tls = tls_new(settings);
|
||||||
targetTls = transport->TlsIn;
|
|
||||||
targetBio = transport->TcpIn->bufferedBio;
|
|
||||||
transport->layer = TRANSPORT_LAYER_TLS;
|
transport->layer = TRANSPORT_LAYER_TLS;
|
||||||
|
bio = transport->TcpIn->bufferedBio;
|
||||||
}
|
}
|
||||||
|
|
||||||
transport->tls = targetTls;
|
transport->tls = tls;
|
||||||
|
|
||||||
targetTls->hostname = settings->ServerHostname;
|
tls->hostname = settings->ServerHostname;
|
||||||
targetTls->port = settings->ServerPort;
|
tls->port = settings->ServerPort;
|
||||||
|
|
||||||
if (targetTls->port == 0)
|
if (tls->port == 0)
|
||||||
targetTls->port = 3389;
|
tls->port = 3389;
|
||||||
|
|
||||||
targetTls->isGatewayTransport = FALSE;
|
tls->isGatewayTransport = FALSE;
|
||||||
tls_status = tls_connect(targetTls, targetBio);
|
tlsStatus = tls_connect(tls, bio);
|
||||||
|
|
||||||
if (tls_status < 1)
|
if (tlsStatus < 1)
|
||||||
{
|
{
|
||||||
if (tls_status < 0)
|
if (tlsStatus < 0)
|
||||||
{
|
{
|
||||||
if (!connectErrorCode)
|
if (!connectErrorCode)
|
||||||
connectErrorCode = TLSCONNECTERROR;
|
connectErrorCode = TLSCONNECTERROR;
|
||||||
@ -189,7 +131,7 @@ BOOL transport_connect_tls(rdpTransport* transport)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
transport->frontBio = targetTls->bio;
|
transport->frontBio = tls->bio;
|
||||||
|
|
||||||
if (!transport->frontBio)
|
if (!transport->frontBio)
|
||||||
{
|
{
|
||||||
@ -324,15 +266,16 @@ BOOL transport_accept_tls(rdpTransport* transport)
|
|||||||
{
|
{
|
||||||
rdpSettings* settings = transport->settings;
|
rdpSettings* settings = transport->settings;
|
||||||
|
|
||||||
if (!transport->TlsIn)
|
if (!transport->tls)
|
||||||
transport->TlsIn = tls_new(transport->settings);
|
transport->tls = tls_new(transport->settings);
|
||||||
|
|
||||||
transport->layer = TRANSPORT_LAYER_TLS;
|
transport->layer = TRANSPORT_LAYER_TLS;
|
||||||
|
|
||||||
if (!tls_accept(transport->TlsIn, transport->TcpIn->bufferedBio, settings->CertificateFile, settings->PrivateKeyFile))
|
if (!tls_accept(transport->tls, transport->TcpIn->bufferedBio, settings->CertificateFile, settings->PrivateKeyFile))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
transport->frontBio = transport->TlsIn->bio;
|
transport->frontBio = transport->tls->bio;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,15 +284,15 @@ BOOL transport_accept_nla(rdpTransport* transport)
|
|||||||
rdpSettings* settings = transport->settings;
|
rdpSettings* settings = transport->settings;
|
||||||
freerdp* instance = (freerdp*) settings->instance;
|
freerdp* instance = (freerdp*) settings->instance;
|
||||||
|
|
||||||
if (!transport->TlsIn)
|
if (!transport->tls)
|
||||||
transport->TlsIn = tls_new(transport->settings);
|
transport->tls = tls_new(transport->settings);
|
||||||
|
|
||||||
transport->layer = TRANSPORT_LAYER_TLS;
|
transport->layer = TRANSPORT_LAYER_TLS;
|
||||||
|
|
||||||
if (!tls_accept(transport->TlsIn, transport->TcpIn->bufferedBio, settings->CertificateFile, settings->PrivateKeyFile))
|
if (!tls_accept(transport->tls, transport->TcpIn->bufferedBio, settings->CertificateFile, settings->PrivateKeyFile))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
transport->frontBio = transport->TlsIn->bio;
|
transport->frontBio = transport->tls->bio;
|
||||||
|
|
||||||
/* Network Level Authentication */
|
/* Network Level Authentication */
|
||||||
|
|
||||||
@ -368,7 +311,7 @@ BOOL transport_accept_nla(rdpTransport* transport)
|
|||||||
transport_set_nla_mode(transport, FALSE);
|
transport_set_nla_mode(transport, FALSE);
|
||||||
credssp_free(transport->credssp);
|
credssp_free(transport->credssp);
|
||||||
transport->credssp = NULL;
|
transport->credssp = NULL;
|
||||||
tls_set_alert_code(transport->TlsIn, TLS_ALERT_LEVEL_FATAL, TLS_ALERT_DESCRIPTION_ACCESS_DENIED);
|
tls_set_alert_code(transport->tls, TLS_ALERT_LEVEL_FATAL, TLS_ALERT_DESCRIPTION_ACCESS_DENIED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -898,6 +841,59 @@ void transport_set_nla_mode(rdpTransport* transport, BOOL NlaMode)
|
|||||||
transport->NlaMode = NlaMode;
|
transport->NlaMode = NlaMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void transport_stop(rdpTransport* transport)
|
||||||
|
{
|
||||||
|
if (transport->async)
|
||||||
|
{
|
||||||
|
if (transport->stopEvent)
|
||||||
|
{
|
||||||
|
SetEvent(transport->stopEvent);
|
||||||
|
WaitForSingleObject(transport->thread, INFINITE);
|
||||||
|
CloseHandle(transport->thread);
|
||||||
|
CloseHandle(transport->stopEvent);
|
||||||
|
transport->thread = NULL;
|
||||||
|
transport->stopEvent = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL transport_disconnect(rdpTransport* transport)
|
||||||
|
{
|
||||||
|
BOOL status = TRUE;
|
||||||
|
|
||||||
|
if (!transport)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
transport_stop(transport);
|
||||||
|
|
||||||
|
if (transport->tsg)
|
||||||
|
{
|
||||||
|
if (transport->tls)
|
||||||
|
{
|
||||||
|
tls_free(transport->tls);
|
||||||
|
transport->tls = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsg_free(transport->tsg);
|
||||||
|
transport->tsg = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (transport->tls)
|
||||||
|
tls_free(transport->tls);
|
||||||
|
|
||||||
|
if (transport->TcpIn)
|
||||||
|
freerdp_tcp_free(transport->TcpIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
transport->TcpIn = NULL;
|
||||||
|
transport->TcpOut = NULL;
|
||||||
|
|
||||||
|
transport->layer = TRANSPORT_LAYER_TCP;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
static void* transport_client_thread(void* arg)
|
static void* transport_client_thread(void* arg)
|
||||||
{
|
{
|
||||||
DWORD status;
|
DWORD status;
|
||||||
|
@ -60,9 +60,6 @@ struct rdp_transport
|
|||||||
rdpTls* tls;
|
rdpTls* tls;
|
||||||
rdpTcp* TcpIn;
|
rdpTcp* TcpIn;
|
||||||
rdpTcp* TcpOut;
|
rdpTcp* TcpOut;
|
||||||
rdpTls* TlsIn;
|
|
||||||
rdpTls* TlsOut;
|
|
||||||
rdpTls* TsgTls;
|
|
||||||
rdpContext* context;
|
rdpContext* context;
|
||||||
rdpCredssp* credssp;
|
rdpCredssp* credssp;
|
||||||
rdpSettings* settings;
|
rdpSettings* settings;
|
||||||
|
Loading…
Reference in New Issue
Block a user