IW4M-Admin/Application/Misc/VPNCheck.cs
RaidMax 9aea9e1c02 Made webfront optional for decreased ram usage
initialization should be better asynced
clean up publish folder after publish
added chevron hover icon for loading more penalties
added T6M maps to config
2018-04-16 15:31:14 -05:00

38 lines
1.0 KiB
C#

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace 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
}
}
}