mirror of
https://github.com/hiddify/hiddify-next.git
synced 2026-07-19 21:05:38 +08:00
feat(settings): move VPN sharing password to config options and exclude from export
This commit is contained in:
parent
d03318f7bf
commit
9de86aa4de
@ -1,4 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hiddify/core/app_info/app_info_provider.dart';
|
||||
import 'package:hiddify/core/model/environment.dart';
|
||||
@ -116,8 +116,6 @@ abstract class Preferences {
|
||||
static final psiphonConsentGiven = PreferencesNotifier.create<bool, bool>("psiphon-consent-given", false);
|
||||
|
||||
static final showRouteGeneralOptions = PreferencesNotifier.create<bool, bool>("show-route-general-options", true);
|
||||
|
||||
static final lanSharingPassword = PreferencesNotifier.create<String, String>("lan_sharing_password", "");
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
|
||||
@ -178,6 +178,8 @@ abstract class ConfigOptions {
|
||||
|
||||
static final allowConnectionFromLan = PreferencesNotifier.create<bool, bool>("allow-connection-from-lan", false);
|
||||
|
||||
static final lanSharingPassword = PreferencesNotifier.create<String, String>("lan_sharing_password", "");
|
||||
|
||||
static final enableFakeDns = PreferencesNotifier.create<bool, bool>("enable-fake-dns", false);
|
||||
|
||||
// static final enableDnsRouting = PreferencesNotifier.create<bool, bool>("enable-dns-routing", true);
|
||||
@ -342,7 +344,11 @@ abstract class ConfigOptions {
|
||||
});
|
||||
|
||||
/// preferences to exclude from share and export
|
||||
static final privatePreferencesKeys = {"extra-security.warp.license-key", "unblocker.warp.license-key"};
|
||||
static final privatePreferencesKeys = {
|
||||
"extra-security.warp.license-key",
|
||||
"unblocker.warp.license-key",
|
||||
"lan-sharing-password",
|
||||
};
|
||||
|
||||
static final Map<String, StateNotifierProvider<PreferencesNotifier, dynamic>> preferences = {
|
||||
"region": region,
|
||||
@ -373,6 +379,7 @@ abstract class ConfigOptions {
|
||||
"clash-api-port": clashApiPort,
|
||||
// "bypass-lan": bypassLan,
|
||||
"allow-connection-from-lan": allowConnectionFromLan,
|
||||
"lan-sharing-password": lanSharingPassword,
|
||||
// "enable-dns-routing": enableDnsRouting,
|
||||
|
||||
// mux
|
||||
@ -492,6 +499,7 @@ abstract class ConfigOptions {
|
||||
setSystemProxy: mode == ServiceMode.systemProxy,
|
||||
// bypassLan: ref.watch(bypassLan),
|
||||
allowConnectionFromLan: ref.watch(allowConnectionFromLan),
|
||||
lanSharingPassword: ref.watch(lanSharingPassword),
|
||||
enableFakeDns: ref.watch(enableFakeDns),
|
||||
// enableDnsRouting: ref.watch(enableDnsRouting),
|
||||
independentDnsCache: ref.watch(independentDnsCache),
|
||||
|
||||
@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/core/notification/in_app_notification_controller.dart';
|
||||
import 'package:hiddify/core/preferences/general_preferences.dart';
|
||||
import 'package:hiddify/core/router/dialog/dialog_notifier.dart';
|
||||
import 'package:hiddify/features/settings/data/config_option_repository.dart';
|
||||
import 'package:hiddify/hiddifycore/hiddify_core_service_provider.dart';
|
||||
@ -25,7 +24,7 @@ class LanSharingPreferenceWidget extends HookConsumerWidget {
|
||||
return null;
|
||||
}
|
||||
final port = ref.read(ConfigOptions.mixedPort);
|
||||
final password = ref.read(Preferences.lanSharingPassword);
|
||||
final password = ref.read(ConfigOptions.lanSharingPassword);
|
||||
if (password.isEmpty) {
|
||||
return 'socks://$ip:$port';
|
||||
} else {
|
||||
@ -40,9 +39,9 @@ class LanSharingPreferenceWidget extends HookConsumerWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
ref.watch(Preferences.lanSharingPassword).isEmpty
|
||||
ref.watch(ConfigOptions.lanSharingPassword).isEmpty
|
||||
? t.pages.settings.inbound.lanSharingPasswordNotSet
|
||||
: ref.watch(Preferences.lanSharingPassword),
|
||||
: ref.watch(ConfigOptions.lanSharingPassword),
|
||||
),
|
||||
if (ref.watch(ConfigOptions.allowConnectionFromLan)) ...[
|
||||
const Gap(12),
|
||||
@ -94,11 +93,11 @@ class LanSharingPreferenceWidget extends HookConsumerWidget {
|
||||
.read(dialogNotifierProvider.notifier)
|
||||
.showSettingInput(
|
||||
title: t.pages.settings.inbound.lanSharingPassword,
|
||||
initialValue: ref.read(Preferences.lanSharingPassword),
|
||||
onReset: ref.read(Preferences.lanSharingPassword.notifier).reset,
|
||||
initialValue: ref.read(ConfigOptions.lanSharingPassword),
|
||||
onReset: ref.read(ConfigOptions.lanSharingPassword.notifier).reset,
|
||||
);
|
||||
if (inputValue != null) {
|
||||
await ref.read(Preferences.lanSharingPassword.notifier).update(inputValue);
|
||||
await ref.read(ConfigOptions.lanSharingPassword.notifier).update(inputValue);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@ -47,6 +47,7 @@ class SingboxConfigOption with _$SingboxConfigOption {
|
||||
required bool setSystemProxy,
|
||||
// required bool bypassLan,
|
||||
required bool allowConnectionFromLan,
|
||||
required String lanSharingPassword,
|
||||
required bool enableFakeDns,
|
||||
// required bool enableDnsRouting,
|
||||
required bool independentDnsCache,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user