You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.3 KiB
130 lines
3.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
using ProtoCSStruct;
|
|
using Sog.IO;
|
|
|
|
namespace Version
|
|
{
|
|
/// <summary>
|
|
/// ip黑白名单列表
|
|
/// </summary>
|
|
public static class LimitIPList
|
|
{
|
|
public static bool IsIPInWhiteList(string id)
|
|
{
|
|
if(string.IsNullOrEmpty(id))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//是否开启白名单
|
|
if(VersionServerUtils.GetServerConfig().enableWhiteIPList)
|
|
{
|
|
if(LimitIpDevice.CheckInWhiteIp(id))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static bool IsIPInBlackList(string id)
|
|
{
|
|
if (string.IsNullOrEmpty(id))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//是否开启黑名单
|
|
if (VersionServerUtils.GetServerConfig().enableBlackIPList)
|
|
{
|
|
if (LimitIpDevice.CheckInBlackIp(id))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static bool IsDeviceIdInWhiteList(string deviceId)
|
|
{
|
|
if (string.IsNullOrEmpty(deviceId))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//是否开启白名单
|
|
if (VersionServerUtils.GetServerConfig().enableWhiteDeviceList)
|
|
{
|
|
return LimitIpDevice.CheckInWhiteDeviceId(deviceId);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
/// <summary>
|
|
/// 检验是否在内测版本白名单中
|
|
/// </summary>
|
|
/// <param name="ip"></param>
|
|
/// <returns></returns>
|
|
public static bool CheckInDebugVesionIp(string ip)
|
|
{
|
|
if (string.IsNullOrEmpty(ip))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return LimitIpDevice.CheckInWhiteIp(ip);
|
|
}
|
|
|
|
|
|
public static void Clear()
|
|
{
|
|
LimitIpDevice.Clear();
|
|
}
|
|
|
|
//白名单版本,有效的白名单版本
|
|
public static bool IsWhiteVer(string os, long reqVersion)
|
|
{
|
|
var cfg = VersionServerUtils.GetServerConfig();
|
|
|
|
if (os.Equals("android"))
|
|
{
|
|
if (cfg.maintenanceWhiteVerNum == null || cfg.maintenanceWhiteVerNum.Length == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
foreach (var ver in cfg.maintenanceWhiteVerNum)
|
|
{
|
|
if (AppVersion.ToIntVersion(ver) == reqVersion)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else if (os.Equals("ios"))
|
|
{
|
|
if (cfg.maintenanceWhiteVerNum_iOS == null || cfg.maintenanceWhiteVerNum_iOS.Length == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
foreach (var ver in cfg.maintenanceWhiteVerNum_iOS)
|
|
{
|
|
if (AppVersion.ToIntVersion(ver) == reqVersion)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|