Skip to content

Commit 092b486

Browse files
committed
Allow to omit boundHost parameter
1 parent 2eec748 commit 092b486

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/Renci.SshNet/ForwardedPortRemote.cs

+3-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public string BoundHost
4343
{
4444
get
4545
{
46-
return BoundHostAddress.ToString();
46+
return BoundHostAddress?.ToString() ?? string.Empty;
4747
}
4848
}
4949

@@ -86,11 +86,6 @@ public string Host
8686
/// <exception cref="ArgumentOutOfRangeException"><paramref name="port" /> is greater than <see cref="IPEndPoint.MaxPort" />.</exception>
8787
public ForwardedPortRemote(IPAddress boundHostAddress, uint boundPort, IPAddress hostAddress, uint port)
8888
{
89-
if (boundHostAddress is null)
90-
{
91-
throw new ArgumentNullException(nameof(boundHostAddress));
92-
}
93-
9489
if (hostAddress is null)
9590
{
9691
throw new ArgumentNullException(nameof(hostAddress));
@@ -116,7 +111,7 @@ public ForwardedPortRemote(IPAddress boundHostAddress, uint boundPort, IPAddress
116111
/// <code source="..\..\src\Renci.SshNet.Tests\Classes\ForwardedPortRemoteTest.cs" region="Example SshClient AddForwardedPort Start Stop ForwardedPortRemote" language="C#" title="Remote port forwarding" />
117112
/// </example>
118113
public ForwardedPortRemote(uint boundPort, string host, uint port)
119-
: this(string.Empty, boundPort, host, port)
114+
: this(boundHost: null, boundPort, host, port)
120115
{
121116
}
122117

@@ -128,7 +123,7 @@ public ForwardedPortRemote(uint boundPort, string host, uint port)
128123
/// <param name="host">The host.</param>
129124
/// <param name="port">The port.</param>
130125
public ForwardedPortRemote(string boundHost, uint boundPort, string host, uint port)
131-
: this(DnsAbstraction.GetHostAddresses(boundHost)[0],
126+
: this(boundHost == null ? null : DnsAbstraction.GetHostAddresses(boundHost)[0],
132127
boundPort,
133128
DnsAbstraction.GetHostAddresses(host)[0],
134129
port)

0 commit comments

Comments
 (0)