Skip to content

Commit 9de86aa

Browse files
committed
feat(settings): move VPN sharing password to config options and exclude from export
1 parent d03318f commit 9de86aa

4 files changed

Lines changed: 17 additions & 11 deletions

File tree

lib/core/preferences/general_preferences.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:flutter/foundation.dart';
1+
import 'package:flutter/foundation.dart';
22
import 'package:flutter/material.dart';
33
import 'package:hiddify/core/app_info/app_info_provider.dart';
44
import 'package:hiddify/core/model/environment.dart';
@@ -116,8 +116,6 @@ abstract class Preferences {
116116
static final psiphonConsentGiven = PreferencesNotifier.create<bool, bool>("psiphon-consent-given", false);
117117

118118
static final showRouteGeneralOptions = PreferencesNotifier.create<bool, bool>("show-route-general-options", true);
119-
120-
static final lanSharingPassword = PreferencesNotifier.create<String, String>("lan_sharing_password", "");
121119
}
122120

123121
@Riverpod(keepAlive: true)

lib/features/settings/data/config_option_repository.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ abstract class ConfigOptions {
178178

179179
static final allowConnectionFromLan = PreferencesNotifier.create<bool, bool>("allow-connection-from-lan", false);
180180

181+
static final lanSharingPassword = PreferencesNotifier.create<String, String>("lan_sharing_password", "");
182+
181183
static final enableFakeDns = PreferencesNotifier.create<bool, bool>("enable-fake-dns", false);
182184

183185
// static final enableDnsRouting = PreferencesNotifier.create<bool, bool>("enable-dns-routing", true);
@@ -342,7 +344,11 @@ abstract class ConfigOptions {
342344
});
343345

344346
/// preferences to exclude from share and export
345-
static final privatePreferencesKeys = {"extra-security.warp.license-key", "unblocker.warp.license-key"};
347+
static final privatePreferencesKeys = {
348+
"extra-security.warp.license-key",
349+
"unblocker.warp.license-key",
350+
"lan-sharing-password",
351+
};
346352

347353
static final Map<String, StateNotifierProvider<PreferencesNotifier, dynamic>> preferences = {
348354
"region": region,
@@ -373,6 +379,7 @@ abstract class ConfigOptions {
373379
"clash-api-port": clashApiPort,
374380
// "bypass-lan": bypassLan,
375381
"allow-connection-from-lan": allowConnectionFromLan,
382+
"lan-sharing-password": lanSharingPassword,
376383
// "enable-dns-routing": enableDnsRouting,
377384

378385
// mux
@@ -492,6 +499,7 @@ abstract class ConfigOptions {
492499
setSystemProxy: mode == ServiceMode.systemProxy,
493500
// bypassLan: ref.watch(bypassLan),
494501
allowConnectionFromLan: ref.watch(allowConnectionFromLan),
502+
lanSharingPassword: ref.watch(lanSharingPassword),
495503
enableFakeDns: ref.watch(enableFakeDns),
496504
// enableDnsRouting: ref.watch(enableDnsRouting),
497505
independentDnsCache: ref.watch(independentDnsCache),

lib/features/settings/widget/lan_sharing_tile.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
33
import 'package:gap/gap.dart';
44
import 'package:hiddify/core/localization/translations.dart';
55
import 'package:hiddify/core/notification/in_app_notification_controller.dart';
6-
import 'package:hiddify/core/preferences/general_preferences.dart';
76
import 'package:hiddify/core/router/dialog/dialog_notifier.dart';
87
import 'package:hiddify/features/settings/data/config_option_repository.dart';
98
import 'package:hiddify/hiddifycore/hiddify_core_service_provider.dart';
@@ -25,7 +24,7 @@ class LanSharingPreferenceWidget extends HookConsumerWidget {
2524
return null;
2625
}
2726
final port = ref.read(ConfigOptions.mixedPort);
28-
final password = ref.read(Preferences.lanSharingPassword);
27+
final password = ref.read(ConfigOptions.lanSharingPassword);
2928
if (password.isEmpty) {
3029
return 'socks://$ip:$port';
3130
} else {
@@ -40,9 +39,9 @@ class LanSharingPreferenceWidget extends HookConsumerWidget {
4039
crossAxisAlignment: CrossAxisAlignment.start,
4140
children: [
4241
Text(
43-
ref.watch(Preferences.lanSharingPassword).isEmpty
42+
ref.watch(ConfigOptions.lanSharingPassword).isEmpty
4443
? t.pages.settings.inbound.lanSharingPasswordNotSet
45-
: ref.watch(Preferences.lanSharingPassword),
44+
: ref.watch(ConfigOptions.lanSharingPassword),
4645
),
4746
if (ref.watch(ConfigOptions.allowConnectionFromLan)) ...[
4847
const Gap(12),
@@ -94,11 +93,11 @@ class LanSharingPreferenceWidget extends HookConsumerWidget {
9493
.read(dialogNotifierProvider.notifier)
9594
.showSettingInput(
9695
title: t.pages.settings.inbound.lanSharingPassword,
97-
initialValue: ref.read(Preferences.lanSharingPassword),
98-
onReset: ref.read(Preferences.lanSharingPassword.notifier).reset,
96+
initialValue: ref.read(ConfigOptions.lanSharingPassword),
97+
onReset: ref.read(ConfigOptions.lanSharingPassword.notifier).reset,
9998
);
10099
if (inputValue != null) {
101-
await ref.read(Preferences.lanSharingPassword.notifier).update(inputValue);
100+
await ref.read(ConfigOptions.lanSharingPassword.notifier).update(inputValue);
102101
}
103102
},
104103
);

lib/singbox/model/singbox_config_option.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class SingboxConfigOption with _$SingboxConfigOption {
4747
required bool setSystemProxy,
4848
// required bool bypassLan,
4949
required bool allowConnectionFromLan,
50+
required String lanSharingPassword,
5051
required bool enableFakeDns,
5152
// required bool enableDnsRouting,
5253
required bool independentDnsCache,

0 commit comments

Comments
 (0)