mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Dotnet 8.x Update
- updated all nugets to latest 8.x versions - linting fixes - switched the application insights to use the connection string.
This commit is contained in:
parent
5d8fe6ca90
commit
f5a96f965a
19 changed files with 64 additions and 98 deletions
|
|
@ -3,4 +3,4 @@
|
|||
public interface IServerQueryService
|
||||
{
|
||||
bool CheckServerStatus(string managerCode, string managerVersion, string ipString, int port);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ public class QueryMasterService : IServerQueryService
|
|||
try
|
||||
{
|
||||
using var server = ServerQuery.GetServerInstance(EngineType.Source, ipString, (ushort)port);
|
||||
return server.GetInfo() != null;
|
||||
return server.GetInfo() is not null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -38,35 +38,23 @@ public class QueryMasterService : IServerQueryService
|
|||
var errors = new List<string>();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(managerCode))
|
||||
{
|
||||
errors.Add("Manager code is required.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var managerCodes = _settings.ManagerCodes ?? new List<ManagerCode>();
|
||||
var managerCodes = _settings.ManagerCodes ?? [];
|
||||
if (!managerCodes.Any(c => c.Code.Equals(managerCode, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
errors.Add("Manager code is invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ipString))
|
||||
{
|
||||
errors.Add("IP Address is required.");
|
||||
}
|
||||
else if (!IPAddress.TryParse(ipString, out IPAddress _))
|
||||
{
|
||||
else if (!IPAddress.TryParse(ipString, out _))
|
||||
errors.Add("IP Address is invalid.");
|
||||
}
|
||||
|
||||
if (port <= ushort.MinValue || port >= ushort.MaxValue)
|
||||
{
|
||||
if (port is <= ushort.MinValue or >= ushort.MaxValue)
|
||||
errors.Add($"Valid port is required ({ushort.MinValue} to {ushort.MaxValue}).");
|
||||
}
|
||||
|
||||
if (errors.Count > 0)
|
||||
{
|
||||
throw new ServerManagerApiException(StatusCodes.Status400BadRequest, errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue