add doh settings
This commit is contained in:
@@ -27,6 +27,21 @@ import 'package:nullability/nullability.dart';
|
||||
|
||||
part 'engine_settings.g.dart';
|
||||
|
||||
enum BuiltInDohProviders {
|
||||
quad9('Quad9', 'https://dns.quad9.net/dns-query'),
|
||||
mullvad('Mullvad', 'https://dns.mullvad.net/dns-query'),
|
||||
adguard('AdGuard', 'https://dns.adguard-dns.com/dns-query'),
|
||||
ffmuc('Freifunk München', 'https://doh.ffmuc.net/dns-query');
|
||||
|
||||
final String name;
|
||||
final String url;
|
||||
|
||||
static bool isBuiltin(String url) =>
|
||||
BuiltInDohProviders.values.any((provider) => provider.url == url);
|
||||
|
||||
const BuiltInDohProviders(this.name, this.url);
|
||||
}
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable(includeIfNull: true, constructor: 'withDefaults')
|
||||
class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
||||
@@ -66,6 +81,20 @@ class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
||||
@JsonKey(fromJson: _addonCollectionFromJson, toJson: _addonCollectionToJson)
|
||||
final AddonCollection? addonCollection;
|
||||
|
||||
final DohSettingsMode dohSettingsMode;
|
||||
final String dohProviderUrl;
|
||||
final String dohDefaultProviderUrl;
|
||||
final List<String> dohExceptionsList;
|
||||
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
DohSettings get dohSettings => DohSettings(
|
||||
dohSettingsMode: dohSettingsMode,
|
||||
dohProviderUrl: dohProviderUrl,
|
||||
dohDefaultProviderUrl: dohDefaultProviderUrl,
|
||||
dohExceptionsList: dohExceptionsList,
|
||||
);
|
||||
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
ContentBlocking get contentBlocking => ContentBlocking(
|
||||
@@ -92,6 +121,10 @@ class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
||||
required this.queryParameterStripping,
|
||||
required this.bounceTrackingProtectionMode,
|
||||
required this.addonCollection,
|
||||
required this.dohSettingsMode,
|
||||
required this.dohProviderUrl,
|
||||
required this.dohDefaultProviderUrl,
|
||||
required this.dohExceptionsList,
|
||||
});
|
||||
|
||||
EngineSettings.withDefaults({
|
||||
@@ -110,11 +143,20 @@ class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
||||
super.userAgent,
|
||||
bool? enterpriseRootsEnabled,
|
||||
this.addonCollection,
|
||||
DohSettingsMode? dohSettingsMode,
|
||||
String? dohProviderUrl,
|
||||
String? dohDefaultProviderUrl,
|
||||
List<String>? dohExceptionsList,
|
||||
}) : queryParameterStripping =
|
||||
queryParameterStripping ?? QueryParameterStripping.disabled,
|
||||
bounceTrackingProtectionMode =
|
||||
bounceTrackingProtectionMode ??
|
||||
BounceTrackingProtectionMode.disabled,
|
||||
dohSettingsMode = dohSettingsMode ?? DohSettingsMode.increased,
|
||||
dohProviderUrl = dohProviderUrl ?? BuiltInDohProviders.quad9.url,
|
||||
dohDefaultProviderUrl =
|
||||
dohDefaultProviderUrl ?? BuiltInDohProviders.quad9.url,
|
||||
dohExceptionsList = dohExceptionsList ?? [],
|
||||
super(
|
||||
javascriptEnabled: javascriptEnabled ?? true,
|
||||
trackingProtectionPolicy:
|
||||
@@ -155,5 +197,9 @@ class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
||||
queryParameterStripping,
|
||||
bounceTrackingProtectionMode,
|
||||
addonCollection,
|
||||
dohSettingsMode,
|
||||
dohProviderUrl,
|
||||
dohDefaultProviderUrl,
|
||||
dohExceptionsList,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -53,6 +53,14 @@ abstract class _$EngineSettingsCWProxy {
|
||||
|
||||
EngineSettings addonCollection(AddonCollection? addonCollection);
|
||||
|
||||
EngineSettings dohSettingsMode(DohSettingsMode dohSettingsMode);
|
||||
|
||||
EngineSettings dohProviderUrl(String dohProviderUrl);
|
||||
|
||||
EngineSettings dohDefaultProviderUrl(String dohDefaultProviderUrl);
|
||||
|
||||
EngineSettings dohExceptionsList(List<String> dohExceptionsList);
|
||||
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `EngineSettings(...).copyWith.fieldName(value)`.
|
||||
///
|
||||
@@ -76,6 +84,10 @@ abstract class _$EngineSettingsCWProxy {
|
||||
QueryParameterStripping queryParameterStripping,
|
||||
BounceTrackingProtectionMode bounceTrackingProtectionMode,
|
||||
AddonCollection? addonCollection,
|
||||
DohSettingsMode dohSettingsMode,
|
||||
String dohProviderUrl,
|
||||
String dohDefaultProviderUrl,
|
||||
List<String> dohExceptionsList,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -160,6 +172,22 @@ class _$EngineSettingsCWProxyImpl implements _$EngineSettingsCWProxy {
|
||||
EngineSettings addonCollection(AddonCollection? addonCollection) =>
|
||||
call(addonCollection: addonCollection);
|
||||
|
||||
@override
|
||||
EngineSettings dohSettingsMode(DohSettingsMode dohSettingsMode) =>
|
||||
call(dohSettingsMode: dohSettingsMode);
|
||||
|
||||
@override
|
||||
EngineSettings dohProviderUrl(String dohProviderUrl) =>
|
||||
call(dohProviderUrl: dohProviderUrl);
|
||||
|
||||
@override
|
||||
EngineSettings dohDefaultProviderUrl(String dohDefaultProviderUrl) =>
|
||||
call(dohDefaultProviderUrl: dohDefaultProviderUrl);
|
||||
|
||||
@override
|
||||
EngineSettings dohExceptionsList(List<String> dohExceptionsList) =>
|
||||
call(dohExceptionsList: dohExceptionsList);
|
||||
|
||||
@override
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `EngineSettings(...).copyWith.fieldName(value)`.
|
||||
@@ -186,6 +214,10 @@ class _$EngineSettingsCWProxyImpl implements _$EngineSettingsCWProxy {
|
||||
Object? queryParameterStripping = const $CopyWithPlaceholder(),
|
||||
Object? bounceTrackingProtectionMode = const $CopyWithPlaceholder(),
|
||||
Object? addonCollection = const $CopyWithPlaceholder(),
|
||||
Object? dohSettingsMode = const $CopyWithPlaceholder(),
|
||||
Object? dohProviderUrl = const $CopyWithPlaceholder(),
|
||||
Object? dohDefaultProviderUrl = const $CopyWithPlaceholder(),
|
||||
Object? dohExceptionsList = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return EngineSettings(
|
||||
javascriptEnabled: javascriptEnabled == const $CopyWithPlaceholder()
|
||||
@@ -263,6 +295,30 @@ class _$EngineSettingsCWProxyImpl implements _$EngineSettingsCWProxy {
|
||||
? _value.addonCollection
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: addonCollection as AddonCollection?,
|
||||
dohSettingsMode:
|
||||
dohSettingsMode == const $CopyWithPlaceholder() ||
|
||||
dohSettingsMode == null
|
||||
? _value.dohSettingsMode
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: dohSettingsMode as DohSettingsMode,
|
||||
dohProviderUrl:
|
||||
dohProviderUrl == const $CopyWithPlaceholder() ||
|
||||
dohProviderUrl == null
|
||||
? _value.dohProviderUrl
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: dohProviderUrl as String,
|
||||
dohDefaultProviderUrl:
|
||||
dohDefaultProviderUrl == const $CopyWithPlaceholder() ||
|
||||
dohDefaultProviderUrl == null
|
||||
? _value.dohDefaultProviderUrl
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: dohDefaultProviderUrl as String,
|
||||
dohExceptionsList:
|
||||
dohExceptionsList == const $CopyWithPlaceholder() ||
|
||||
dohExceptionsList == null
|
||||
? _value.dohExceptionsList
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: dohExceptionsList as List<String>,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -323,6 +379,15 @@ EngineSettings _$EngineSettingsFromJson(Map<String, dynamic> json) =>
|
||||
addonCollection: EngineSettings._addonCollectionFromJson(
|
||||
json['addonCollection'] as String?,
|
||||
),
|
||||
dohSettingsMode: $enumDecodeNullable(
|
||||
_$DohSettingsModeEnumMap,
|
||||
json['dohSettingsMode'],
|
||||
),
|
||||
dohProviderUrl: json['dohProviderUrl'] as String?,
|
||||
dohDefaultProviderUrl: json['dohDefaultProviderUrl'] as String?,
|
||||
dohExceptionsList: (json['dohExceptionsList'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$EngineSettingsToJson(
|
||||
@@ -355,6 +420,10 @@ Map<String, dynamic> _$EngineSettingsToJson(
|
||||
'addonCollection': EngineSettings._addonCollectionToJson(
|
||||
instance.addonCollection,
|
||||
),
|
||||
'dohSettingsMode': _$DohSettingsModeEnumMap[instance.dohSettingsMode]!,
|
||||
'dohProviderUrl': instance.dohProviderUrl,
|
||||
'dohDefaultProviderUrl': instance.dohDefaultProviderUrl,
|
||||
'dohExceptionsList': instance.dohExceptionsList,
|
||||
};
|
||||
|
||||
const _$TrackingProtectionPolicyEnumMap = {
|
||||
@@ -400,3 +469,10 @@ const _$BounceTrackingProtectionModeEnumMap = {
|
||||
BounceTrackingProtectionMode.enabledStandby: 'enabledStandby',
|
||||
BounceTrackingProtectionMode.enabledDryRun: 'enabledDryRun',
|
||||
};
|
||||
|
||||
const _$DohSettingsModeEnumMap = {
|
||||
DohSettingsMode.geckoDefault: 'geckoDefault',
|
||||
DohSettingsMode.increased: 'increased',
|
||||
DohSettingsMode.max: 'max',
|
||||
DohSettingsMode.off: 'off',
|
||||
};
|
||||
|
||||
@@ -98,6 +98,22 @@ class EngineSettingsRepository extends _$EngineSettingsRepository {
|
||||
DriftSqlType.string,
|
||||
db.typeMapping,
|
||||
),
|
||||
'dohSettingsMode': settings['dohSettingsMode']?.readAs(
|
||||
DriftSqlType.string,
|
||||
db.typeMapping,
|
||||
),
|
||||
'dohProviderUrl': settings['dohProviderUrl']?.readAs(
|
||||
DriftSqlType.string,
|
||||
db.typeMapping,
|
||||
),
|
||||
'dohDefaultProviderUrl': settings['dohDefaultProviderUrl']?.readAs(
|
||||
DriftSqlType.string,
|
||||
db.typeMapping,
|
||||
),
|
||||
'dohExceptionsList': settings['dohExceptionsList']?.readAs(
|
||||
DriftSqlType.string,
|
||||
db.typeMapping,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ final class EngineSettingsRepositoryProvider
|
||||
}
|
||||
|
||||
String _$engineSettingsRepositoryHash() =>
|
||||
r'f5e50bbfc707cdae698ac201d42e165bffc7615f';
|
||||
r'5e403757036edb4ef964b01cdcf96cbcbdc4d809';
|
||||
|
||||
abstract class _$EngineSettingsRepository
|
||||
extends $StreamNotifier<EngineSettings> {
|
||||
|
||||
Reference in New Issue
Block a user