mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 22:12:53 +00:00
Added cache config dns
This commit is contained in:
parent
44cd39026b
commit
45946ddc1a
4 changed files with 152 additions and 2 deletions
|
@ -453,5 +453,14 @@
|
||||||
"nullIp": "Null IP",
|
"nullIp": "Null IP",
|
||||||
"nullIpDescription": "Respond with zero IP address (0.0.0.0 for A; :: for AAAA)",
|
"nullIpDescription": "Respond with zero IP address (0.0.0.0 for A; :: for AAAA)",
|
||||||
"customIp": "Custom IP",
|
"customIp": "Custom IP",
|
||||||
"customIpDescription": "Respond with a manually set IP address"
|
"customIpDescription": "Respond with a manually set IP address",
|
||||||
|
"dnsCacheConfig": "DNS cache configuration",
|
||||||
|
"cacheSize": "Cache size",
|
||||||
|
"inBytes": "In bytes",
|
||||||
|
"overrideMinimumTtl": "Override minimum TTL",
|
||||||
|
"overrideMinimumTtlDescription": "Extend short time-to-live values (seconds) received from the upstream server when caching DNS responses.",
|
||||||
|
"overrideMaximumTtl": "Override maximum TTL",
|
||||||
|
"overrideMaximumTtlDescription": "Set a maximum time-to-live value (seconds) for entries in the DNS cache.",
|
||||||
|
"optimisticCaching": "Optimistic caching",
|
||||||
|
"optimisticCachingDescription": "Make AdGuard Home respond from the cache even when the entries are expired and also try to refresh them."
|
||||||
}
|
}
|
|
@ -453,5 +453,14 @@
|
||||||
"nullIp": "IP nula",
|
"nullIp": "IP nula",
|
||||||
"nullIpDescription": "Responde con dirección IP cero (0.0.0.0 para A; :: para AAAA)",
|
"nullIpDescription": "Responde con dirección IP cero (0.0.0.0 para A; :: para AAAA)",
|
||||||
"customIp": "IP personalizada",
|
"customIp": "IP personalizada",
|
||||||
"customIpDescription": "Responde con una dirección IP establecida manualmente."
|
"customIpDescription": "Responde con una dirección IP establecida manualmente.",
|
||||||
|
"dnsCacheConfig": "Configuración de la caché DNS",
|
||||||
|
"cacheSize": "Tamaño de la caché",
|
||||||
|
"inBytes": "En bytes",
|
||||||
|
"overrideMinimumTtl": "Anular TTL mínimo",
|
||||||
|
"overrideMinimumTtlDescription": "Amplía el corto tiempo de vida (segundos) de los valores recibidos del servidor DNS de subida al almacenar en caché las respuestas DNS.",
|
||||||
|
"overrideMaximumTtl": "Anular TTL máximo",
|
||||||
|
"overrideMaximumTtlDescription": "Establece un valor de tiempo de vida (segundos) máximo para las entradas en la caché DNS.",
|
||||||
|
"optimisticCaching": "Optimistic caching",
|
||||||
|
"optimisticCachingDescription": "Haz que AdGuard Home responda desde la caché incluso cuando las entradas estén expiradas y también intente actualizarlas."
|
||||||
}
|
}
|
119
lib/screens/settings/dns/cache_config.dart
Normal file
119
lib/screens/settings/dns/cache_config.dart
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
import 'package:adguard_home_manager/widgets/custom_switch_list_tile.dart';
|
||||||
|
|
||||||
|
class CacheConfigDnsScreen extends StatefulWidget {
|
||||||
|
const CacheConfigDnsScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CacheConfigDnsScreen> createState() => _CacheConfigDnsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CacheConfigDnsScreenState extends State<CacheConfigDnsScreen> {
|
||||||
|
final TextEditingController cacheSizeController = TextEditingController();
|
||||||
|
String? cacheSizeError;
|
||||||
|
|
||||||
|
final TextEditingController overrideMinTtlController = TextEditingController();
|
||||||
|
String? overrideMinTtlError;
|
||||||
|
|
||||||
|
final TextEditingController overrideMaxTtlController = TextEditingController();
|
||||||
|
String? overrideMaxTtlError;
|
||||||
|
|
||||||
|
bool optimisticCache = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
Widget numericField({
|
||||||
|
required TextEditingController controller,
|
||||||
|
required String label,
|
||||||
|
String? helper,
|
||||||
|
String? error,
|
||||||
|
required void Function(String) onChanged,
|
||||||
|
}) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: overrideMinTtlController,
|
||||||
|
onChanged: onChanged,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
prefixIcon: const Icon(Icons.timer_rounded),
|
||||||
|
border: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(10)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
errorText: error,
|
||||||
|
helperText: helper,
|
||||||
|
helperMaxLines: 10,
|
||||||
|
labelText: label,
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(AppLocalizations.of(context)!.dnsCacheConfig),
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
padding: const EdgeInsets.only(top: 10),
|
||||||
|
children: [
|
||||||
|
numericField(
|
||||||
|
controller: cacheSizeController,
|
||||||
|
label: AppLocalizations.of(context)!.cacheSize,
|
||||||
|
helper: AppLocalizations.of(context)!.inBytes,
|
||||||
|
error: cacheSizeError,
|
||||||
|
onChanged: (value) {
|
||||||
|
if (int.tryParse(value) != null) {
|
||||||
|
setState(() => cacheSizeError = null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setState(() => cacheSizeError = AppLocalizations.of(context)!.valueNotNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
numericField(
|
||||||
|
controller: overrideMinTtlController,
|
||||||
|
label: AppLocalizations.of(context)!.overrideMinimumTtl,
|
||||||
|
helper: AppLocalizations.of(context)!.overrideMinimumTtlDescription,
|
||||||
|
error: overrideMinTtlError,
|
||||||
|
onChanged: (value) {
|
||||||
|
if (int.tryParse(value) != null) {
|
||||||
|
setState(() => overrideMinTtlError = null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setState(() => overrideMinTtlError = AppLocalizations.of(context)!.valueNotNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
numericField(
|
||||||
|
controller: overrideMaxTtlController,
|
||||||
|
label: AppLocalizations.of(context)!.overrideMaximumTtl,
|
||||||
|
helper: AppLocalizations.of(context)!.overrideMaximumTtlDescription,
|
||||||
|
error: overrideMaxTtlError,
|
||||||
|
onChanged: (value) {
|
||||||
|
if (int.tryParse(value) != null) {
|
||||||
|
setState(() => overrideMaxTtlError = null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setState(() => overrideMaxTtlError = AppLocalizations.of(context)!.valueNotNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
CustomSwitchListTile(
|
||||||
|
value: optimisticCache,
|
||||||
|
onChanged: (value) => setState(() => optimisticCache = value),
|
||||||
|
title: AppLocalizations.of(context)!.optimisticCaching,
|
||||||
|
subtitle: AppLocalizations.of(context)!.optimisticCachingDescription,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
import 'package:adguard_home_manager/screens/settings/dns/cache_config.dart';
|
||||||
import 'package:adguard_home_manager/screens/settings/dns/dns_server_settings.dart';
|
import 'package:adguard_home_manager/screens/settings/dns/dns_server_settings.dart';
|
||||||
import 'package:adguard_home_manager/screens/settings/dns/bootstrap_dns.dart';
|
import 'package:adguard_home_manager/screens/settings/dns/bootstrap_dns.dart';
|
||||||
import 'package:adguard_home_manager/screens/settings/dns/private_reverse_servers.dart';
|
import 'package:adguard_home_manager/screens/settings/dns/private_reverse_servers.dart';
|
||||||
|
@ -65,6 +66,18 @@ class DnsSettings extends StatelessWidget {
|
||||||
builder: (context) => const DnsServerSettingsScreen()
|
builder: (context) => const DnsServerSettingsScreen()
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
AppLocalizations.of(context)!.dnsCacheConfig,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.normal
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () => Navigator.push(context, MaterialPageRoute(
|
||||||
|
builder: (context) => const CacheConfigDnsScreen()
|
||||||
|
)),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue