mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
migrating Stats to .Net Core 2
moved buildscripts to application added publish profile
This commit is contained in:
37
Application/Misc/VPNCheck.cs
Normal file
37
Application/Misc/VPNCheck.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IW4MAdmin.Application.Misc
|
||||
{
|
||||
public class VPNCheck
|
||||
{
|
||||
public static async Task<bool> UsingVPN(string ip, string apiKey)
|
||||
{
|
||||
#if DEBUG
|
||||
return await Task.FromResult(false);
|
||||
|
||||
#else
|
||||
try
|
||||
{
|
||||
using (var RequestClient = new System.Net.Http.HttpClient())
|
||||
{
|
||||
RequestClient.DefaultRequestHeaders.Add("X-Key", apiKey);
|
||||
string response = await RequestClient.GetStringAsync($"http://v2.api.iphub.info/ip/{ip}");
|
||||
var responseJson = JsonConvert.DeserializeObject<JObject>(response);
|
||||
int blockType = Convert.ToInt32(responseJson["block"]);
|
||||
return blockType == 1;
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user