mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
support custom master url
refactor api instatation to allow custom master url in config
This commit is contained in:
@ -98,6 +98,8 @@ namespace SharedLibraryCore.Configuration
|
||||
public string WebfrontUrl => string.IsNullOrEmpty(ManualWebfrontUrl) ? WebfrontBindUrl?.Replace("0.0.0.0", "127.0.0.1") : ManualWebfrontUrl;
|
||||
[ConfigurationIgnore]
|
||||
public bool IgnoreServerConnectionLost { get; set; }
|
||||
[ConfigurationIgnore]
|
||||
public Uri MasterUrl { get; set; } = new Uri("https://fn-p.master.threadsafe.sh/");
|
||||
|
||||
public IBaseConfiguration Generate()
|
||||
{
|
||||
|
@ -67,6 +67,10 @@ namespace SharedLibraryCore.Configuration.Validation
|
||||
RuleForEach(_app => _app.Servers)
|
||||
.NotEmpty()
|
||||
.SetValidator(new ServerConfigurationValidator());
|
||||
|
||||
RuleFor(_app => _app.MasterUrl)
|
||||
.NotNull()
|
||||
.Must(_url => _url != null && _url.Scheme == Uri.UriSchemeHttp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
SharedLibraryCore/Interfaces/IMasterCommunication.cs
Normal file
24
SharedLibraryCore/Interfaces/IMasterCommunication.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// defines the capabilities of the communication to the master server
|
||||
/// </summary>
|
||||
public interface IMasterCommunication
|
||||
{
|
||||
/// <summary>
|
||||
/// checks the current version of IW4MAdmin against the master version
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task CheckVersion();
|
||||
|
||||
/// <summary>
|
||||
/// Sends heart beats to the master
|
||||
/// </summary>
|
||||
/// <param name="token">Cancellation token</param>
|
||||
/// <returns></returns>
|
||||
Task RunUploadStatus(CancellationToken token);
|
||||
}
|
||||
}
|
@ -541,10 +541,6 @@ namespace SharedLibraryCore.Services
|
||||
LastConnection = client.LastConnection
|
||||
};
|
||||
|
||||
#if DEBUG == true
|
||||
var clientsSql = iqClients.ToSql();
|
||||
#endif
|
||||
|
||||
return await iqClients.ToListAsync();
|
||||
}
|
||||
}
|
||||
@ -601,9 +597,7 @@ namespace SharedLibraryCore.Services
|
||||
LastConnection = _client.LastConnection,
|
||||
ClientId = _client.ClientId,
|
||||
});
|
||||
#if DEBUG == true
|
||||
var iqClientsSql = iqClients.ToSql();
|
||||
#endif
|
||||
|
||||
var clients = await iqClientProjection.ToListAsync();
|
||||
|
||||
// this is so we don't try to evaluate this in the linq to entities query
|
||||
@ -635,9 +629,7 @@ namespace SharedLibraryCore.Services
|
||||
{
|
||||
var startOfPeriod = DateTime.UtcNow.AddHours(-24);
|
||||
var iqQuery = context.Clients.Where(_client => _client.LastConnection >= startOfPeriod);
|
||||
#if DEBUG
|
||||
string sql = iqQuery.ToSql();
|
||||
#endif
|
||||
|
||||
return await iqQuery.CountAsync();
|
||||
}
|
||||
}
|
||||
@ -664,9 +656,6 @@ namespace SharedLibraryCore.Services
|
||||
LastConnection = _client.FirstConnection
|
||||
});
|
||||
|
||||
#if DEBUG
|
||||
var sql = iqClients.ToSql();
|
||||
#endif
|
||||
return await iqClients.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
@ -88,9 +88,6 @@ namespace SharedLibraryCore.Services
|
||||
IsEvade = _penalty.IsEvadedOffense
|
||||
});
|
||||
|
||||
#if DEBUG == true
|
||||
var querySql = iqPenalties.ToSql();
|
||||
#endif
|
||||
return await iqPenalties.ToListAsync();
|
||||
}
|
||||
}
|
||||
@ -136,9 +133,6 @@ namespace SharedLibraryCore.Services
|
||||
IsEvade = _penalty.IsEvadedOffense
|
||||
});
|
||||
|
||||
#if DEBUG == true
|
||||
var querySql = iqPenalties.ToSql();
|
||||
#endif
|
||||
return await iqPenalties.Distinct().ToListAsync();
|
||||
}
|
||||
}
|
||||
@ -167,11 +161,6 @@ namespace SharedLibraryCore.Services
|
||||
.SelectMany(a => a.Link.ReceivedPenalties)
|
||||
.Where(filter);
|
||||
|
||||
#if DEBUG == true
|
||||
var penaltiesSql = iqLinkPenalties.ToSql();
|
||||
var ipPenaltiesSql = iqIPPenalties.ToSql();
|
||||
#endif
|
||||
|
||||
var activePenalties = (await iqLinkPenalties.ToListAsync())
|
||||
.Union(await iqIPPenalties.ToListAsync())
|
||||
.Distinct();
|
||||
|
@ -964,7 +964,12 @@ namespace SharedLibraryCore
|
||||
}
|
||||
|
||||
public static bool ShouldHideLevel(this Permission perm) => perm == Permission.Flagged;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// indicates if running in development mode
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool IsDevelopment => Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development";
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -981,12 +986,5 @@ namespace SharedLibraryCore
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
#if DEBUG == true
|
||||
public static string ToSql<TEntity>(this IQueryable<TEntity> query) where TEntity : class
|
||||
{
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user