diff --git a/src/Renci.SshNet/ForwardedPortRemote.cs b/src/Renci.SshNet/ForwardedPortRemote.cs index af7fd48a2..0203d2a1d 100644 --- a/src/Renci.SshNet/ForwardedPortRemote.cs +++ b/src/Renci.SshNet/ForwardedPortRemote.cs @@ -43,7 +43,7 @@ public string BoundHost { get { - return BoundHostAddress.ToString(); + return BoundHostAddress?.ToString() ?? string.Empty; } } @@ -86,11 +86,6 @@ public string Host /// is greater than . public ForwardedPortRemote(IPAddress boundHostAddress, uint boundPort, IPAddress hostAddress, uint port) { - if (boundHostAddress is null) - { - throw new ArgumentNullException(nameof(boundHostAddress)); - } - if (hostAddress is null) { throw new ArgumentNullException(nameof(hostAddress)); @@ -116,7 +111,7 @@ public ForwardedPortRemote(IPAddress boundHostAddress, uint boundPort, IPAddress /// /// public ForwardedPortRemote(uint boundPort, string host, uint port) - : this(string.Empty, boundPort, host, port) + : this(boundHost: null, boundPort, host, port) { } @@ -128,7 +123,7 @@ public ForwardedPortRemote(uint boundPort, string host, uint port) /// The host. /// The port. public ForwardedPortRemote(string boundHost, uint boundPort, string host, uint port) - : this(DnsAbstraction.GetHostAddresses(boundHost)[0], + : this(boundHost == null ? null : DnsAbstraction.GetHostAddresses(boundHost)[0], boundPort, DnsAbstraction.GetHostAddresses(host)[0], port)