using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Utils
{
    public class RequestHelper
    {
        /// <summary>
        /// 是否为远程服务器,DEBUG用
        /// </summary>
        public static bool IsRemote
        {
            get
            {
                string address = RequestHelper.GetServerIp();
                bool a = !address.Contains("192.168.") && !address.Contains("127.0.");
                return a;
            }
        }
        static string serverIp;
        public static string GetServerIp()
        {
            if (string.IsNullOrEmpty(serverIp))
            {
                System.Net.IPAddress[] addressList = Dns.GetHostAddresses(Dns.GetHostName());

                string address = "";
                foreach (System.Net.IPAddress a in addressList)
                {
                    if (a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        address = a.ToString();
                        break;
                    }
                }
                serverIp = address;
            }
            return serverIp;
        }
    }
}
