-
-
Notifications
You must be signed in to change notification settings - Fork 131
/
UriRecord.cs
84 lines (72 loc) · 3 KB
/
UriRecord.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Linq;
namespace DnsClient.Protocol
{
/*
* RFC 7553 https://tools.ietf.org/html/rfc7553
4.5. URI RDATA Wire Format
The RDATA for a URI RR consists of a 2-octet Priority field, a
2-octet Weight field, and a variable-length Target field.
Priority and Weight are unsigned integers in network byte order.
The remaining data in the RDATA contains the Target field. The
Target field contains the URI as a sequence of octets (without the
enclosing double-quote characters used in the presentation format).
The length of the Target field MUST be greater than zero.
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Priority | Weight |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/ /
/ Target /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
/// <summary>
/// A <see cref="DnsResourceRecord"/> representing a Uniform Resource Identifier (URI) resource.
/// </summary>
/// <seealso href="https://tools.ietf.org/html/rfc7553">RFC 7553</seealso>
public class UriRecord : DnsResourceRecord
{
/// <summary>
/// Gets or sets the target Uri.
/// </summary>
/// <value>
/// The target.
/// </value>
public string Target { get; set; }
/// <summary>
/// Gets or sets the priority.
/// </summary>
/// <value>
/// The priority.
/// </value>
public int Priority { get; set; }
/// <summary>
/// Gets or sets the weight.
/// </summary>
/// <value>
/// The weight.
/// </value>
public int Weight { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="UriRecord"/> class.
/// </summary>
/// <param name="info">The information.</param>
/// <param name="priority">The priority.</param>
/// <param name="weight">The weight.</param>
/// <param name="target">The target.</param>
/// <exception cref="ArgumentNullException">If <paramref name="info"/> or <paramref name="target"/> is null.</exception>
public UriRecord(ResourceRecordInfo info, int priority, int weight, string target)
: base(info)
{
Target = target ?? throw new ArgumentNullException(nameof(target));
Priority = priority;
Weight = weight;
}
private protected override string RecordToString()
{
return $"{Priority} {Weight} \"{Target}\"";
}
}
}