Преглед на файлове

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
timyhac преди 9 месеца
родител
ревизия
9c454ba978
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  1. 4 1
      src/Renci.SshNet/ForwardedPortDynamic.cs

+ 4 - 1
src/Renci.SshNet/ForwardedPortDynamic.cs

@@ -40,7 +40,7 @@ namespace Renci.SshNet
         /// <summary>
         /// Gets the bound port.
         /// </summary>
-        public uint BoundPort { get; }
+        public uint BoundPort { get; private set; }
 
         private Socket _listener;
         private CountdownEvent _pendingChannelCountdown;
@@ -168,6 +168,9 @@ namespace Renci.SshNet
             _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;