Exemple #1
0
 protected IPQuery.CZ_INDEX_INFO IndexInfoAtPos(uint Index_Pos)
 {
     IPQuery.CZ_INDEX_INFO cz_index_info = new IPQuery.CZ_INDEX_INFO();
     this.FileStrm.Seek(( long )(this.Index_Set + (7 * Index_Pos)), SeekOrigin.Begin);
     cz_index_info.IpSet  = this.GetUInt32();
     cz_index_info.Offset = this.GetOffset();
     this.FileStrm.Seek(( long )cz_index_info.Offset, SeekOrigin.Begin);
     cz_index_info.IpEnd = this.GetUInt32();
     return(cz_index_info);
 }
Exemple #2
0
 protected IPQuery.CZ_INDEX_INFO IndexInfoAtPos(uint Index_Pos)
 {
     IPQuery.CZ_INDEX_INFO cZ_INDEX_INFO = new IPQuery.CZ_INDEX_INFO();
     this.FileStrm.Seek((long)((ulong)(this.Index_Set + 7u * Index_Pos)), SeekOrigin.Begin);
     cZ_INDEX_INFO.IpSet  = this.GetUInt32();
     cZ_INDEX_INFO.Offset = this.GetOffset();
     this.FileStrm.Seek((long)((ulong)cZ_INDEX_INFO.Offset), SeekOrigin.Begin);
     cZ_INDEX_INFO.IpEnd = this.GetUInt32();
     return(cZ_INDEX_INFO);
 }
Exemple #3
0
            public string GetAddressWithIP(string IPValue)
            {
                if (!this.bFilePathInitialized)
                {
                    return("");
                }
                this.Initialize();
                uint num = this.IPToUInt32(IPValue);

                while (true)
                {
                    this.Search_Set = this.IndexInfoAtPos(this.Search_Index_Set);
                    this.Search_End = this.IndexInfoAtPos(this.Search_Index_End);
                    if (num >= this.Search_Set.IpSet && num <= this.Search_Set.IpEnd)
                    {
                        break;
                    }
                    if (num >= this.Search_End.IpSet && num <= this.Search_End.IpEnd)
                    {
                        goto Block_5;
                    }
                    this.Search_Mid = this.IndexInfoAtPos((this.Search_Index_End + this.Search_Index_Set) / 2u);
                    if (num >= this.Search_Mid.IpSet && num <= this.Search_Mid.IpEnd)
                    {
                        goto Block_7;
                    }
                    if (num < this.Search_Mid.IpSet)
                    {
                        this.Search_Index_End = (this.Search_Index_End + this.Search_Index_Set) / 2u;
                    }
                    else
                    {
                        this.Search_Index_Set = (this.Search_Index_End + this.Search_Index_Set) / 2u;
                    }
                }
                return(this.ReadAddressInfoAtOffset(this.Search_Set.Offset));

Block_5:
                return(this.ReadAddressInfoAtOffset(this.Search_End.Offset));

Block_7:
                return(this.ReadAddressInfoAtOffset(this.Search_Mid.Offset));
            }
Exemple #4
0
            /// <summary>
            /// 获取IP地址归属地
            /// </summary>
            /// <param name="IPValue">要查找的IP地址</param>
            /// <returns></returns>
            public string GetAddressWithIP(string IPValue)
            {
                if (!this.bFilePathInitialized)
                {
                    return("");
                }
                this.Initialize();
                uint num = this.IPToUInt32(IPValue);

                while (true)
                {
                    //首先初始化本轮查找的区间

                    //区间头
                    this.Search_Set = this.IndexInfoAtPos(this.Search_Index_Set);
                    //区间尾
                    this.Search_End = this.IndexInfoAtPos(this.Search_Index_End);

                    if ((num >= this.Search_Set.IpSet) && (num <= this.Search_Set.IpEnd))
                    {
                        return(this.ReadAddressInfoAtOffset(this.Search_Set.Offset));
                    }
                    if ((num >= this.Search_End.IpSet) && (num <= this.Search_End.IpEnd))
                    {
                        return(this.ReadAddressInfoAtOffset(this.Search_End.Offset));
                    }
                    this.Search_Mid = this.IndexInfoAtPos((this.Search_Index_End + this.Search_Index_Set) / 2);
                    if ((num >= this.Search_Mid.IpSet) && (num <= this.Search_Mid.IpEnd))
                    {
                        return(this.ReadAddressInfoAtOffset(this.Search_Mid.Offset));
                    }
                    if (num < this.Search_Mid.IpSet)
                    {
                        this.Search_Index_End = (this.Search_Index_End + this.Search_Index_Set) / 2;
                    }
                    else
                    {
                        this.Search_Index_Set = (this.Search_Index_End + this.Search_Index_Set) / 2;
                    }
                }
            }