|
@@ -36,6 +36,7 @@ class GlobalController extends GetxController {
|
|
|
var tunProxySwitchIng = false.obs;
|
|
|
bool allowStatusUpdate = false;
|
|
|
|
|
|
+
|
|
|
final selectedNode = Rx<NodeMode?>(null);
|
|
|
// 策略组
|
|
|
var proxieGroups = <ProxieProxiesItem>[].obs;
|
|
@@ -371,6 +372,9 @@ class GlobalController extends GetxController {
|
|
|
/// 打开代理
|
|
|
|
|
|
Future<void> openProxy() async {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
int? port = controllers.config.mixedPort.value;
|
|
|
if (port == 0) {
|
|
|
port = null;
|
|
@@ -383,38 +387,68 @@ class GlobalController extends GetxController {
|
|
|
if (mixedPort == 0) {
|
|
|
mixedPort = null;
|
|
|
}
|
|
|
-
|
|
|
port = port ?? mixedPort ?? 0;
|
|
|
if (port != 0) {
|
|
|
- await proxyManager.setAsSystemProxy(
|
|
|
- ProxyTypes.http,
|
|
|
- "127.0.0.1",
|
|
|
- port,
|
|
|
- );
|
|
|
- await proxyManager.setAsSystemProxy(
|
|
|
- ProxyTypes.https,
|
|
|
- "127.0.0.1",
|
|
|
- port,
|
|
|
- );
|
|
|
- systemProxy = true;
|
|
|
- }
|
|
|
- socksPort = socksPort ?? mixedPort ?? 0;
|
|
|
- if (socksPort != 0) {
|
|
|
- if (!Platform.isWindows) {
|
|
|
- await proxyManager.setAsSystemProxy(
|
|
|
- ProxyTypes.socks,
|
|
|
- "127.0.0.1",
|
|
|
- socksPort,
|
|
|
+ String loa = '127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*';
|
|
|
+ int? exitCode;
|
|
|
+ // Process sysproxy = await Process.start(Files.assetsSysProxyWin.path,,mode: ProcessStartMode.inheritStdio);
|
|
|
+ // sysproxy.exitCode.then((code) => exitCode = code);
|
|
|
+ try {
|
|
|
+ await Process.run(
|
|
|
+ Files.assetsSysProxyWin.path,
|
|
|
+ ['global','127.0.0.1:$port',loa],
|
|
|
+ runInShell: true,
|
|
|
);
|
|
|
+ } on ProcessException catch (e) {
|
|
|
+ //.e('Failed to start $coreName: ${e.message}');
|
|
|
+ throw Exception('Failed to start sysproxy: ${e.message}');
|
|
|
}
|
|
|
- systemProxy = true;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //
|
|
|
+ // port = port ?? mixedPort ?? 0;
|
|
|
+ // if (port != 0) {
|
|
|
+ // await proxyManager.setAsSystemProxy(
|
|
|
+ // ProxyTypes.http,
|
|
|
+ // "127.0.0.1",
|
|
|
+ // port,
|
|
|
+ // );
|
|
|
+ // await proxyManager.setAsSystemProxy(
|
|
|
+ // ProxyTypes.https,
|
|
|
+ // "127.0.0.1",
|
|
|
+ // port,
|
|
|
+ // );
|
|
|
+ // systemProxy = true;
|
|
|
+ // }
|
|
|
+ // socksPort = socksPort ?? mixedPort ?? 0;
|
|
|
+ // if (socksPort != 0) {
|
|
|
+ // if (!Platform.isWindows) {
|
|
|
+ // await proxyManager.setAsSystemProxy(
|
|
|
+ // ProxyTypes.socks,
|
|
|
+ // "127.0.0.1",
|
|
|
+ // socksPort,
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // systemProxy = true;
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
/// 关闭代理
|
|
|
|
|
|
Future<void> closeProxy() async {
|
|
|
- proxyManager.cleanSystemProxy();
|
|
|
+ // proxyManager.cleanSystemProxy();
|
|
|
+ try {
|
|
|
+ await Process.run(
|
|
|
+ Files.assetsSysProxyWin.path,
|
|
|
+ ['set','1','','',''],
|
|
|
+ runInShell: true,
|
|
|
+ );
|
|
|
+ } on ProcessException catch (e) {
|
|
|
+ //.e('Failed to start $coreName: ${e.message}');
|
|
|
+ throw Exception('Failed to start sysproxy: ${e.message}');
|
|
|
+ }
|
|
|
systemProxy = false;
|
|
|
}
|
|
|
Future<void> stopAllCore() async {
|