mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 17:39:42 +00:00
Merge pull request 'fix: Detect the situation when we have faulty link-local IPv6 records' (#473) from inex/fix-linklocal-ipv6 into master
Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/473 Reviewed-by: NaiJi ✨ <naiji@noreply.git.selfprivacy.org>
This commit is contained in:
commit
6611093f48
|
@ -37,13 +37,22 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<DnsRecord> allDnsRecords = await api.getDnsRecords();
|
final List<DnsRecord> allDnsRecords = await api.getDnsRecords();
|
||||||
allDnsRecords.removeWhere((final record) => record.type == 'AAAA');
|
|
||||||
final foundRecords = await validateDnsRecords(
|
final foundRecords = await validateDnsRecords(
|
||||||
domain,
|
domain,
|
||||||
extractDkimRecord(allDnsRecords)?.content ?? '',
|
extractDkimRecord(allDnsRecords)?.content ?? '',
|
||||||
allDnsRecords,
|
allDnsRecords,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!foundRecords.success && foundRecords.message == 'link-local') {
|
||||||
|
emit(
|
||||||
|
DnsRecordsState(
|
||||||
|
dnsState: DnsRecordsStatus.error,
|
||||||
|
dnsRecords: foundRecords.data,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!foundRecords.success || foundRecords.data.isEmpty) {
|
if (!foundRecords.success || foundRecords.data.isEmpty) {
|
||||||
emit(const DnsRecordsState());
|
emit(const DnsRecordsState());
|
||||||
return;
|
return;
|
||||||
|
@ -140,6 +149,17 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
|
||||||
message: e.toString(),
|
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(
|
return GenericResult(
|
||||||
data: foundRecords,
|
data: foundRecords,
|
||||||
success: true,
|
success: true,
|
||||||
|
@ -166,6 +186,28 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
|
||||||
emit(state.copyWith(dnsState: DnsRecordsStatus.refreshing));
|
emit(state.copyWith(dnsState: DnsRecordsStatus.refreshing));
|
||||||
final List<DnsRecord> records = await api.getDnsRecords();
|
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?
|
/// TODO: Error handling?
|
||||||
final ServerDomain? domain = getIt<ApiConnectionRepository>().serverDomain;
|
final ServerDomain? domain = getIt<ApiConnectionRepository>().serverDomain;
|
||||||
await ProvidersController.currentDnsProvider!.removeDomainRecords(
|
await ProvidersController.currentDnsProvider!.removeDomainRecords(
|
||||||
|
@ -173,7 +215,7 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
|
||||||
domain: domain!,
|
domain: domain!,
|
||||||
);
|
);
|
||||||
await ProvidersController.currentDnsProvider!.createDomainRecords(
|
await ProvidersController.currentDnsProvider!.createDomainRecords(
|
||||||
records: records,
|
records: records.where((final r) => r.content != null).toList(),
|
||||||
domain: domain,
|
domain: domain,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue