From 5dfd4561d93007867edb5b78394d05222324aed8 Mon Sep 17 00:00:00 2001 From: Artem Los Date: Tue, 2 Nov 2021 10:37:14 +0100 Subject: [PATCH] Fix an issue with GetKey not recording IP and Friendly Name --- LicenseServer/Helpers.cs | 15 +++++++++------ LicenseServer/LicenseKeyPI.cs | 13 +++++++++++-- LicenseServer/LicenseServerCore.csproj | 6 +++--- LicenseServer/Program.cs | 4 ++-- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/LicenseServer/Helpers.cs b/LicenseServer/Helpers.cs index cd65a6c..e636a92 100644 --- a/LicenseServer/Helpers.cs +++ b/LicenseServer/Helpers.cs @@ -42,6 +42,7 @@ public static string ProcessActivateRequest(byte[] stream, Dictionary new ConcurrentDictionary(), (x, y) => y); } - if(method == APIMethod.GetKey) + if (method == APIMethod.GetKey) { FloatingResult(result, null, null, context, 1, activationData.Values.Select(x => new ActivationData { Time = x.Time, FloatingExpires = x.FloatingExpires, FriendlyName = x.FriendlyName, IP = x.IP, Mid = x.Mid }).ToList()); return $"Floating license {licenseKey} returned successfully using a GetKey request. The data from the local license server is used."; @@ -99,12 +100,14 @@ public static string ProcessActivateRequest(byte[] stream, Dictionary DateTime.UtcNow) { activation.FloatingExpires = DateTime.UtcNow.AddSeconds(floatingTimeInterval); + activation.FriendlyName = friendlyName; + activation.IP = context.Request.RemoteEndPoint.ToString(); FloatingResult(result, activation, machineCode, context); return $"Floating license {licenseKey} returned successfully."; } else if(activationData.Count(x=> x.Value.FloatingExpires > DateTime.UtcNow) < result.LicenseKey.MaxNoOfMachines) { - activation = activationData.AddOrUpdate(machineCode, x=> new ActivationData { Mid = machineCode, Time = DateTime.UtcNow, FloatingExpires = DateTime.UtcNow.AddSeconds(floatingTimeInterval) }, (x,y) => new ActivationData { Mid = machineCode, Time = y.Time, FloatingExpires = DateTime.UtcNow.AddSeconds(floatingTimeInterval) }); + activation = activationData.AddOrUpdate(machineCode, x=> new ActivationData { Mid = machineCode, Time = DateTime.UtcNow, FloatingExpires = DateTime.UtcNow.AddSeconds(floatingTimeInterval), FriendlyName = friendlyName, IP = context.Request.RemoteEndPoint.ToString() }, (x,y) => new ActivationData { Mid = machineCode, Time = y.Time, FloatingExpires = DateTime.UtcNow.AddSeconds(floatingTimeInterval), FriendlyName = friendlyName, IP = context.Request.RemoteEndPoint.ToString() }); FloatingResult(result, activation, machineCode, context); return $"Floating license {licenseKey} returned successfully."; @@ -120,7 +123,7 @@ public static string ProcessActivateRequest(byte[] stream, Dictionary new ActivationDataPI { FriendlyName = x.FriendlyName, IP = x.IP, Time = ToUnixTimestamp(x.Time.Value), Mid = $"floating:{x.Mid}"}).ToList(); + licenseKeyToReturn.ActivatedMachines = activations.Select(x => new ActivationDataPIV3 { FriendlyName = x.FriendlyName, IP = x.IP, Time = ToUnixTimestamp(x.Time.Value), Mid = $"floating:{x.Mid}", FloatingExpires = ToUnixTimestamp(x.FloatingExpires.Value)}).ToList(); } else { - licenseKeyToReturn.ActivatedMachines = new List() { new ActivationDataPI { Mid = $"floating:{machineCode}", Time = - ToUnixTimestamp(activation.Time.Value)} }; + licenseKeyToReturn.ActivatedMachines = new List() { new ActivationDataPIV3 { Mid = $"floating:{machineCode}", Time = + ToUnixTimestamp(activation.Time.Value), FriendlyName = activation.FriendlyName, IP = activation.IP, FloatingExpires = ToUnixTimestamp(activation.FloatingExpires.Value) } }; } licenseKeyToReturn.Block = result.LicenseKey.Block; diff --git a/LicenseServer/LicenseKeyPI.cs b/LicenseServer/LicenseKeyPI.cs index 1932b7e..4d64c3c 100644 --- a/LicenseServer/LicenseKeyPI.cs +++ b/LicenseServer/LicenseKeyPI.cs @@ -54,7 +54,7 @@ public LicenseKeyPI() public CustomerPI Customer { get; set; } - public List ActivatedMachines { get; set; } + public List ActivatedMachines { get; set; } public bool TrialActivation { get; set; } @@ -74,7 +74,7 @@ public LicenseKey ToLicenseKey() foreach (var item in ActivatedMachines) { - activationData.Add(new ActivationData() { IP = item.IP, Mid = item.Mid, Time = epoch.AddSeconds(item.Time) }); + activationData.Add(new ActivationData() { IP = item.IP, Mid = item.Mid, Time = epoch.AddSeconds(item.Time), FriendlyName = item.FriendlyName, FloatingExpires = epoch.AddSeconds(item.FloatingExpires) }); } return new LicenseKey @@ -130,4 +130,13 @@ public class ActivationDataPI public string FriendlyName { get; set; } } + public class ActivationDataPIV3 + { + public string Mid { get; set; } + public string FriendlyName { get; set; } + public string IP { get; set; } + public long Time { get; set; } + public long FloatingExpires { get; set; } + } + } diff --git a/LicenseServer/LicenseServerCore.csproj b/LicenseServer/LicenseServerCore.csproj index 7625c82..acee4a3 100644 --- a/LicenseServer/LicenseServerCore.csproj +++ b/LicenseServer/LicenseServerCore.csproj @@ -18,13 +18,13 @@ LicenseServer - 2.5.1.0 + 2.6.1.0 - 2.5.1.0 + 2.6.1.0 Copyright © 2019 - 2021 Cryptolens AB - 2.5 + 2.6 LicenseServer diff --git a/LicenseServer/Program.cs b/LicenseServer/Program.cs index 8e2cb17..c5f3965 100644 --- a/LicenseServer/Program.cs +++ b/LicenseServer/Program.cs @@ -29,7 +29,7 @@ namespace LicenseServer { class Program { - public const string versionInfo = "v2.5 (2021-10-21)" ; + public const string versionInfo = "v2.6 (2021-11-02)" ; public const string ServiceName = "license-server"; @@ -77,7 +77,7 @@ protected override void OnStop() // A configuration can be generated on https://app.cryptolens.io/extensions/licenseserver // More instructions can be found here: https://github.com/Cryptolens/license-server/#floating-licenses-offline - public static string ConfigurationFromCryptolens = "ksUFW5jNH5DNAW3DkaxsaWNlbnNlZmlsZXPD2gGfPFJTQUtleVZhbHVlPjxNb2R1bHVzPnNHYnZ4d2RsRGJxRlhPTWxWVW5BRjVldzB0MFdwUFc3ckZwSTVqSFFPRmtodC8zMjZkdmg3dDc0UlllTXBqeTM1N05sam91aHBUTEEzYTZpZG5uNGo2YzNqbVBXQmtqWm5kR3NQTDRCcW0rZndFNDhuS3BHUGprajRxL3l6VDR0SFhCVHl2YUJqQThiVm9DVG51K0xpQzRYRWFMWlJUaEd6S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