fix: Remove unneded DNS check depending on CLOUDFLARE

pull/212/head
NaiJi ✨ 2023-06-05 11:18:41 -03:00
parent a690fb5089
commit 29cbf702e5
1 changed files with 13 additions and 40 deletions

View File

@ -23,7 +23,6 @@ import 'package:selfprivacy/logic/models/hive/server_domain.dart';
import 'package:selfprivacy/logic/models/hive/user.dart';
import 'package:selfprivacy/logic/models/json/device_token.dart';
import 'package:selfprivacy/logic/models/json/dns_records.dart';
import 'package:selfprivacy/logic/models/message.dart';
import 'package:selfprivacy/logic/models/server_basic_info.dart';
import 'package:selfprivacy/logic/models/server_type.dart';
import 'package:selfprivacy/ui/helpers/modals.dart';
@ -208,46 +207,20 @@ class ServerInstallationRepository {
final String? ip4,
final Map<String, bool> skippedMatches,
) async {
final List<String> addresses = <String>[
'$domainName',
'api.$domainName',
'cloud.$domainName',
'meet.$domainName',
'password.$domainName'
];
final Map<String, bool> matches = <String, bool>{};
for (final String address in addresses) {
if (skippedMatches[address] ?? false) {
matches[address] = true;
continue;
}
final List<RRecord>? lookupRecordRes = await DnsUtils.lookupRecord(
address,
RRecordType.A,
provider: DnsApiProvider.CLOUDFLARE,
);
getIt.get<ConsoleModel>().addMessage(
Message(
text:
'DnsLookup: address: $address, $RRecordType, provider: CLOUDFLARE, ip4: $ip4',
),
);
getIt.get<ConsoleModel>().addMessage(
Message(
text:
'DnsLookup: ${lookupRecordRes == null ? 'empty' : (lookupRecordRes[0].data != ip4 ? 'wrong ip4' : 'right ip4')}',
),
);
if (lookupRecordRes == null ||
lookupRecordRes.isEmpty ||
lookupRecordRes[0].data != ip4) {
matches[address] = false;
} else {
matches[address] = true;
}
}
await InternetAddress.lookup(domainName!).then(
(final records) {
for (final record in records) {
if (skippedMatches[record.host] ?? false) {
matches[record.host] = true;
continue;
}
if (record.address == ip4!) {
matches[record.host] = true;
}
}
},
);
return matches;
}