
What is Ip2region?
Ip2region v2.0 is an offline IP address location library and IP location data management framework, with query efficiency at the 10-microsecond level. It provides xdb data generation and query client implementations for many mainstream programming languages.
Application Scenarios
Ip2region is widely used in various scenarios that require IP address location. For example, it can detect and block attacks from IP addresses in certain regions or countries, and it can locate a user's specific geographic location based on their IP address. It can also perform data analysis and statistics based on the geographic information of IP addresses, such as counting the number of users in a specific region.
Features
1. Standardized Data Format
The region information for each IP segment has a fixed format: Country|Area|Province|City|ISP. Only Chinese data is mostly accurate down to the city level; for other countries, some data can only pinpoint the country, with subsequent fields all set to 0.
2. Data Deduplication and Compression
The xdb format generator automatically deduplicates and compresses some data. The default full IP data generates an ip2region.xdb database of about 11 MiB. As the data detail increases, the database size gradually grows.
3. Ultra-Fast Query Response
Even for queries based entirely on the xdb file, the response time for a single query is at the ten-microsecond level. Memory acceleration for queries can be enabled in two ways:
- vIndex cache: Uses a fixed 512 KiB memory space to cache the vector index data, reducing one disk IO operation and maintaining an average query efficiency stable between 10–20 microseconds.
- Full xdb file cache: Loads the entire xdb file into memory. Memory usage equals the xdb file size, with no disk IO, maintaining microsecond-level query efficiency.
4. IP Data Management Framework
The xdb format in v2.0 supports billions of IP data segment rows. The region information can be fully customized. For example, you can append data specific to business requirements in the region field, such as GPS information, international unified region codes, postal codes, etc. In short, you can fully use ip2region to manage your own IP location data.
How to Use in C#?
- Install the NuGet package IP2Region.Net.
Install-Package IP2Region.Net
- Use the API to query – it's very simple!
using IP2Region.Net.XDB;
Searcher searcher = new Searcher();
searcher.Search("IP address");
Dependency Injection
services.AddSingleton<ISearcher,Searcher>();
Performance
