新增(移动)一些应该放在“管理”形成列表管理,而非放在“设置”形成单一配置的内容
This commit is contained in:
@@ -13,12 +13,12 @@ import quant.rich.emoney.client.OkHttpClientProvider;
|
||||
import quant.rich.emoney.entity.config.ProxyConfig;
|
||||
import quant.rich.emoney.pojo.dto.IpInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Proxy;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
@Slf4j
|
||||
public class GeoIPUtil {
|
||||
@@ -28,16 +28,16 @@ public class GeoIPUtil {
|
||||
|
||||
static {
|
||||
try {
|
||||
cityReader = new DatabaseReader.Builder(new File("./conf/extra/GeoLite2-City.mmdb")).build();
|
||||
ClassPathResource geoLite2CityResource = new ClassPathResource("/conf/extra/GeoLite2-City.mmdb");
|
||||
cityReader = new DatabaseReader.Builder(geoLite2CityResource.getInputStream()).build();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("IP 地址库初始化失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
public static IpInfo getIpInfoThroughProxy(ProxyConfig proxyConfig) {
|
||||
ReentrantLock lock = CallerLockUtil.acquireLock();
|
||||
lock.lock();
|
||||
try {
|
||||
return CallerLockUtil.tryCallWithCallerLock(() -> {
|
||||
Proxy proxy = proxyConfig.getProxy();
|
||||
boolean ignoreHttpsVerification = proxyConfig.getIgnoreHttpsVerification();
|
||||
// OkHttp 客户端配置
|
||||
@@ -82,10 +82,7 @@ public class GeoIPUtil {
|
||||
log.warn("Proxy ipv6 error {}", e.getMessage());
|
||||
}
|
||||
return queryIpInfoGeoLite(ipInfo);
|
||||
}
|
||||
finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}, 100, proxyConfig).orElse(IpInfo.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user