1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-07 13:48:00 -05:00
RaidMax 3e186ca07a
Add ResolvedExternalIPAddress to API and Master Communication (#365)
* Feature: Add ResolvedExternalIPAddress to API and Master Communication

This commit introduces the `ResolvedExternalIPAddress` property to enhance IP address reporting.

1.  **Server API (`WebfrontCore/Controllers/API/Server.cs`):**
    The `ResolvedExternalIPAddress` property has been added to the JSON
    responses for the `/api/server` endpoints. This property is nullable
    and contains the IPv4 string value of the manager's external IP address
    if the server's resolved IP endpoint is an internal address. Otherwise,
    it is null.

2.  **Master Server Communication (`MasterCommunication.cs` and `ApiServer.cs`):**
    - The `ApiServer` DTO (in `Application/API/Master/ApiServer.cs`) now
      includes the `ResolvedExternalIPAddress` property (serialized as
      `resolved_external_ip_address`).
    - The `UploadStatus` method in `Application/Misc/MasterCommunication.cs`
      now populates this property for each server being reported to the
      master server, using the same logic (external IP if server's own
      resolved IP is internal).

This provides more comprehensive IP address information both through the
web API and to the master server.

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-05-24 15:36:24 -05:00

49 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Data.Models;
using SharedLibraryCore.Helpers;
namespace SharedLibraryCore.Dtos
{
public class ServerInfo
{
public string Name { get; set; }
public int Port { get; set; }
public string Map { get; set; }
public string GameType { get; set; }
public int ClientCount { get; set; }
public int MaxClients { get; set; }
public int PrivateClientSlots { get; set; }
public List<ChatInfo> ChatHistory { get; set; }
public List<PlayerInfo> Players { get; set; }
public List<Report> Reports { get; set; }
public ClientHistoryInfo ClientHistory { get; set; }
public long ID { get; set; }
public bool Online { get; set; }
public string ConnectProtocolUrl { get; set; }
public string IPAddress { get; set; }
public string ExternalIPAddress { get; set; }
public bool IsPasswordProtected { get; set; }
public string? ResolvedExternalIPAddress { get; set; }
public string Endpoint => $"{IPAddress}:{Port}";
public double? LobbyZScore
{
get
{
var valid = Players.Where(player => player.ZScore != null && player.ZScore != 0)
.ToList();
if (!valid.Any())
{
return null;
}
return Math.Round(valid.Select(player => player.ZScore.Value).Average(), 2);
}
}
public Reference.Game Game { get; set; }
}
}