Skip to content

Commit

Permalink
Allow to omit boundHost parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1seL committed Nov 15, 2023
1 parent 2eec748 commit 092b486
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/Renci.SshNet/ForwardedPortRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public string BoundHost
{
get
{
return BoundHostAddress.ToString();
return BoundHostAddress?.ToString() ?? string.Empty;
}
}

Expand Down Expand Up @@ -86,11 +86,6 @@ public string Host
/// <exception cref="ArgumentOutOfRangeException"><paramref name="port" /> is greater than <see cref="IPEndPoint.MaxPort" />.</exception>
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));
Expand All @@ -116,7 +111,7 @@ public ForwardedPortRemote(IPAddress boundHostAddress, uint boundPort, IPAddress
/// <code source="..\..\src\Renci.SshNet.Tests\Classes\ForwardedPortRemoteTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortRemote" language="C#" title="Remote port forwarding" />
/// </example>
public ForwardedPortRemote(uint boundPort, string host, uint port)
: this(string.Empty, boundPort, host, port)
: this(boundHost: null, boundPort, host, port)
{
}

Expand All @@ -128,7 +123,7 @@ public ForwardedPortRemote(uint boundPort, string host, uint port)
/// <param name="host">The host.</param>
/// <param name="port">The port.</param>
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)
Expand Down

0 comments on commit 092b486

Please sign in to comment.