THRIFT-4817 Add string CTOR to TTlsSocketTransport
Client: netstd
Patch: Jens Geyer
This closes #1753
diff --git a/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs b/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs
index 3bd9606..98fb982 100644
--- a/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs
+++ b/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs
@@ -109,6 +109,36 @@
InitSocket();
}
+ public TTlsSocketTransport(string host, int port, int timeout,
+ X509Certificate2 certificate,
+ RemoteCertificateValidationCallback certValidator = null,
+ LocalCertificateSelectionCallback localCertificateSelectionCallback = null,
+ SslProtocols sslProtocols = SslProtocols.Tls12)
+ {
+ try
+ {
+ var entry = Dns.GetHostEntry(host);
+ if (entry.AddressList.Length == 0)
+ throw new TTransportException(TTransportException.ExceptionType.Unknown, "unable to resolve host name");
+
+ var addr = entry.AddressList[0];
+
+ _host = new IPAddress(addr.GetAddressBytes(), addr.ScopeId); ;
+ _port = port;
+ _timeout = timeout;
+ _certificate = certificate;
+ _certValidator = certValidator;
+ _localCertificateSelectionCallback = localCertificateSelectionCallback;
+ _sslProtocols = sslProtocols;
+
+ InitSocket();
+ }
+ catch (SocketException e)
+ {
+ throw new TTransportException(TTransportException.ExceptionType.Unknown, e.Message, e);
+ }
+ }
+
public int Timeout
{
set { _client.ReceiveTimeout = _client.SendTimeout = _timeout = value; }
diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs
index f480846..a85312b 100644
--- a/test/netstd/Client/TestClient.cs
+++ b/test/netstd/Client/TestClient.cs
@@ -63,7 +63,7 @@
private class TestParams
{
public int numIterations = 1;
- public IPAddress host = IPAddress.Any;
+ public string host = "localhost";
public int port = 9090;
public int numThreads = 1;
public string url;
@@ -92,7 +92,7 @@
else if (args[i].StartsWith("--host="))
{
// check there for ipaddress
- host = new IPAddress(Encoding.Unicode.GetBytes(args[i].Substring(args[i].IndexOf("=") + 1)));
+ host = args[i].Substring(args[i].IndexOf("=") + 1);
if (transport != TransportChoice.TlsSocket)
transport = TransportChoice.Socket;
}