diff --git a/lib/logic/cubit/dns_records/dns_records_cubit.dart b/lib/logic/cubit/dns_records/dns_records_cubit.dart index cdb4e9b1..1b682dea 100644 --- a/lib/logic/cubit/dns_records/dns_records_cubit.dart +++ b/lib/logic/cubit/dns_records/dns_records_cubit.dart @@ -37,13 +37,22 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit { } final List allDnsRecords = await api.getDnsRecords(); - allDnsRecords.removeWhere((final record) => record.type == 'AAAA'); final foundRecords = await validateDnsRecords( domain, extractDkimRecord(allDnsRecords)?.content ?? '', allDnsRecords, ); + if (!foundRecords.success && foundRecords.message == 'link-local') { + emit( + DnsRecordsState( + dnsState: DnsRecordsStatus.error, + dnsRecords: foundRecords.data, + ), + ); + return; + } + if (!foundRecords.success || foundRecords.data.isEmpty) { emit(const DnsRecordsState()); return; @@ -140,6 +149,17 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit { message: e.toString(), ); } + // If providerDnsRecords contains a link-local ipv6 record, return an error + if (providerDnsRecords.any( + (final r) => + r.type == 'AAAA' && (r.content?.trim().startsWith('fe80::') ?? false), + )) { + return GenericResult( + data: foundRecords, + success: false, + message: 'link-local', + ); + } return GenericResult( data: foundRecords, success: true, @@ -166,6 +186,28 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit { emit(state.copyWith(dnsState: DnsRecordsStatus.refreshing)); final List records = await api.getDnsRecords(); + // If there are explicit link-local ipv6 records, remove them from the list + records.removeWhere( + (final r) => + r.type == 'AAAA' && (r.content?.trim().startsWith('fe80::') ?? false), + ); + + // If there are no AAAA records, make empty copies of A records + if (!records.any((final r) => r.type == 'AAAA')) { + final recordsToAdd = records + .where((final r) => r.type == 'A') + .map( + (final r) => DnsRecord( + name: r.name, + type: 'AAAA', + content: null, + ), + ) + .toList(); + records.addAll(recordsToAdd); + } + + /// TODO: Error handling? final ServerDomain? domain = getIt().serverDomain; await ProvidersController.currentDnsProvider!.removeDomainRecords( @@ -173,7 +215,7 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit { domain: domain!, ); await ProvidersController.currentDnsProvider!.createDomainRecords( - records: records, + records: records.where((final r) => r.content != null).toList(), domain: domain, ); diff --git a/lib/ui/pages/more/app_settings/developer_settings.dart b/lib/ui/pages/more/app_settings/developer_settings.dart index cd1c6811..46149e15 100644 --- a/lib/ui/pages/more/app_settings/developer_settings.dart +++ b/lib/ui/pages/more/app_settings/developer_settings.dart @@ -40,9 +40,9 @@ class _DeveloperSettingsPageState extends State { SwitchListTile( title: Text('developer_settings.ignore_tls'.tr()), subtitle: Text('developer_settings.ignore_tls_description'.tr()), - value: TlsOptions.verifyCertificate, + value: !TlsOptions.verifyCertificate, onChanged: (final bool value) => setState( - () => TlsOptions.verifyCertificate = value, + () => TlsOptions.verifyCertificate = !value, ), ), SwitchListTile(