public final class IpRegionUtils
extends java.lang.Object
Ported from api-gateway: com.tydic.newretail.util.IPUtils.ip2region().
Adapted for WebFlux: the entire xdb (11 MB) is loaded into memory once at class-loading
time via Searcher.newWithBuffer(byte[]), so subsequent searchRegion(String) calls
are purely in-memory and safe to call on Netty event-loop threads (no blocking file I/O).
Region result format (same as api-gateway): "国家|区域|省份|城市|ISP" e.g. "中国|0|北京市|北京市|电信"
| 限定符和类型 | 方法和说明 |
|---|---|
static java.lang.String |
parseCity(java.lang.String region)
Extract city name from region string (index 3 in pipe-delimited format).
|
static java.lang.String |
parseProvince(java.lang.String region)
Extract province name from region string (index 2 in pipe-delimited format).
|
static java.lang.String |
searchRegion(java.lang.String ip)
Look up the region for the given IP address.
|
public static java.lang.String searchRegion(java.lang.String ip)
Result format: "国家|区域|省份|城市|ISP" e.g. "中国|0|北京市|北京市|电信"
ip - the IPv4 address string"" if lookup fails or xdb not loadedpublic static java.lang.String parseProvince(java.lang.String region)
region - region string e.g. "中国|0|北京市|北京市|电信""" if not availablepublic static java.lang.String parseCity(java.lang.String region)
region - region string e.g. "中国|0|北京市|北京市|电信""" if not availableCopyright © 2026 The Apache Software Foundation. All rights reserved.