Skip to content

Commit e951eea

Browse files
committed
Merge branch 'master' of github.com:cantarus/PolyDeploy into development
2 parents 25e5785 + ddc2bc2 commit e951eea

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

DeployClient/Program.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ static async Task Main(string[] args)
228228
// Finished install.
229229
WriteLine(string.Format("Finished installation in {0} ms.", (DateTime.Now - installStartTime).TotalMilliseconds));
230230
ReadLine();
231+
232+
int succeeded = ParseResults(results).succeeded;
233+
bool allSucceeded = succeeded == results.Count;
234+
ExitCode exitCode = allSucceeded ? ExitCode.Success : ExitCode.InstallFailure;
235+
Environment.Exit((int)exitCode);
231236
}
232237
catch (Exception ex)
233238
{
@@ -268,6 +273,12 @@ private static void GetSettings(string[] args)
268273
}
269274

270275
private static string BuildUpdateString(SortedList<string, dynamic> results)
276+
{
277+
var (attempted, succeeded, _) = ParseResults(results);
278+
return string.Format("\t{0}/{1} module archives processed, {2}/{0} succeeded.", attempted, results.Count, succeeded);
279+
}
280+
281+
private static (int attempted, int succeeded, int failed) ParseResults(SortedList<string, dynamic> results)
271282
{
272283
// Get counts.
273284
int attempted = 0;
@@ -293,7 +304,7 @@ private static string BuildUpdateString(SortedList<string, dynamic> results)
293304
}
294305
}
295306

296-
return string.Format("\t{0}/{1} module archives processed, {2}/{0} succeeded.", attempted, results.Count, succeeded);
307+
return (attempted, succeeded, failed);
297308
}
298309

299310
private static void WriteException(Exception ex, int maxDepth = 10, int depth = 0)

PolyDeploy/Components/IPSpecManager.cs

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Cantarus.Modules.PolyDeploy.Components.DataAccess.Models;
33
using System;
44
using System.Collections.Generic;
5+
using System.Net;
56

67
namespace Cantarus.Modules.PolyDeploy.Components
78
{
@@ -51,6 +52,20 @@ public static IPSpec GetById(int id)
5152
*/
5253
public static bool IsWhitelisted(string address)
5354
{
55+
if (!IPAddress.TryParse(address, out _))
56+
{
57+
// see if address is an IP plus port, e.g. "1.1.1.1:58290"
58+
if (Uri.TryCreate(Uri.UriSchemeHttps + Uri.SchemeDelimiter + address, UriKind.Absolute, out Uri uri))
59+
{
60+
if (uri.HostNameType != UriHostNameType.IPv4 && uri.HostNameType != UriHostNameType.IPv6)
61+
{
62+
return false;
63+
}
64+
65+
address = uri.Host;
66+
}
67+
}
68+
5469
IPSpec ipSpec = IPSpecDC.FindByAddress(address);
5570

5671
return ipSpec != null;

0 commit comments

Comments
 (0)