diff --git a/server/AyaNova/util/License.cs b/server/AyaNova/util/License.cs index f4d82427..739a2331 100644 --- a/server/AyaNova/util/License.cs +++ b/server/AyaNova/util/License.cs @@ -28,8 +28,12 @@ namespace AyaNova.Core internal static class License { - //License server address - private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/"; + //License server addresses + private const string LICENSE_SERVER_URL_ROCKFISH = "https://rockfish.ayanova.com/"; + private const string LICENSE_SERVER_URL_IO = "https://io.ayanova.com/"; + private const string LICENSE_SERVER_URL_EUROPA = "https://europa.ayanova.com/"; + private const string LICENSE_SERVER_URL_CALLISTO = "https://callisto.ayanova.com/"; + // #if (DEBUG) // private const string LICENSE_SERVER_URL = "http://localhost:3001/"; @@ -186,7 +190,7 @@ namespace AyaNova.Core { get { - + return (Status == LicenseStatus.ActivePurchased) || (Status == LicenseStatus.ActiveTrial); } @@ -454,7 +458,7 @@ namespace AyaNova.Core trialRequest.DbId = ServerDbId; log.LogDebug($"Requesting trial license for DBID {LicenseDbId}"); - string sUrl = $"{LICENSE_SERVER_URL}rvr"; + string sUrl = $"{LICENSE_SERVER_URL_ROCKFISH}rvr"; try { var content = new StringContent(JsonConvert.SerializeObject(trialRequest), Encoding.UTF8, "application/json"); @@ -492,7 +496,7 @@ namespace AyaNova.Core /// /// Result string #if (DEBUG) - internal static async Task FetchKeyAsync(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log, bool calledFromInternalJob, bool devTestTrial=false) + internal static async Task FetchKeyAsync(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log, bool calledFromInternalJob, bool devTestTrial = false) #else internal static async Task FetchKeyAsync(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log, bool calledFromInternalJob) #endif @@ -504,22 +508,22 @@ namespace AyaNova.Core var FetchRequest = new dtoFetchRequest() { DbId = LicenseDbId }; #if (DEBUG) - string sUrl = $"{LICENSE_SERVER_URL}rvf"; + string AppendToLicenseUrl = "rvf"; if (devTestTrial) { - sUrl += "?dtt=true";//signal to rockfish to provide a key immediately for dev testing + AppendToLicenseUrl += "?dtt=true";//signal to rockfish to provide a key immediately for dev testing } #else - string sUrl = $"{LICENSE_SERVER_URL}rvf"; + string sUrl = $"rvf"; #endif try { - // string ResponseText = await ServiceProviderProvider.HttpClientFactory.CreateClient().GetStringAsync(sUrl); - var content = new StringContent(JsonConvert.SerializeObject(FetchRequest), Encoding.UTF8, "application/json"); var client = ServiceProviderProvider.HttpClientFactory.CreateClient(); - var res = await client.PostAsync(sUrl, content); + HttpResponseMessage res = null; + + res = await DoFetchAsync(AppendToLicenseUrl, content, client); if (res.IsSuccessStatusCode) { var responseText = await res.Content.ReadAsStringAsync(); @@ -587,6 +591,40 @@ namespace AyaNova.Core } } + private static async Task DoFetchAsync(string AppendToLicenseUrl, StringContent content, HttpClient client) + { + var LicenseServer = string.Empty; + for (int x = 0; x < 4; x++) + { + try + { + switch (x) + { + case 0: + LicenseServer = LICENSE_SERVER_URL_CALLISTO; + break; + case 1: + LicenseServer = LICENSE_SERVER_URL_IO; + break; + case 2: + LicenseServer = LICENSE_SERVER_URL_EUROPA; + break; + case 3: + LicenseServer = LICENSE_SERVER_URL_ROCKFISH ; + break; + } + + return await client.PostAsync($"{LicenseServer}{AppendToLicenseUrl}", content); + + } + catch(System.Net.Http.HttpRequestException){ + if(x==3) + throw; + } + } + return null; + } + /// /// Initialize the license