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.
 
 
 
 
 
 

94 lines
2.3 KiB

using Sog;
using Sog.IO;
namespace World
{
/// <summary>
/// ip黑白名单列表
/// </summary>
public static class LimitIPList
{
public static bool CheckIPValid(string id)
{
if(string.IsNullOrEmpty(id))
{
return true;
}
//是否开启白名单
if(WorldServerUtils.GetServerConfig().enableWhiteIPList)
{
if(false == LimitIpDevice.CheckInWhiteIp(id))
{
return false;
}
}
//是否开启黑名单
if(WorldServerUtils.GetServerConfig().enableBlackIPList)
{
if(LimitIpDevice.CheckInBlackIp(id))
{
return false;
}
}
return true;
}
public static bool CheckDeviceIdValid(string deviceId)
{
if (string.IsNullOrEmpty(deviceId))
{
return true;
}
//是否开启白名单
if (WorldServerUtils.GetServerConfig().enableWhiteIPList)
{
return LimitIpDevice.CheckInWhiteDeviceId(deviceId);
}
return true;
}
/// <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 CheckWhiteVerValid(long reqVersion)
{
var cfg = WorldServerUtils.GetServerConfig();
if(cfg.maintenanceWhiteVerNum == null || cfg.maintenanceWhiteVerNum.Length == 0)
{
return false;
}
foreach (var ver in cfg.maintenanceWhiteVerNum)
{
if(AppVersion.ToIntVersion(ver) == reqVersion)
{
return true;
}
}
return false;
}
}
}