new: add seperated VPN service mode

This commit is contained in:
Hiddify
2024-02-14 15:51:58 +01:00
parent 930959baf7
commit 382f4c7d5e
6 changed files with 19 additions and 13 deletions

View File

@@ -214,7 +214,8 @@
"serviceModes": { "serviceModes": {
"proxy": "Proxy Service Only", "proxy": "Proxy Service Only",
"systemProxy": "Set System Proxy", "systemProxy": "Set System Proxy",
"tun": "VPN" "tun": "VPN",
"tunService": "VPN Service"
}, },
"section": { "section": {
"route": "Route Options", "route": "Route Options",

View File

@@ -191,6 +191,7 @@ class SingBoxConfigOptionRepositoryImpl
enableClashApi: persisted.enableClashApi, enableClashApi: persisted.enableClashApi,
clashApiPort: persisted.clashApiPort, clashApiPort: persisted.clashApiPort,
enableTun: persisted.serviceMode == ServiceMode.tun, enableTun: persisted.serviceMode == ServiceMode.tun,
enableTunService: persisted.serviceMode == ServiceMode.tunService,
setSystemProxy: persisted.serviceMode == ServiceMode.systemProxy, setSystemProxy: persisted.serviceMode == ServiceMode.systemProxy,
bypassLan: persisted.bypassLan, bypassLan: persisted.bypassLan,
allowConnectionFromLan: persisted.allowConnectionFromLan, allowConnectionFromLan: persisted.allowConnectionFromLan,

View File

@@ -159,11 +159,11 @@ class ConnectionRepositoryImpl
await $( await $(
TaskEither(() async { TaskEither(() async {
if (options.enableTun) { if (options.enableTun) {
// final hasPrivilege = await platformSource.checkPrivilege(); final hasPrivilege = await platformSource.checkPrivilege();
// if (!hasPrivilege) { if (!hasPrivilege) {
// loggy.warning("missing privileges for tun mode"); loggy.warning("missing privileges for tun mode");
// return left(const MissingPrivilege()); return left(const MissingPrivilege());
// } }
} }
return right(unit); return right(unit);
}), }),
@@ -192,11 +192,11 @@ class ConnectionRepositoryImpl
await $( await $(
TaskEither(() async { TaskEither(() async {
if (options.enableTun) { if (options.enableTun) {
// final hasPrivilege = await platformSource.checkPrivilege(); final hasPrivilege = await platformSource.checkPrivilege();
// if (!hasPrivilege) { if (!hasPrivilege) {
// loggy.warning("missing privileges for tun mode"); loggy.warning("missing privileges for tun mode");
// return left(const MissingPrivilege()); return left(const MissingPrivilege());
// } }
} }
return right(unit); return right(unit);
}), }),

View File

@@ -6,7 +6,8 @@ import 'package:json_annotation/json_annotation.dart';
enum ServiceMode { enum ServiceMode {
proxy("proxy"), proxy("proxy"),
systemProxy("system-proxy"), systemProxy("system-proxy"),
tun("vpn"); tun("vpn"),
tunService("vpnService");
const ServiceMode(this.key); const ServiceMode(this.key);
@@ -27,6 +28,8 @@ enum ServiceMode {
systemProxy => t.settings.config.serviceModes.systemProxy, systemProxy => t.settings.config.serviceModes.systemProxy,
tun => tun =>
"${t.settings.config.serviceModes.tun}${PlatformUtils.isDesktop ? " (${t.settings.experimental})" : ""}", "${t.settings.config.serviceModes.tun}${PlatformUtils.isDesktop ? " (${t.settings.experimental})" : ""}",
tunService =>
"${t.settings.config.serviceModes.tunService}${PlatformUtils.isDesktop ? " (${t.settings.experimental})" : ""}",
}; };
} }

View File

@@ -33,6 +33,7 @@ class SingboxConfigOption with _$SingboxConfigOption {
required bool enableClashApi, required bool enableClashApi,
required int clashApiPort, required int clashApiPort,
required bool enableTun, required bool enableTun,
required bool enableTunService,
required bool setSystemProxy, required bool setSystemProxy,
required bool bypassLan, required bool bypassLan,
required bool allowConnectionFromLan, required bool allowConnectionFromLan,

View File

@@ -2,7 +2,7 @@
cd "\$(dirname "\$0")" cd "\$(dirname "\$0")"
export LD_LIBRARY_PATH=usr/lib export LD_LIBRARY_PATH=usr/lib
if [ $1 == "HiddifyService" ];then if [ "$1" == "HiddifyService" ];then
exec ./$@ exec ./$@
else else
exec ./$appName $@ exec ./$appName $@