Fix service mode
This commit is contained in:
@@ -48,6 +48,20 @@ class PreferencesVersion1Migration extends PreferencesMigrationStep
|
||||
|
||||
@override
|
||||
Future<void> migrate() async {
|
||||
if (sharedPreferences.getString("service-mode")
|
||||
case final String serviceMode) {
|
||||
final newMode = switch (serviceMode) {
|
||||
"proxy" || "system-proxy" || "vpn" => serviceMode,
|
||||
"systemProxy" => "system-proxy",
|
||||
"tun" => "vpn",
|
||||
_ => PlatformUtils.isDesktop ? "system-proxy" : "vpn",
|
||||
};
|
||||
loggy.debug(
|
||||
"changing service-mode from [$serviceMode] to [$newMode]",
|
||||
);
|
||||
await sharedPreferences.setString("service-mode", newMode);
|
||||
}
|
||||
|
||||
if (sharedPreferences.getString("ipv6-mode") case final String ipv6Mode) {
|
||||
loggy.debug(
|
||||
"changing ipv6-mode from [$ipv6Mode] to [${_ipv6Mapper(ipv6Mode)}]",
|
||||
|
||||
@@ -2,10 +2,15 @@ import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/utils/platform_utils.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
@JsonEnum(valueField: 'key')
|
||||
enum ServiceMode {
|
||||
proxy,
|
||||
systemProxy,
|
||||
tun;
|
||||
proxy("proxy"),
|
||||
systemProxy("system-proxy"),
|
||||
tun("vpn");
|
||||
|
||||
const ServiceMode(this.key);
|
||||
|
||||
final String key;
|
||||
|
||||
static ServiceMode get defaultMode =>
|
||||
PlatformUtils.isDesktop ? systemProxy : tun;
|
||||
|
||||
Reference in New Issue
Block a user