From 8c5f01a9d994f06692765c2c59303944b0e8af03 Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation Date: Wed, 13 Oct 2021 21:23:00 +0000 Subject: [PATCH 1/2] build: version bump to 0.25 --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index a9b9390fb..bc8aec0c6 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "0.24", + "version": "0.25", "publicReleaseRefSpec": [ ".*" ], From f0fd8d3c7f8454630ac786f564fa6aefffc7dcc3 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Wed, 13 Oct 2021 18:16:18 -0700 Subject: [PATCH 2/2] fix: skip ports that are in use to make sure availability check only checks the unused port --- .../ServerModeSession.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/AWS.Deploy.ServerMode.Client/ServerModeSession.cs b/src/AWS.Deploy.ServerMode.Client/ServerModeSession.cs index e9ce6c337..2c6b60c3b 100644 --- a/src/AWS.Deploy.ServerMode.Client/ServerModeSession.cs +++ b/src/AWS.Deploy.ServerMode.Client/ServerModeSession.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using System.Net.Http; +using System.Net.NetworkInformation; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; @@ -126,6 +127,14 @@ public async Task Start(CancellationToken cancellationToken) for (var port = _startPort; port <= _endPort; port++) { + // This ensures that deploy tool CLI doesn't try on the in-use port + // because server availability task will return success response for + // an in-use port + if (IsPortInUse(port)) + { + continue; + } + _aes = Aes.Create(); _aes.GenerateKey(); @@ -216,6 +225,14 @@ private Task IsServerAvailable(CancellationToken cancellationToken) cancellationToken); } + private static bool IsPortInUse(int port) + { + var ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); + var listeners = ipGlobalProperties.GetActiveTcpListeners(); + + return listeners.Any(x => x.Port == port); + } + #endregion #region Disposable