using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Sog; using ProtoCSStruct; using Sog.IO; namespace Version { /// /// ip黑白名单列表 /// 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; } /// /// 检验是否在内测版本白名单中 /// /// /// 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; } } }