mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
fix proxy
This commit is contained in:
@@ -17,7 +17,7 @@ import Flutter
|
||||
let proxyConfig = "\(host):\(port)"
|
||||
result(proxyConfig)
|
||||
} else {
|
||||
result("")
|
||||
result("no proxy")
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -125,16 +125,15 @@ class AppDio extends DioForNative {
|
||||
}
|
||||
|
||||
void setSystemProxy() {
|
||||
HttpOverrides.global = _ProxyHttpOverrides()
|
||||
..findProxy(Uri());
|
||||
HttpOverrides.global = _ProxyHttpOverrides()..findProxy(Uri());
|
||||
}
|
||||
|
||||
class _ProxyHttpOverrides extends HttpOverrides {
|
||||
String proxy = "DIRECT";
|
||||
|
||||
String findProxy(Uri uri) {
|
||||
var haveUserProxy = appdata.settings["proxy"] != null
|
||||
&& appdata.settings["proxy"].toString().isNotEmpty;
|
||||
var haveUserProxy = appdata.settings["proxy"] != null &&
|
||||
appdata.settings["proxy"].toString().removeAllBlank.isNotEmpty;
|
||||
if (!App.isLinux && !haveUserProxy) {
|
||||
var channel = const MethodChannel("pixes/proxy");
|
||||
channel.invokeMethod("getProxy").then((value) {
|
||||
@@ -158,6 +157,16 @@ class _ProxyHttpOverrides extends HttpOverrides {
|
||||
proxy = "PROXY ${appdata.settings["proxy"]}";
|
||||
}
|
||||
}
|
||||
// check validation
|
||||
if (proxy.startsWith("PROXY")) {
|
||||
var uri = proxy.replaceFirst("PROXY", "").removeAllBlank;
|
||||
if (!uri.startsWith("http")) {
|
||||
uri += "http://";
|
||||
}
|
||||
if (!uri.isURL) {
|
||||
return "DIRECT";
|
||||
}
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user