Country added
This commit is contained in:
parent
c34aa7bf2f
commit
8d1ba087d8
@ -29,6 +29,7 @@ WEB: https://gtacoopr.entenkoeniq.de/
|
||||
- [LemonUI.SHVDN3](https://github.com/justalemon/LemonUI/tree/a29f73120fc4f473cdfd14104aaef77f1a1b76e5)
|
||||
- [Lidgren Network](https://github.com/lidgren/lidgren-network-gen3/tree/f99b006d9af8a9a230ba7c5ce0320fc727ebae0c)
|
||||
- [Protobuf-net](https://www.nuget.org/packages/protobuf-net/2.4.6)
|
||||
- [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/13.0.1)
|
||||
|
||||
# ♻️ Synchronization
|
||||
- Pedestrians
|
||||
|
@ -6,6 +6,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="protobuf-net" Version="2.4.6" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -5,12 +5,18 @@ using System.Threading;
|
||||
using System.Text;
|
||||
using System.Net.Http;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Lidgren.Network;
|
||||
|
||||
using CoopServer.Entities;
|
||||
|
||||
namespace CoopServer
|
||||
{
|
||||
class IpInfo
|
||||
{
|
||||
public string Country { get; set; }
|
||||
}
|
||||
|
||||
class MasterServer
|
||||
{
|
||||
private Thread MainThread;
|
||||
@ -25,6 +31,19 @@ namespace CoopServer
|
||||
{
|
||||
try
|
||||
{
|
||||
IpInfo info;
|
||||
try
|
||||
{
|
||||
using HttpClient httpClient = new();
|
||||
string data = await httpClient.GetStringAsync("https://ipinfo.io/json");
|
||||
|
||||
info = JsonConvert.DeserializeObject<IpInfo>(data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
info = new() { Country = "?" };
|
||||
}
|
||||
|
||||
bool responseError = false;
|
||||
HttpClient client = new();
|
||||
|
||||
@ -37,7 +56,8 @@ namespace CoopServer
|
||||
"\"version\": \"" + Server.CurrentModVersion.Replace("_", ".") + "\", " +
|
||||
"\"players\": \"" + Server.MainNetServer.ConnectionsCount + "\", " +
|
||||
"\"maxPlayers\": \"" + Server.MainSettings.MaxPlayers + "\", " +
|
||||
"\"allowlist\": \"" + Server.MainSettings.Allowlist + "\"" +
|
||||
"\"allowlist\": \"" + Server.MainSettings.Allowlist + "\", " +
|
||||
"\"country\": \"" + info.Country + "\"" +
|
||||
" }";
|
||||
|
||||
HttpResponseMessage response = await client.PostAsync(Server.MainSettings.MasterServer, new StringContent(msg, Encoding.UTF8, "application/json"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user