Beispiel #1
0
 public static IPModel GetIPInfo(string word)
 {
     if (!string.IsNullOrEmpty(word))
     {
         IPModel slt   = null;
         string  key   = "host_" + word;
         object  cache = CacheUtils.GetCache(key);
         if (cache == null)
         {
             if (RegexUtils.IsDomain(word))
             {
                 string ip = GetIPFromDomain(word);
                 slt = GetIP(ip);
             }
             else
             {
                 slt = GetIP(word);
             }
             if (slt != null)
             {
                 CacheUtils.SetCache(key, slt, new TimeSpan(0, 30, 0));
             }
         }
         else
         {
             slt = cache as IPModel;
         }
         return(slt);
     }
     return(null);
 }
Beispiel #2
0
        public static IPModel GetIP(string ip)
        {
            IPModel model    = null;
            string  fileName = HttpContext.Current.Server.MapPath("~/App_Data/CoralWry.dat");
            var     slt      = IpLocator.GetIpLocation(fileName, ip);

            model = new IPModel()
            {
                ip      = ip,
                country = slt.Country,
                city    = slt.City,
                start   = IpLocator.IntToIpString(slt.IpStart),
                end     = IpLocator.IntToIpString(slt.IpEnd)
            };
            return(model);
        }