2023-05-25 03:02:10 +00:00
|
|
|
import 'package:selfprivacy/logic/api_maps/generic_result.dart';
|
|
|
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/desired_dns_record.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
|
|
|
export 'package:selfprivacy/logic/api_maps/generic_result.dart';
|
|
|
|
|
|
|
|
abstract class DnsProvider {
|
2023-06-29 18:38:46 +00:00
|
|
|
/// Returns an assigned enum value, respectively to which
|
|
|
|
/// provider implements [DnsProvider] interface.
|
2023-06-02 05:44:34 +00:00
|
|
|
DnsProviderType get type;
|
2023-06-29 18:38:46 +00:00
|
|
|
|
|
|
|
/// Tries to access an account linked to the provided token.
|
|
|
|
///
|
|
|
|
/// To generate a token for your account follow instructions of your
|
|
|
|
/// DNS provider respectfully.
|
|
|
|
///
|
|
|
|
/// If success, saves it for future usage.
|
2023-05-25 03:02:10 +00:00
|
|
|
Future<GenericResult<bool>> tryInitApiByToken(final String token);
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Returns list of all available domain entries assigned to the account.
|
|
|
|
Future<GenericResult<List<String>>> domainList();
|
|
|
|
|
|
|
|
/// Tries to create all main domain records needed
|
|
|
|
/// for SelfPrivacy to launch on requested domain by ip4.
|
|
|
|
///
|
|
|
|
/// Doesn't check for duplication, cleaning has
|
|
|
|
/// to be done beforehand by [removeDomainRecords]
|
|
|
|
Future<GenericResult<void>> createDomainRecords({
|
2023-05-25 03:02:10 +00:00
|
|
|
required final ServerDomain domain,
|
|
|
|
final String? ip4,
|
|
|
|
});
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Tries to remove all domain records of requested domain by ip4.
|
|
|
|
///
|
|
|
|
/// Will remove all entries, including the ones
|
|
|
|
/// that weren't created by SelfPrivacy.
|
|
|
|
Future<GenericResult<void>> removeDomainRecords({
|
2023-05-25 03:02:10 +00:00
|
|
|
required final ServerDomain domain,
|
2023-07-05 09:34:35 +00:00
|
|
|
final String? ip4,
|
2023-05-25 03:02:10 +00:00
|
|
|
});
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Returns list of all [DnsRecord] entries assigned to requested domain.
|
|
|
|
Future<GenericResult<List<DnsRecord>>> getDnsRecords({
|
2023-05-25 03:02:10 +00:00
|
|
|
required final ServerDomain domain,
|
|
|
|
});
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Tries to create or update a domain record needed
|
|
|
|
/// on requested domain.
|
|
|
|
///
|
|
|
|
/// Doesn't check for duplication, cleaning has
|
|
|
|
/// to be done beforehand by [removeDomainRecords]
|
2023-05-25 03:02:10 +00:00
|
|
|
Future<GenericResult<void>> setDnsRecord(
|
|
|
|
final DnsRecord record,
|
|
|
|
final ServerDomain domain,
|
|
|
|
);
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Tries to check whether all known DNS records on the domain by ip4
|
|
|
|
/// match expectations of SelfPrivacy in order to launch.
|
|
|
|
///
|
|
|
|
/// Will return list of [DesiredDnsRecord] objects, which represent
|
|
|
|
/// only those records which have successfully passed validation.
|
2023-05-25 03:02:10 +00:00
|
|
|
Future<GenericResult<List<DesiredDnsRecord>>> validateDnsRecords(
|
|
|
|
final ServerDomain domain,
|
|
|
|
final String ip4,
|
|
|
|
final String dkimPublicKey,
|
|
|
|
);
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Will return list of [DesiredDnsRecord] objects, which represent
|
|
|
|
/// samples of perfect DNS records we need to know about in order to launch
|
|
|
|
/// SelfPrivacy application correctly.
|
2023-05-25 03:02:10 +00:00
|
|
|
List<DesiredDnsRecord> getDesiredDnsRecords(
|
|
|
|
final String? domainName,
|
|
|
|
final String? ip4,
|
|
|
|
final String? dkimPublicKey,
|
|
|
|
);
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Tries to access zone of requested domain.
|
|
|
|
///
|
|
|
|
/// If a DNS provider doesn't support zones,
|
|
|
|
/// will return domain without any changes.
|
|
|
|
///
|
|
|
|
/// If success, returns an initializing string of zone id.
|
|
|
|
Future<GenericResult<String?>> getZoneId(final String domain);
|
2023-05-25 03:02:10 +00:00
|
|
|
}
|