using MailSharp.DNS.Records; namespace MailSharp.DNS.Records; /* 3.3.9. MX RDATA format +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | PREFERENCE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / EXCHANGE / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ where: PREFERENCE A 16 bit integer which specifies the preference given to this RR among others at the same owner. Lower values are preferred. EXCHANGE A which specifies a host willing to act as a mail exchange for the owner name. MX records cause type A additional section processing for the host specified by EXCHANGE. The use of MX RRs is explained in detail in [RFC-974]. */ public record RecordMX(RecordReader rr) : DnsRecord(rr), IComparable { public ushort Preference { get; } = rr.ReadUInt16(); public string Exchange { get; } = rr.ReadDomainName(); public override string ToString() => $"{Preference} {Exchange}"; public int CompareTo(RecordMX? other) { if (other is not RecordMX recordMX) return -1; else if (Preference > recordMX.Preference) return 1; else if (Preference < recordMX.Preference) return -1; else // they are the same, now compare case insensitive names return string.Compare(Exchange, recordMX.Exchange, true); } }