mirror of
https://github.com/octopusYan/alist-gui.git
synced 2024-11-22 03:56:42 +08:00
pref: 获取系统网络代理设置
This commit is contained in:
parent
b1218e9122
commit
956f7fd7ba
9
pom.xml
9
pom.xml
@ -57,15 +57,6 @@
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- java 网络代理查找库-->
|
||||
<!-- https://github.com/MarkusBernhardt/proxy-vole -->
|
||||
<!-- https://mvnrepository.com/artifact/org.bidib.com.github.markusbernhardt/proxy-vole -->
|
||||
<dependency>
|
||||
<groupId>org.bidib.com.github.markusbernhardt</groupId>
|
||||
<artifactId>proxy-vole</artifactId>
|
||||
<version>1.1.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- slf4j -->
|
||||
<!-- https://slf4j.org/manual.html -->
|
||||
<dependency>
|
||||
|
@ -132,10 +132,13 @@ public class ConfigManager {
|
||||
public static void proxySetup(ProxySetup setup) {
|
||||
guiConfig.setProxySetup(setup.getName());
|
||||
|
||||
if (ProxySetup.NO_PROXY.equals(setup)) {
|
||||
HttpUtil.getInstance().clearProxy();
|
||||
} else if (hasProxy()) {
|
||||
HttpUtil.getInstance().proxy(setup, ConfigManager.getProxyInfo());
|
||||
switch (setup) {
|
||||
case NO_PROXY -> HttpUtil.getInstance().clearProxy();
|
||||
case SYSTEM, MANUAL -> {
|
||||
if (ProxySetup.MANUAL.equals(setup) && !hasProxy())
|
||||
return;
|
||||
HttpUtil.getInstance().proxy(setup, ConfigManager.getProxyInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,10 @@ import java.util.concurrent.Executor;
|
||||
@Data
|
||||
public class HttpConfig {
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpConfig.class);
|
||||
static {
|
||||
// 使用系统默认代理
|
||||
System.setProperty("java.net.useSystemProxies", "true");
|
||||
}
|
||||
/**
|
||||
* http版本
|
||||
*/
|
||||
@ -86,12 +90,12 @@ public class HttpConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
|
||||
public void checkClientTrusted(X509Certificate[] arg0, String arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
|
||||
public void checkServerTrusted(X509Certificate[] arg0, String arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}};
|
||||
|
@ -4,8 +4,8 @@ import cn.octopusyan.alistgui.enums.ProxySetup;
|
||||
import cn.octopusyan.alistgui.model.ProxyInfo;
|
||||
import cn.octopusyan.alistgui.util.JsonUtil;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.github.markusbernhardt.proxy.ProxySearch;
|
||||
import com.github.markusbernhardt.proxy.selector.misc.BufferedProxySelector;
|
||||
//import com.github.markusbernhardt.proxy.ProxySearch;
|
||||
//import com.github.markusbernhardt.proxy.selector.misc.BufferedProxySelector;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
@ -29,19 +29,6 @@ public class HttpUtil {
|
||||
private volatile static HttpUtil util;
|
||||
private volatile HttpClient httpClient;
|
||||
private final HttpConfig httpConfig;
|
||||
public static final ProxySearch proxySearch = ProxySearch.getDefaultProxySearch();
|
||||
|
||||
static {
|
||||
proxySearch.addStrategy(ProxySearch.Strategy.WIN);
|
||||
proxySearch.addStrategy(ProxySearch.Strategy.OS_DEFAULT);
|
||||
proxySearch.addStrategy(ProxySearch.Strategy.IE);
|
||||
proxySearch.addStrategy(ProxySearch.Strategy.FIREFOX);
|
||||
proxySearch.addStrategy(ProxySearch.Strategy.JAVA);
|
||||
// PAC 代理查询
|
||||
proxySearch.setPacCacheSettings(20, 1000 * 60 * 10, BufferedProxySelector.CacheScope.CACHE_SCOPE_HOST);
|
||||
// 设置系统默认代理
|
||||
ProxySelector.setDefault(proxySearch.getProxySelector());
|
||||
}
|
||||
|
||||
private HttpUtil(HttpConfig httpConfig) {
|
||||
this.httpConfig = httpConfig;
|
||||
|
@ -15,7 +15,6 @@ module cn.octopusyan.alistgui {
|
||||
requires com.fasterxml.jackson.databind;
|
||||
requires com.fasterxml.jackson.dataformat.yaml;
|
||||
requires atlantafx.base;
|
||||
requires proxy.vole;
|
||||
|
||||
exports cn.octopusyan.alistgui;
|
||||
opens cn.octopusyan.alistgui to javafx.fxml;
|
||||
|
Loading…
Reference in New Issue
Block a user