fix(cloudflare): Convert MX name from @ to root domain

- #265
pull/424/head
NaiJi ✨ 2024-01-15 14:45:36 +04:00 committed by Inex Code
parent 39f92f769b
commit 2836ce4870
3 changed files with 9 additions and 2 deletions

View File

@ -270,6 +270,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
records: getProjectDnsRecords( records: getProjectDnsRecords(
state.serverDomain!.domainName, state.serverDomain!.domainName,
serverDetails.ip4, serverDetails.ip4,
false,
), ),
domain: state.serverDomain!, domain: state.serverDomain!,
); );
@ -277,6 +278,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
records: getProjectDnsRecords( records: getProjectDnsRecords(
state.serverDomain!.domainName, state.serverDomain!.domainName,
serverDetails.ip4, serverDetails.ip4,
true,
), ),
domain: state.serverDomain!, domain: state.serverDomain!,
); );

View File

@ -4,14 +4,18 @@ CloudflareDnsRecord _fromDnsRecord(
final DnsRecord dnsRecord, final DnsRecord dnsRecord,
final String rootDomain, final String rootDomain,
) { ) {
final String type = dnsRecord.type;
String name = dnsRecord.name ?? ''; String name = dnsRecord.name ?? '';
if (name != rootDomain && name != '@') { if (name != rootDomain && name != '@') {
name = '$name.$rootDomain'; name = '$name.$rootDomain';
} }
if (type == 'MX' && name == '@') {
name = rootDomain;
}
return CloudflareDnsRecord( return CloudflareDnsRecord(
content: dnsRecord.content, content: dnsRecord.content,
name: name, name: name,
type: dnsRecord.type, type: type,
zoneName: rootDomain, zoneName: rootDomain,
id: null, id: null,
ttl: dnsRecord.ttl, ttl: dnsRecord.ttl,

View File

@ -93,6 +93,7 @@ void launchURL(final url) async {
List<DnsRecord> getProjectDnsRecords( List<DnsRecord> getProjectDnsRecords(
final String? domainName, final String? domainName,
final String? ip4, final String? ip4,
final bool isCreating,
) { ) {
final DnsRecord domainA = final DnsRecord domainA =
DnsRecord(type: 'A', name: domainName, content: ip4); DnsRecord(type: 'A', name: domainName, content: ip4);
@ -139,7 +140,7 @@ List<DnsRecord> getProjectDnsRecords(
mx, mx,
txt1, txt1,
txt2, txt2,
txt3, if (!isCreating) txt3,
vpn, vpn,
]; ];
} }