Example #1
0
        /// <summary>
        /// Create IpFilter
        /// </summary>
        /// <param name="srcList">Source IpRange/ASN/Country based List string</param>
        /// <param name="listType"></param>
        /// <param name="isBlackList"></param>
        /// <param name="act"></param>
        /// <returns></returns>
        public static stIPFilter IpFilterCreate(
            List <string> srcList,
            stACL.IpFilterType listType,
            bool isBlackList = true,
            Func <uint, List <int>, int, bool, bool> act = null,
            Func <string, int> func = null
            )
        {
            StringCollection geoCollection = null;

            if ((srcList != null) && (srcList.Count > 0))
            {
                geoCollection = new StringCollection();
                geoCollection.AddRange(srcList.ToArray());
            }
            return(stACL._IpFilterCreate(
                       ((listType == IpFilterType.IPRange) ? geoCollection : null),
                       ((listType == IpFilterType.GeoASN) ? geoCollection : null),
                       ((listType == IpFilterType.GeoCountry) ? geoCollection : null),
                       ((listType == IpFilterType.IPRange) ? isBlackList : true),
                       ((listType == IpFilterType.GeoASN) ? isBlackList : true),
                       ((listType == IpFilterType.GeoCountry) ? isBlackList : true),
                       act,
                       func
                       ));
        }
Example #2
0
        /// <summary>
        /// Create IpFilter
        /// </summary>
        /// <param name="srcList">Source ASN/Country based List int</param>
        /// <param name="listType"></param>
        /// <param name="isBlackList"></param>
        /// <param name="act"></param>
        /// <returns></returns>
        public static stIPFilter IpFilterCreate(
            List <int> srcList,
            stACL.IpFilterType listType,
            bool isBlackList = true,
            Func <uint, List <int>, int, bool, bool> act = null,
            Func <string, int> func = null
            )
        {
            StringCollection geoCollection = null;

            if (
                ((srcList != null) && (srcList.Count > 0)) &&
                ((listType == IpFilterType.GeoASN) || (listType == IpFilterType.GeoCountry))
                )
            {
                geoCollection = new StringCollection();
                foreach (int num in srcList)
                {
                    geoCollection.Add(num.ToString());
                }
            }
            return(stACL._IpFilterCreate(
                       null,
                       ((listType == IpFilterType.GeoASN) ? geoCollection : null),
                       ((listType == IpFilterType.GeoCountry) ? geoCollection : null),
                       true,
                       ((listType == IpFilterType.GeoASN) ? isBlackList : true),
                       ((listType == IpFilterType.GeoCountry) ? isBlackList : true),
                       act,
                       func
                       ));
        }
Example #3
0
 /// <summary>
 /// Create IpFilter
 /// </summary>
 /// <param name="srcList">Source IpRange/ASN/Country based StringCollection</param>
 /// <param name="listType"></param>
 /// <param name="isBlackList"></param>
 /// <param name="act"></param>
 /// <returns></returns>
 public static stIPFilter IpFilterCreate(
     StringCollection strCollection,
     stACL.IpFilterType listType,
     bool isBlackList = true,
     Func <uint, List <int>, int, bool, bool> act = null,
     Func <string, int> func = null
     )
 {
     return(stACL._IpFilterCreate(
                ((listType == IpFilterType.IPRange) ? strCollection : null),
                ((listType == IpFilterType.GeoASN) ? strCollection : null),
                ((listType == IpFilterType.GeoCountry) ? strCollection : null),
                ((listType == IpFilterType.IPRange) ? isBlackList : true),
                ((listType == IpFilterType.GeoASN) ? isBlackList : true),
                ((listType == IpFilterType.GeoCountry) ? isBlackList : true),
                act,
                func
                ));
 }
Example #4
0
 public static bool IpFilterIpRange(this List <stIpRange> IpListRange, uint ipa, stACL.IpFilterType ipListType = stACL.IpFilterType.BlackList)
 {
     if (ipa == 0)
     {
         return(false);
     }
     return(stACL._IpFilterIpRange(IpListRange, ipa, ((ipListType == stACL.IpFilterType.WhiteList) ? false : true)));
 }