-
-
Notifications
You must be signed in to change notification settings - Fork 131
/
MXRecord.cs
69 lines (59 loc) · 2.67 KB
/
MXRecord.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
namespace DnsClient.Protocol
{
/* https://tools.ietf.org/html/rfc1035#section-3.3.9
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 <domain-name> 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].
*/
/// <summary>
/// A <see cref="DnsResourceRecord"/> representing a mail exchange.
/// </summary>
/// <seealso href="https://tools.ietf.org/html/rfc1035#section-3.3.9">RFC 1035</seealso>
/// <seealso href="https://tools.ietf.org/html/rfc974">RFC 974</seealso>
// TODO: For V2 Remove CLS incompliant properties - make ushort => int. Currently would break backward compat...
[CLSCompliant(false)]
public class MxRecord : DnsResourceRecord
{
/// <summary>
/// Gets a 16 bit integer which specifies the preference given to
/// this RR among others at the same owner.
/// Lower values are preferred.
/// </summary>
public ushort Preference { get; }
/// <summary>
/// A domain name which specifies a host willing to act as a mail exchange.
/// </summary>
public DnsString Exchange { get; }
/// <summary>
/// Initializes a new instance of the <see cref="MxRecord"/> class.
/// </summary>
/// <param name="info">The information.</param>
/// <param name="preference">The preference.</param>
/// <param name="domainName">Name of the domain.</param>
/// <exception cref="ArgumentNullException">If <paramref name="domainName"/> or <paramref name="info"/> is null.</exception>
public MxRecord(ResourceRecordInfo info, ushort preference, DnsString domainName)
: base(info)
{
Preference = preference;
Exchange = domainName ?? throw new ArgumentNullException(nameof(domainName));
}
private protected override string RecordToString()
{
return string.Format("{0} {1}", Preference, Exchange);
}
}
}