From 092b4869212495edf1e1268c7adf5ce1cfa0b8cc Mon Sep 17 00:00:00 2001 From: Alexander Salamatov Date: Fri, 3 Nov 2023 21:45:04 +0300 Subject: [PATCH] Allow to omit boundHost parameter --- src/Renci.SshNet/ForwardedPortRemote.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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)