update IP地址行政区域助手类重命名以匹配其工具类的功能定位

This commit is contained in:
秋辞未寒 2025-12-11 13:04:47 +08:00
parent cbe576ecfa
commit 455ec9a2f1
2 changed files with 6 additions and 6 deletions

View File

@ -37,7 +37,7 @@ public class AddressUtils {
return LOCAL_ADDRESS; return LOCAL_ADDRESS;
} }
// TipsIp2Region 提供了精简的IPv6地址库精简的IPv6地址库并不能完全支持IPv6地址的查询且准确度上可能会存在问题如需要准确的IPv6地址查询建议自行实现 // TipsIp2Region 提供了精简的IPv6地址库精简的IPv6地址库并不能完全支持IPv6地址的查询且准确度上可能会存在问题如需要准确的IPv6地址查询建议自行实现
return Ip2RegionHelper.getRegion(ip); return RegionUtils.getRegion(ip);
} }
} }

View File

@ -13,14 +13,14 @@ import java.io.File;
import java.time.Duration; import java.time.Duration;
/** /**
* IP地址行政区域助手工具类 * IP地址行政区域工具类
* 参考地址<a href="https://gitee.com/lionsoul/ip2region/tree/master/binding/java">ip2region xdb java 查询客户端实现</a> * 参考地址<a href="https://gitee.com/lionsoul/ip2region/tree/master/binding/java">ip2region xdb java 查询客户端实现</a>
* xdb数据库文件下载<a href="https://gitee.com/lionsoul/ip2region/tree/master/data">ip2region data</a> * xdb数据库文件下载<a href="https://gitee.com/lionsoul/ip2region/tree/master/data">ip2region data</a>
* *
* @author 秋辞未寒 * @author 秋辞未寒
*/ */
@Slf4j @Slf4j
public class Ip2RegionHelper { public class RegionUtils {
// 默认IPv4地址库文件路径 // 默认IPv4地址库文件路径
// 下载地址https://gitee.com/lionsoul/ip2region/blob/master/data/ip2region_v4.xdb // 下载地址https://gitee.com/lionsoul/ip2region/blob/master/data/ip2region_v4.xdb
@ -53,11 +53,11 @@ public class Ip2RegionHelper {
// Config v6Config = Config.custom() // Config v6Config = Config.custom()
// .setCachePolicy(Config.BufferCache) // .setCachePolicy(Config.BufferCache)
// .setXdbPath(v6TempXdb.getPath()) // .setXdbPath(v6TempXdb.getPath())
// .asV6(FileUtil.createRandomAccessFile(v6TempXdb, FileMode.r)); // .asV6();
// 初始化Ip2Region实例 // 初始化Ip2Region实例
Ip2RegionHelper.ip2Region = Ip2Region.create(v4Config, null); RegionUtils.ip2Region = Ip2Region.create(v4Config, null);
// Ip2RegionHelper.ip2Region = Ip2Region.create(v4Config, v6Config); // RegionUtils.ip2Region = Ip2Region.create(v4Config, v6Config);
// 删除临时文件 // 删除临时文件
// 注意因为使用的 CachePolicy BufferCacheBufferCache是加载整个xdb文件到内存中所以临时文件的删除不会影响到正常的使用如果使用的是 VIndexCache NoCache即实时读取文件删除临时文件会导致xdb数据库读取不到而无法使用 // 注意因为使用的 CachePolicy BufferCacheBufferCache是加载整个xdb文件到内存中所以临时文件的删除不会影响到正常的使用如果使用的是 VIndexCache NoCache即实时读取文件删除临时文件会导致xdb数据库读取不到而无法使用