mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 09:31:13 +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(
|
DnsRecord _toDnsRecord(
|
||||||
content: cloudflareRecord.content,
|
final CloudflareDnsRecord cloudflareRecord,
|
||||||
name: cloudflareRecord.name,
|
final String domainName,
|
||||||
type: cloudflareRecord.type,
|
) {
|
||||||
ttl: cloudflareRecord.ttl,
|
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 _toServerDomain(final CloudflareZone cloudflareZone) =>
|
||||||
ServerDomain(
|
ServerDomain(
|
||||||
|
|
|
@ -93,5 +93,6 @@ class CloudflareDnsRecord {
|
||||||
static CloudflareDnsRecord fromJson(final Map<String, dynamic> json) =>
|
static CloudflareDnsRecord fromJson(final Map<String, dynamic> json) =>
|
||||||
_$CloudflareDnsRecordFromJson(json);
|
_$CloudflareDnsRecordFromJson(json);
|
||||||
Map<String, dynamic> toJson() => _$CloudflareDnsRecordToJson(this);
|
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) {
|
for (final rawRecord in result.data) {
|
||||||
records.add(rawRecord.toDnsRecord());
|
records.add(rawRecord.toDnsRecord(domain.domainName));
|
||||||
}
|
}
|
||||||
|
|
||||||
return GenericResult(
|
return GenericResult(
|
||||||
|
|
Loading…
Reference in a new issue