mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 17:11:14 +00:00
fix(cloudflare): Adapt Cloudflare DNS convertion
This commit is contained in:
parent
19e070133c
commit
ff9c96a114
|
@ -18,12 +18,23 @@ CloudflareDnsRecord _fromDnsRecord(
|
|||
);
|
||||
}
|
||||
|
||||
DnsRecord _toDnsRecord(final CloudflareDnsRecord cloudflareRecord) => DnsRecord(
|
||||
content: cloudflareRecord.content,
|
||||
name: cloudflareRecord.name,
|
||||
type: cloudflareRecord.type,
|
||||
ttl: cloudflareRecord.ttl,
|
||||
);
|
||||
DnsRecord _toDnsRecord(
|
||||
final CloudflareDnsRecord cloudflareRecord,
|
||||
final String domainName,
|
||||
) {
|
||||
String? name = cloudflareRecord.name;
|
||||
if (name != null && name.endsWith('.$domainName')) {
|
||||
// e.g. 'api.example.com -> [api] [example] [com] -> [api]'
|
||||
name = name.split('.')[0];
|
||||
}
|
||||
|
||||
return DnsRecord(
|
||||
content: cloudflareRecord.content,
|
||||
type: cloudflareRecord.type,
|
||||
ttl: cloudflareRecord.ttl,
|
||||
name: name,
|
||||
);
|
||||
}
|
||||
|
||||
ServerDomain _toServerDomain(final CloudflareZone cloudflareZone) =>
|
||||
ServerDomain(
|
||||
|
|
|
@ -93,5 +93,6 @@ class CloudflareDnsRecord {
|
|||
static CloudflareDnsRecord fromJson(final Map<String, dynamic> json) =>
|
||||
_$CloudflareDnsRecordFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$CloudflareDnsRecordToJson(this);
|
||||
DnsRecord toDnsRecord() => _toDnsRecord(this);
|
||||
DnsRecord toDnsRecord(final String domainName) =>
|
||||
_toDnsRecord(this, domainName);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ class CloudflareDnsProvider extends DnsProvider {
|
|||
}
|
||||
|
||||
for (final rawRecord in result.data) {
|
||||
records.add(rawRecord.toDnsRecord());
|
||||
records.add(rawRecord.toDnsRecord(domain.domainName));
|
||||
}
|
||||
|
||||
return GenericResult(
|
||||
|
|
Loading…
Reference in a new issue