BF2Statistics.ASP.StatsManager.IsAuthorizedGameServer C# (CSharp) Method

IsAuthorizedGameServer() public static method

Returns whether the specified IP address is authorized to POST snapshot data to this ASP server. All local IP address are automatically authorized.
public static IsAuthorizedGameServer ( IPAddress RemoteIP ) : bool
RemoteIP System.Net.IPAddress The server IP to authorize
return bool
        public static bool IsAuthorizedGameServer(IPAddress RemoteIP)
        {
            // Local is always authorized
            if (IPAddress.IsLoopback(RemoteIP) || HttpServer.LocalIPs.Contains(RemoteIP))
                return true;

            // Setup local vars
            IPAddress Ip;

            // Loop through all Config allowed game hosts, and determine if the remote host is allowed
            // to post snapshots here
            if (!String.IsNullOrWhiteSpace(Program.Config.ASP_GameHosts))
            {
                string[] Hosts = Program.Config.ASP_GameHosts.Split(',');
                foreach (string Host in Hosts)
                {
                    if (IPAddress.TryParse(Host, out Ip) && Ip.Equals(RemoteIP))
                    {
                        return true;
                    }
                }
            }

            return false;
        }