using Sog; using Sog.IO; namespace World { /// /// ip黑白名单列表 /// 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; } /// /// 检验是否在内测版本白名单中 /// /// /// 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; } } }