Skip to content

Commit

Permalink
Update bound port on ForwardedPortDynamic after connection (in case o…
Browse files Browse the repository at this point in the history
…riginal was passed as zero) (#1577)

* update bound port (in case original was passed as zero)

* Needed to allow private set for BoundPort
  • Loading branch information
timyhac authored Jan 20, 2025
1 parent 5c29394 commit 9c454ba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Renci.SshNet/ForwardedPortDynamic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ForwardedPortDynamic : ForwardedPort
/// <summary>
/// Gets the bound port.
/// </summary>
public uint BoundPort { get; }
public uint BoundPort { get; private set; }

private Socket _listener;
private CountdownEvent _pendingChannelCountdown;
Expand Down Expand Up @@ -168,6 +168,9 @@ private void InternalStart()
_listener.Bind(ep);
_listener.Listen(5);

// update bound port (in case original was passed as zero)
BoundPort = (uint)((IPEndPoint)_listener.LocalEndPoint).Port;

Session.ErrorOccured += Session_ErrorOccured;
Session.Disconnected += Session_Disconnected;

Expand Down

0 comments on commit 9c454ba

Please sign in to comment.