This is an automated email from the ASF dual-hosted git repository. jensg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push: new 22c412e THRIFT-4817 Add string CTOR to TTlsSocketTransport Client: netstd Patch: Jens Geyer 22c412e is described below commit 22c412e42d00d84c687725475f7f935953938e5f Author: Jens Geyer <je...@apache.org> AuthorDate: Tue Mar 12 01:06:25 2019 +0100 THRIFT-4817 Add string CTOR to TTlsSocketTransport Client: netstd Patch: Jens Geyer This closes #1753 --- .../Thrift/Transport/Client/TTlsSocketTransport.cs | 30 ++++++++++++++++++++++ test/netstd/Client/TestClient.cs | 4 +-- 2 files changed, 32 insertions(+), 2 deletions(-) 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 @@ namespace Thrift.Transport.Client 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 @@ namespace ThriftTest 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 @@ namespace ThriftTest 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; }