Skip to content

Commit 9c454ba

Browse files
authored
Update bound port on ForwardedPortDynamic after connection (in case original was passed as zero) (#1577)
* update bound port (in case original was passed as zero) * Needed to allow private set for BoundPort
1 parent 5c29394 commit 9c454ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Renci.SshNet/ForwardedPortDynamic.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ForwardedPortDynamic : ForwardedPort
4040
/// <summary>
4141
/// Gets the bound port.
4242
/// </summary>
43-
public uint BoundPort { get; }
43+
public uint BoundPort { get; private set; }
4444

4545
private Socket _listener;
4646
private CountdownEvent _pendingChannelCountdown;
@@ -168,6 +168,9 @@ private void InternalStart()
168168
_listener.Bind(ep);
169169
_listener.Listen(5);
170170

171+
// update bound port (in case original was passed as zero)
172+
BoundPort = (uint)((IPEndPoint)_listener.LocalEndPoint).Port;
173+
171174
Session.ErrorOccured += Session_ErrorOccured;
172175
Session.Disconnected += Session_Disconnected;
173176

0 commit comments

Comments
 (0)