Compare commits

...

4 Commits

Author SHA1 Message Date
def d33db5bf5b Merge branch 'master' into add_copy_link_to_service_page 2024-03-01 15:00:52 +02:00
Inex Code b29ee2e90e fix: Misleading value of "Do not verify TLS"
continuous-integration/drone/push Build is passing Details
2024-03-01 11:16:53 +02:00
Inex Code 6611093f48 Merge pull request 'fix: Detect the situation when we have faulty link-local IPv6 records' (#473) from inex/fix-linklocal-ipv6 into master
continuous-integration/drone/push Build was killed Details
Reviewed-on: #473
Reviewed-by: NaiJi  <naiji@noreply.git.selfprivacy.org>
2024-03-01 11:14:24 +02:00
Inex Code 643020ebd7 fix: Detect the situation when we have faulty link-local IPv6 records 2024-03-01 11:54:27 +03:00
2 changed files with 46 additions and 4 deletions

View File

@ -37,13 +37,22 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
}
final List<DnsRecord> 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<DnsRecordsState> {
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<DnsRecordsState> {
emit(state.copyWith(dnsState: DnsRecordsStatus.refreshing));
final List<DnsRecord> 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<ApiConnectionRepository>().serverDomain;
await ProvidersController.currentDnsProvider!.removeDomainRecords(
@ -173,7 +215,7 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
domain: domain!,
);
await ProvidersController.currentDnsProvider!.createDomainRecords(
records: records,
records: records.where((final r) => r.content != null).toList(),
domain: domain,
);

View File

@ -40,9 +40,9 @@ class _DeveloperSettingsPageState extends State<DeveloperSettingsPage> {
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(