2018-03-13 17:30:22 -04:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System;
|
2018-03-09 03:01:12 -05:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2018-04-16 16:31:14 -04:00
|
|
|
|
namespace Application.Misc
|
2018-03-09 03:01:12 -05:00
|
|
|
|
{
|
|
|
|
|
public class VPNCheck
|
|
|
|
|
{
|
2018-03-14 01:36:25 -04:00
|
|
|
|
public static async Task<bool> UsingVPN(string ip, string apiKey)
|
2018-03-09 03:01:12 -05:00
|
|
|
|
{
|
2018-03-13 17:30:22 -04:00
|
|
|
|
#if DEBUG
|
2018-03-18 22:25:11 -04:00
|
|
|
|
return await Task.FromResult(false);
|
|
|
|
|
|
|
|
|
|
#else
|
2018-03-09 03:01:12 -05:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var RequestClient = new System.Net.Http.HttpClient())
|
|
|
|
|
{
|
2018-03-14 01:36:25 -04:00
|
|
|
|
RequestClient.DefaultRequestHeaders.Add("X-Key", apiKey);
|
2018-03-13 17:30:22 -04:00
|
|
|
|
string response = await RequestClient.GetStringAsync($"http://v2.api.iphub.info/ip/{ip}");
|
|
|
|
|
var responseJson = JsonConvert.DeserializeObject<JObject>(response);
|
|
|
|
|
int blockType = Convert.ToInt32(responseJson["block"]);
|
2018-05-03 01:25:49 -04:00
|
|
|
|
/*if (responseJson.ContainsKey("isp"))
|
2018-04-29 16:44:04 -04:00
|
|
|
|
{
|
|
|
|
|
if (responseJson["isp"].ToString() == "TSF-IP-CORE")
|
|
|
|
|
return true;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
}*/
|
2018-03-13 17:30:22 -04:00
|
|
|
|
return blockType == 1;
|
2018-03-09 03:01:12 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-03-18 22:25:11 -04:00
|
|
|
|
#endif
|
2018-03-09 03:01:12 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|