Skip to content

Commit

Permalink
include app configs before validaing proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Aug 7, 2024
1 parent 599a2dd commit bf4213f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/features/config_option/overview/config_options_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,14 @@ class ConfigOptionsPage extends HookConsumerWidget {
digitsOnly: true,
inputToValue: int.tryParse,
),
const Gap(24),

SwitchListTile(
title: Text(experimental(t.config.useXrayCoreWhenPossible.Label)),
subtitle: Text(t.config.useXrayCoreWhenPossible.Description),
value: ref.watch(ConfigOptions.useXrayCoreWhenPossible),
onChanged: ref.watch(ConfigOptions.useXrayCoreWhenPossible.notifier).update,
),
const Gap(24),
],
),
),
Expand Down
9 changes: 7 additions & 2 deletions lib/features/profile/data/profile_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ class ProfileRepositoryImpl with ExceptionHandler, InfraLogger implements Profil
bool debug,
) {
return exceptionHandler(
() {
() async {
singbox.changeOptions(await configOptionRepository.getConfigOptions()).run();

return singbox.validateConfigByPath(path, tempPath, debug).mapLeft(ProfileFailure.invalidConfig).run();
},
ProfileUnexpectedFailure.new,
Expand Down Expand Up @@ -276,7 +278,7 @@ class ProfileRepositoryImpl with ExceptionHandler, InfraLogger implements Profil
return TaskEither<ProfileFailure, String>.Do(
($) async {
final configFile = profilePathResolver.file(id);
// TODO pass options

final options = await configOptionRepository.getConfigOptions();

singbox.changeOptions(options).mapLeft(InvalidConfigOption.new).run();
Expand Down Expand Up @@ -394,10 +396,13 @@ class ProfileRepositoryImpl with ExceptionHandler, InfraLogger implements Profil
final tempFile = profilePathResolver.tempFile(fileName);

try {
final configs = await configOptionRepository.getConfigOptions();

final response = await httpClient.download(
url.trim(),
tempFile.path,
cancelToken: cancelToken,
userAgent: configs.useXrayCoreWhenPossible ? "v2rayNG/1.8.23" : null,
);
final headers = await _populateHeaders(response.headers.map, tempFile.path);
return await validateConfig(file.path, tempFile.path, false)
Expand Down
2 changes: 1 addition & 1 deletion libcore

0 comments on commit bf4213f

Please sign in to comment.