2023-07-27 00:23:37 +00:00
|
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
2023-11-09 12:31:30 +00:00
|
|
|
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
2023-11-08 14:31:28 +00:00
|
|
|
|
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
2023-11-09 12:31:30 +00:00
|
|
|
|
part 'desec_dns_adapter.dart';
|
2023-07-27 00:23:37 +00:00
|
|
|
|
part 'desec_dns_info.g.dart';
|
|
|
|
|
|
|
|
|
|
/// https://desec.readthedocs.io/en/latest/dns/domains.html#domain-management
|
|
|
|
|
@JsonSerializable()
|
|
|
|
|
class DesecDomain {
|
2023-11-09 12:31:30 +00:00
|
|
|
|
DesecDomain({
|
|
|
|
|
required this.name,
|
2023-07-27 00:23:37 +00:00
|
|
|
|
this.minimumTtl,
|
2023-11-09 12:31:30 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
factory DesecDomain.fromServerDomain(final ServerDomain serverDomain) =>
|
|
|
|
|
_fromServerDomain(serverDomain);
|
2023-07-27 00:23:37 +00:00
|
|
|
|
|
|
|
|
|
/// Restrictions on what is a valid domain name apply on
|
|
|
|
|
/// a per-user basis.
|
|
|
|
|
///
|
|
|
|
|
/// The maximum length is 191.
|
|
|
|
|
final String name;
|
|
|
|
|
|
|
|
|
|
/// Smallest TTL that can be used in an RRset.
|
|
|
|
|
/// The value is set automatically by DESEC
|
|
|
|
|
@JsonKey(name: 'minimum_ttl')
|
2023-11-09 12:31:30 +00:00
|
|
|
|
final int? minimumTtl;
|
2023-07-27 00:23:37 +00:00
|
|
|
|
|
|
|
|
|
static DesecDomain fromJson(final Map<String, dynamic> json) =>
|
|
|
|
|
_$DesecDomainFromJson(json);
|
2023-11-09 12:31:30 +00:00
|
|
|
|
ServerDomain toServerDomain() => _toServerDomain(this);
|
2023-07-27 00:23:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// https://desec.readthedocs.io/en/latest/dns/rrsets.html#retrieving-and-creating-dns-records
|
|
|
|
|
@JsonSerializable()
|
|
|
|
|
class DesecDnsRecord {
|
|
|
|
|
DesecDnsRecord({
|
|
|
|
|
required this.subname,
|
|
|
|
|
required this.type,
|
|
|
|
|
required this.ttl,
|
|
|
|
|
required this.records,
|
|
|
|
|
});
|
|
|
|
|
|
2023-11-22 11:14:02 +00:00
|
|
|
|
factory DesecDnsRecord.fromDnsRecord(
|
|
|
|
|
final DnsRecord dnsRecord,
|
|
|
|
|
final String domainName,
|
|
|
|
|
) =>
|
|
|
|
|
_fromDnsRecord(dnsRecord, domainName);
|
2023-11-09 12:31:30 +00:00
|
|
|
|
|
2023-07-27 00:23:37 +00:00
|
|
|
|
/// Subdomain string which, together with domain, defines the RRset name.
|
|
|
|
|
/// Typical examples are www or _443._tcp.
|
|
|
|
|
final String subname;
|
|
|
|
|
|
|
|
|
|
/// RRset type (uppercase). A broad range of record types is supported,
|
|
|
|
|
/// with most DNSSEC-related types (and the SOA type) managed automagically
|
|
|
|
|
/// by the backend.
|
|
|
|
|
final String type;
|
|
|
|
|
|
|
|
|
|
/// Time-to-live value, which dictates for how long resolvers may
|
|
|
|
|
/// cache this RRset, measured in seconds.
|
|
|
|
|
///
|
|
|
|
|
/// The smallest acceptable value is given by the domain’s minimum TTL setting.
|
|
|
|
|
/// The maximum value is 86400 (one day).
|
|
|
|
|
final int ttl;
|
|
|
|
|
|
|
|
|
|
/// Array of record content strings.
|
|
|
|
|
///
|
|
|
|
|
/// The maximum number of array elements is 4091,
|
|
|
|
|
/// and the maximum length of the array is 64,000 (after JSON encoding).
|
|
|
|
|
final List<String> records;
|
|
|
|
|
|
|
|
|
|
static DesecDnsRecord fromJson(final Map<String, dynamic> json) =>
|
|
|
|
|
_$DesecDnsRecordFromJson(json);
|
|
|
|
|
Map<String, dynamic> toJson() => _$DesecDnsRecordToJson(this);
|
2023-11-22 11:14:02 +00:00
|
|
|
|
DnsRecord toDnsRecord(final String domainName) =>
|
|
|
|
|
_toDnsRecord(this, domainName);
|
2023-07-27 00:23:37 +00:00
|
|
|
|
}
|