Optimize app logic
Support windows administrator auto launch Support android close vpn
This commit is contained in:
@@ -10,50 +10,22 @@ class Proxy extends ProxyPlatform {
|
||||
|
||||
@override
|
||||
Future<bool?> startProxy(int port) async {
|
||||
bool? isStart = false;
|
||||
switch (Platform.operatingSystem) {
|
||||
case "macos":
|
||||
isStart = await _startProxyWithMacos(port);
|
||||
break;
|
||||
case "linux":
|
||||
isStart = await _startProxyWithLinux(port);
|
||||
break;
|
||||
case "windows":
|
||||
isStart = await ProxyPlatform.instance.startProxy(port);
|
||||
break;
|
||||
}
|
||||
if (isStart == true) {
|
||||
startTime = DateTime.now();
|
||||
}
|
||||
return isStart;
|
||||
return switch (Platform.operatingSystem) {
|
||||
"macos" => await _startProxyWithMacos(port),
|
||||
"linux" => await _startProxyWithLinux(port),
|
||||
"windows" => await ProxyPlatform.instance.startProxy(port),
|
||||
String() => false,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool?> stopProxy() async {
|
||||
bool? isStop = false;
|
||||
switch (Platform.operatingSystem) {
|
||||
case "macos":
|
||||
isStop = await _stopProxyWithMacos();
|
||||
break;
|
||||
case "linux":
|
||||
isStop = await _stopProxyWithLinux();
|
||||
break;
|
||||
case "windows":
|
||||
isStop = await ProxyPlatform.instance.stopProxy();
|
||||
break;
|
||||
}
|
||||
if (isStop == true) {
|
||||
startTime = null;
|
||||
}
|
||||
return isStop;
|
||||
}
|
||||
|
||||
@override
|
||||
get startTime => ProxyPlatform.instance.startTime;
|
||||
|
||||
@override
|
||||
set startTime(DateTime? dateTime) {
|
||||
ProxyPlatform.instance.startTime = dateTime;
|
||||
return switch (Platform.operatingSystem) {
|
||||
"macos" => await _stopProxyWithMacos(),
|
||||
"linux" => await _stopProxyWithLinux(),
|
||||
"windows" => await ProxyPlatform.instance.stopProxy(),
|
||||
String() => false,
|
||||
};
|
||||
}
|
||||
|
||||
Future<bool> _startProxyWithLinux(int port) async {
|
||||
@@ -205,4 +177,3 @@ class Proxy extends ProxyPlatform {
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,6 @@ class MethodChannelProxy extends ProxyPlatform {
|
||||
|
||||
@override
|
||||
Future<bool?> stopProxy() async {
|
||||
final isStop = await methodChannel.invokeMethod<bool>("StopProxy");
|
||||
if (isStop == true) {
|
||||
startTime = null;
|
||||
}
|
||||
return isStop;
|
||||
return await methodChannel.invokeMethod<bool>("StopProxy");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ abstract class ProxyPlatform extends PlatformInterface {
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
DateTime? startTime;
|
||||
|
||||
Future<bool?> startProxy(int port) {
|
||||
throw UnimplementedError('startProxy() has not been implemented.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user