mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
few more small fixes
complete join button on webfront update for 2.2.6.0
This commit is contained in:
@ -40,8 +40,8 @@ namespace SharedLibraryCore.Database.Models
|
||||
[NotMapped]
|
||||
public virtual string Name
|
||||
{
|
||||
get { return CurrentAlias.Name; }
|
||||
set { CurrentAlias.Name = value; }
|
||||
get { return CurrentAlias?.Name ?? "--"; }
|
||||
set { if (CurrentAlias != null) CurrentAlias.Name = value; }
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual int? IPAddress
|
||||
|
@ -20,5 +20,6 @@ namespace SharedLibraryCore.Dtos
|
||||
public long ID { get; set; }
|
||||
public bool Online { get; set; }
|
||||
public string ConnectProtocolUrl { get; set; }
|
||||
public string IPAddress { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -46,5 +46,6 @@ namespace SharedLibraryCore.Interfaces
|
||||
IEventParser GenerateDynamicEventParser();
|
||||
string Version { get;}
|
||||
ITokenAuthentication TokenAuthenticator { get; }
|
||||
string ExternalIPAddress { get; }
|
||||
}
|
||||
}
|
||||
|
@ -467,7 +467,17 @@ namespace SharedLibraryCore.Database.Models
|
||||
State = ClientState.Disconnecting;
|
||||
TotalConnectionTime += ConnectionLength;
|
||||
LastConnection = DateTime.UtcNow;
|
||||
await CurrentServer.Manager.GetClientService().Update(this);
|
||||
|
||||
try
|
||||
{
|
||||
await CurrentServer.Manager.GetClientService().Update(this);
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
CurrentServer.Logger.WriteWarning($"Could not update disconnected player {this}");
|
||||
CurrentServer.Logger.WriteDebug(e.GetExceptionInfo());
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnJoin(int? ipAddress)
|
||||
|
@ -248,6 +248,7 @@ namespace SharedLibraryCore.Services
|
||||
Type = GameEvent.EventType.ChangePermission,
|
||||
Extra = newPermission,
|
||||
Origin = origin,
|
||||
Owner = temporalClient.CurrentServer,
|
||||
Target = _client
|
||||
}, ctx);
|
||||
#if DEBUG == true
|
||||
@ -255,7 +256,6 @@ namespace SharedLibraryCore.Services
|
||||
#endif
|
||||
});
|
||||
|
||||
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -730,6 +731,53 @@ namespace SharedLibraryCore
|
||||
return string.Format(output, values);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// https://stackoverflow.com/questions/8113546/how-to-determine-whether-an-ip-address-in-private/39120248
|
||||
/// An extension method to determine if an IP address is internal, as specified in RFC1918
|
||||
/// </summary>
|
||||
/// <param name="toTest">The IP address that will be tested</param>
|
||||
/// <returns>Returns true if the IP is internal, false if it is external</returns>
|
||||
public static bool IsInternal(this IPAddress toTest)
|
||||
{
|
||||
if (toTest.ToString().StartsWith("127.0.0"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
byte[] bytes = toTest.GetAddressBytes();
|
||||
switch (bytes[0])
|
||||
{
|
||||
case 10:
|
||||
return true;
|
||||
case 172:
|
||||
return bytes[1] < 32 && bytes[1] >= 16;
|
||||
case 192:
|
||||
return bytes[1] == 168;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieves the external IP address of the current running machine
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static async Task<string> GetExternalIP()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var wc = new WebClient())
|
||||
{
|
||||
return await wc.DownloadStringTaskAsync("https://api.ipify.org");
|
||||
}
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG == true
|
||||
|
||||
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
|
||||
|
Reference in New Issue
Block a user