删除 EmoneyRequestConfig 和 ProxyConfig 设置,改为数据库(SQLite)配置。默认配置的设置和删除逻辑由
SQLite 触发器配置。
This commit is contained in:
@@ -24,7 +24,6 @@ import org.bouncycastle.util.encoders.Hex;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
@Slf4j
|
||||
|
||||
@@ -10,7 +10,7 @@ import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import quant.rich.emoney.client.OkHttpClientProvider;
|
||||
import quant.rich.emoney.entity.config.ProxyConfig;
|
||||
import quant.rich.emoney.entity.sqlite.ProxySetting;
|
||||
import quant.rich.emoney.pojo.dto.IpInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -36,10 +36,13 @@ public class GeoIPUtil {
|
||||
}
|
||||
|
||||
@Async
|
||||
public static IpInfo getIpInfoThroughProxy(ProxyConfig proxyConfig) {
|
||||
public static IpInfo getIpInfoThroughProxy(ProxySetting proxySetting) {
|
||||
if (proxySetting == null) {
|
||||
throw new RuntimeException("代理为空");
|
||||
}
|
||||
return CallerLockUtil.tryCallWithCallerLock(() -> {
|
||||
Proxy proxy = proxyConfig.getProxy();
|
||||
boolean ignoreHttpsVerification = proxyConfig.getIgnoreHttpsVerification();
|
||||
Proxy proxy = proxySetting.getProxy();
|
||||
boolean ignoreHttpsVerification = proxySetting.getIgnoreHttpsVerification();
|
||||
// OkHttp 客户端配置
|
||||
OkHttpClient client = OkHttpClientProvider.getInstance(
|
||||
proxy, ignoreHttpsVerification,
|
||||
@@ -82,7 +85,7 @@ public class GeoIPUtil {
|
||||
log.warn("Proxy ipv6 error {}", e.getMessage());
|
||||
}
|
||||
return queryIpInfoGeoLite(ipInfo);
|
||||
}, 100, proxyConfig).orElse(IpInfo.EMPTY);
|
||||
}, 100, proxySetting).orElse(IpInfo.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,25 +48,25 @@ public class SmartResourceResolver {
|
||||
Path externalPath = resolveExternalPath(relativePath);
|
||||
|
||||
if (externalPath != null && Files.exists(externalPath)) {
|
||||
log.debug("从外部文件系统加载资源: {}", externalPath);
|
||||
log.debug("Load resource externally: {}", externalPath);
|
||||
return Files.newInputStream(externalPath);
|
||||
}
|
||||
|
||||
// 否则回退到 classpath(JAR、WAR、IDE)
|
||||
InputStream in = SmartResourceResolver.class.getClassLoader().getResourceAsStream(relativePath);
|
||||
if (in != null) {
|
||||
log.debug("从 classpath 内部加载资源: {}", relativePath);
|
||||
log.debug("Load resource within internal classpath: {}", relativePath);
|
||||
return in;
|
||||
}
|
||||
|
||||
throw new FileNotFoundException("无法找到资源: " + relativePath);
|
||||
throw new FileNotFoundException("Cannot find resources: " + relativePath);
|
||||
}
|
||||
|
||||
public static void saveText(String relativePath, String content) throws IOException {
|
||||
Path outputPath = resolveExternalPath(relativePath);
|
||||
Files.createDirectories(outputPath.getParent()); // 确保目录存在
|
||||
Files.writeString(outputPath, content, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
log.debug("写入外部资源文件成功: {}", outputPath);
|
||||
log.debug("Write resources externally success: {}", outputPath);
|
||||
}
|
||||
|
||||
private static Path resolveExternalPath(String relativePath) {
|
||||
|
||||
Reference in New Issue
Block a user