package cn.reghao.tnb.search.esapp.log.geoip;

/**
 * @author reghao
 * @date 2025-03-12 17:16:31
 */
public class GeoIpTool {
    private final String geoipPath;
    private IPLocation ipLocation;

    public GeoIpTool(String geoipPath) throws Exception {
        this.geoipPath =geoipPath;
        this.ipLocation = new IPLocation(geoipPath);
    }

    public void reload() throws Exception {
        this.ipLocation = new IPLocation(geoipPath);
    }

    public Location getLocation(String ip) {
        return ipLocation.fetchIPLocation(ip);
    }
}
