mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Build error fix and added back ip property
This commit is contained in:
parent
868ee2a4ff
commit
38edb68574
@ -280,18 +280,19 @@
|
|||||||
if (GeolocationCache.ContainsKey(ActivityMachineAddress))
|
if (GeolocationCache.ContainsKey(ActivityMachineAddress))
|
||||||
return GeolocationCache[ActivityMachineAddress];
|
return GeolocationCache[ActivityMachineAddress];
|
||||||
|
|
||||||
string location, locationCity, locationRegion, locationCountry = "";
|
string location = "", locationCity = "", locationRegion = "", locationCountry = "";
|
||||||
|
|
||||||
IPInfoResponse locationInformation;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IPInfoResponse locationInformation = await Http.GetJson<IPInfoResponse>($"https://ipinfo.io/{ActivityMachineAddress}/json");
|
var locationInformation = await Http.GetJson<IPInfoResponse>($"https://ipinfo.io/{ActivityMachineAddress}/json");
|
||||||
|
|
||||||
|
if (locationInformation is not null)
|
||||||
|
{
|
||||||
locationCity = locationInformation.IP;
|
locationCity = locationInformation.IP;
|
||||||
locationRegion = locationInformation.Region;
|
locationRegion = locationInformation.Region;
|
||||||
locationCountry = locationInformation.Country;
|
locationCountry = locationInformation.Country;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine(LOG_IDENT, $"Failed to get server location for {ActivityMachineAddress}");
|
App.Logger.WriteLine(LOG_IDENT, $"Failed to get server location for {ActivityMachineAddress}");
|
||||||
|
@ -2,13 +2,13 @@ namespace Bloxstrap.Models
|
|||||||
{
|
{
|
||||||
public class IPInfoResponse
|
public class IPInfoResponse
|
||||||
{
|
{
|
||||||
[JsonPropertyName("city")]
|
[JsonPropertyName("ip")]
|
||||||
public string? City { get; set; }
|
public string IP { get; set; } = null!;
|
||||||
|
|
||||||
[JsonPropertyName("country")]
|
[JsonPropertyName("country")]
|
||||||
public string? Country { get; set; }
|
public string Country { get; set; } = null!;
|
||||||
|
|
||||||
[JsonPropertyName("region")]
|
[JsonPropertyName("region")]
|
||||||
public string? Region { get; set; }
|
public string Region { get; set; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user