2using System.Collections.Generic;
4using System.Text.RegularExpressions;
16 private static readonly Regex srvName =
new Regex(
"^_(?'Service'[^.]*)[.]_(?'Protocol'[^.]*)[.](?'Name'.*)$", RegexOptions.Singleline | RegexOptions.Compiled);
18 private string service;
19 private string protocol;
20 private ushort priority;
21 private ushort weight;
23 private string targetHost;
31 this.service =
string.Empty;
32 this.protocol =
string.Empty;
36 this.targetHost =
string.Empty;
54 M = srvName.Match(
Name);
57 if (!M.Success || M.Index > 0 || M.Length <
Name.Length)
58 throw new ArgumentException(
"Invalid service name.", nameof(
Name));
60 this.service = M.Groups[
"Service"].Value;
61 this.protocol = M.Groups[
"Protocol"].Value;
62 this.Name = M.Groups[
"Name"].Value;
64 this.priority =
DnsClient.ReadUInt16(Data);
67 this.targetHost =
DnsClient.ReadName(Data);
73 [DefaultValueStringEmpty]
77 set => this.service = value;
83 [DefaultValueStringEmpty]
87 set => this.protocol = value;
93 [DefaultValue((ushort)0)]
97 set => this.priority = value;
103 [DefaultValue((ushort)0)]
107 set => this.weight = value;
113 [DefaultValue((ushort)0)]
117 set => this.port = value;
123 [DefaultValueStringEmpty]
126 get => this.targetHost;
127 set => this.targetHost = value;
133 return base.ToString() +
"\t" + this.service +
"\t" + this.protocol +
134 "\t" + this.priority.ToString() +
"\t" + this.weight.ToString() +
135 "\t" + this.port.ToString() +
"\t" + this.targetHost;
Abstract base class for DNS clients.
Abstract base class for a resource record.
TYPE Type
Resource Record Type
CLASS Class
Resource Record Class
string Protocol
Protocol name
string TargetHost
Target Host
string Service
Service name.
SRV(string Name, TYPE Type, CLASS Class, uint Ttl, Stream Data)
Server Selection
override string ToString()
CLASS
TYPE fields are used in resource records.
TYPE
TYPE fields are used in resource records.