Ejemplo n.º 1
0
 internal bool IsIPAddressAllowed(IPAddress ipAddress)
 {
     if (this.AllowLocal)
     {
         if (this._localIps == null)
         {
             lock (this._lockObj)
             {
                 if (this._localIps == null)
                 {
                     this._localIps = this.GetLocalAddresses();
                 }
             }
         }
         if (this._localIps != null)
         {
             foreach (IPAddress current in this._localIps)
             {
                 if (current.Equals(ipAddress))
                 {
                     bool result = true;
                     return(result);
                 }
             }
         }
     }
     if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
     {
         if (this._ip4Ranges == null)
         {
             lock (this._lockObj)
             {
                 if (this._ip4Ranges == null)
                 {
                     this._ip4Ranges = this.ParseIPRangeList(AddressFamily.InterNetwork, this.IPAddress);
                 }
             }
         }
         if (this._ip4Ranges == null)
         {
             return(false);
         }
         using (System.Collections.Generic.List <IPRange> .Enumerator enumerator2 = this._ip4Ranges.GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 IPRange current2 = enumerator2.Current;
                 if (current2.IsInRange(ipAddress))
                 {
                     bool result = true;
                     return(result);
                 }
             }
             return(false);
         }
     }
     if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
     {
         if (this._ip6Ranges == null)
         {
             lock (this._lockObj)
             {
                 if (this._ip6Ranges == null)
                 {
                     this._ip6Ranges = this.ParseIPRangeList(AddressFamily.InterNetworkV6, this.IP6Address);
                 }
             }
         }
         if (this._ip6Ranges != null)
         {
             foreach (IPRange current3 in this._ip6Ranges)
             {
                 if (current3.IsInRange(ipAddress))
                 {
                     bool result = true;
                     return(result);
                 }
             }
         }
     }
     return(false);
 }