Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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