mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
.NET 5+ Support (#1674)
Implement changes to support .NET 5 onwards. Co-authored-by: ReinforceZwei <39955851+ReinforceZwei@users.noreply.github.com> Co-authored-by: ORelio <ORelio@users.noreply.github.com>
This commit is contained in:
parent
b3cc2351ee
commit
d9f1a77ac2
117 changed files with 1028 additions and 9058 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
|
@ -87,7 +88,7 @@ namespace MinecraftClient.Protocol
|
|||
if (!System.IO.Directory.Exists("lang"))
|
||||
System.IO.Directory.CreateDirectory("lang");
|
||||
|
||||
string Language_File = "lang" + (Program.isUsingMono ? '/' : '\\') + Settings.Language + ".lang";
|
||||
string Language_File = "lang" + Path.DirectorySeparatorChar + Settings.Language + ".lang";
|
||||
|
||||
//File not found? Try downloading language file from Mojang's servers?
|
||||
if (!System.IO.File.Exists(Language_File))
|
||||
|
|
|
|||
|
|
@ -1,351 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
#region RFC specification
|
||||
/*
|
||||
4.1.1. Header section format
|
||||
|
||||
The header contains the following fields:
|
||||
|
||||
1 1 1 1 1 1
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| ID |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|QR| Opcode |AA|TC|RD|RA| Z | RCODE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| QDCOUNT |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| ANCOUNT |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| NSCOUNT |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| ARCOUNT |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
ID A 16 bit identifier assigned by the program that
|
||||
generates any kind of query. This identifier is copied
|
||||
the corresponding reply and can be used by the requester
|
||||
to match up replies to outstanding queries.
|
||||
|
||||
QR A one bit field that specifies whether this message is a
|
||||
query (0), or a response (1).
|
||||
|
||||
OPCODE A four bit field that specifies kind of query in this
|
||||
message. This value is set by the originator of a query
|
||||
and copied into the response. The values are:
|
||||
|
||||
0 a standard query (QUERY)
|
||||
|
||||
1 an inverse query (IQUERY)
|
||||
|
||||
2 a server status request (STATUS)
|
||||
|
||||
3-15 reserved for future use
|
||||
|
||||
AA Authoritative Answer - this bit is valid in responses,
|
||||
and specifies that the responding name server is an
|
||||
authority for the domain name in question section.
|
||||
|
||||
Note that the contents of the answer section may have
|
||||
multiple owner names because of aliases. The AA bit
|
||||
corresponds to the name which matches the query name, or
|
||||
the first owner name in the answer section.
|
||||
|
||||
TC TrunCation - specifies that this message was truncated
|
||||
due to length greater than that permitted on the
|
||||
transmission channel.
|
||||
|
||||
RD Recursion Desired - this bit may be set in a query and
|
||||
is copied into the response. If RD is set, it directs
|
||||
the name server to pursue the query recursively.
|
||||
Recursive query support is optional.
|
||||
|
||||
RA Recursion Available - this be is set or cleared in a
|
||||
response, and denotes whether recursive query support is
|
||||
available in the name server.
|
||||
|
||||
Z Reserved for future use. Must be zero in all queries
|
||||
and responses.
|
||||
|
||||
RCODE Response code - this 4 bit field is set as part of
|
||||
responses. The values have the following
|
||||
interpretation:
|
||||
|
||||
0 No error condition
|
||||
|
||||
1 Format error - The name server was
|
||||
unable to interpret the query.
|
||||
|
||||
2 Server failure - The name server was
|
||||
unable to process this query due to a
|
||||
problem with the name server.
|
||||
|
||||
3 Name Error - Meaningful only for
|
||||
responses from an authoritative name
|
||||
server, this code signifies that the
|
||||
domain name referenced in the query does
|
||||
not exist.
|
||||
|
||||
4 Not Implemented - The name server does
|
||||
not support the requested kind of query.
|
||||
|
||||
5 Refused - The name server refuses to
|
||||
perform the specified operation for
|
||||
policy reasons. For example, a name
|
||||
server may not wish to provide the
|
||||
information to the particular requester,
|
||||
or a name server may not wish to perform
|
||||
a particular operation (e.g., zone
|
||||
transfer) for particular data.
|
||||
|
||||
6-15 Reserved for future use.
|
||||
|
||||
QDCOUNT an unsigned 16 bit integer specifying the number of
|
||||
entries in the question section.
|
||||
|
||||
ANCOUNT an unsigned 16 bit integer specifying the number of
|
||||
resource records in the answer section.
|
||||
|
||||
NSCOUNT an unsigned 16 bit integer specifying the number of name
|
||||
server resource records in the authority records
|
||||
section.
|
||||
|
||||
ARCOUNT an unsigned 16 bit integer specifying the number of
|
||||
resource records in the additional records section.
|
||||
|
||||
*/
|
||||
#endregion
|
||||
|
||||
public class Header
|
||||
{
|
||||
/// <summary>
|
||||
/// An identifier assigned by the program
|
||||
/// </summary>
|
||||
public ushort ID;
|
||||
|
||||
// internal flag
|
||||
private ushort Flags;
|
||||
|
||||
/// <summary>
|
||||
/// the number of entries in the question section
|
||||
/// </summary>
|
||||
public ushort QDCOUNT;
|
||||
|
||||
/// <summary>
|
||||
/// the number of resource records in the answer section
|
||||
/// </summary>
|
||||
public ushort ANCOUNT;
|
||||
|
||||
/// <summary>
|
||||
/// the number of name server resource records in the authority records section
|
||||
/// </summary>
|
||||
public ushort NSCOUNT;
|
||||
|
||||
/// <summary>
|
||||
/// the number of resource records in the additional records section
|
||||
/// </summary>
|
||||
public ushort ARCOUNT;
|
||||
|
||||
public Header()
|
||||
{
|
||||
}
|
||||
|
||||
public Header(RecordReader rr)
|
||||
{
|
||||
ID = rr.ReadUInt16();
|
||||
Flags = rr.ReadUInt16();
|
||||
QDCOUNT = rr.ReadUInt16();
|
||||
ANCOUNT = rr.ReadUInt16();
|
||||
NSCOUNT = rr.ReadUInt16();
|
||||
ARCOUNT = rr.ReadUInt16();
|
||||
}
|
||||
|
||||
|
||||
private ushort SetBits(ushort oldValue, int position, int length, bool blnValue)
|
||||
{
|
||||
return SetBits(oldValue, position, length, blnValue ? (ushort)1 : (ushort)0);
|
||||
}
|
||||
|
||||
private ushort SetBits(ushort oldValue, int position, int length, ushort newValue)
|
||||
{
|
||||
// sanity check
|
||||
if (length <= 0 || position >= 16)
|
||||
return oldValue;
|
||||
|
||||
// get some mask to put on
|
||||
int mask = (2 << (length - 1)) - 1;
|
||||
|
||||
// clear out value
|
||||
oldValue &= (ushort)~(mask << position);
|
||||
|
||||
// set new value
|
||||
oldValue |= (ushort)((newValue & mask) << position);
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
private ushort GetBits(ushort oldValue, int position, int length)
|
||||
{
|
||||
// sanity check
|
||||
if (length <= 0 || position >= 16)
|
||||
return 0;
|
||||
|
||||
// get some mask to put on
|
||||
int mask = (2 << (length - 1)) - 1;
|
||||
|
||||
// shift down to get some value and mask it
|
||||
return (ushort)((oldValue >> position) & mask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the header as a byte array
|
||||
/// </summary>
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
List<byte> data = new List<byte>();
|
||||
data.AddRange(WriteShort(ID));
|
||||
data.AddRange(WriteShort(Flags));
|
||||
data.AddRange(WriteShort(QDCOUNT));
|
||||
data.AddRange(WriteShort(ANCOUNT));
|
||||
data.AddRange(WriteShort(NSCOUNT));
|
||||
data.AddRange(WriteShort(ARCOUNT));
|
||||
return data.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] WriteShort(ushort sValue)
|
||||
{
|
||||
return BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)sValue));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// query (false), or a response (true)
|
||||
/// </summary>
|
||||
public bool QR
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBits(Flags, 15, 1) == 1;
|
||||
}
|
||||
set
|
||||
{
|
||||
Flags = SetBits(Flags, 15, 1, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies kind of query
|
||||
/// </summary>
|
||||
public OPCode OPCODE
|
||||
{
|
||||
get
|
||||
{
|
||||
return (OPCode)GetBits(Flags, 11, 4);
|
||||
}
|
||||
set
|
||||
{
|
||||
Flags = SetBits(Flags, 11, 4, (ushort)value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authoritative Answer
|
||||
/// </summary>
|
||||
public bool AA
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBits(Flags, 10, 1) == 1;
|
||||
}
|
||||
set
|
||||
{
|
||||
Flags = SetBits(Flags, 10, 1, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TrunCation
|
||||
/// </summary>
|
||||
public bool TC
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBits(Flags, 9, 1) == 1;
|
||||
}
|
||||
set
|
||||
{
|
||||
Flags = SetBits(Flags, 9, 1, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recursion Desired
|
||||
/// </summary>
|
||||
public bool RD
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBits(Flags, 8, 1) == 1;
|
||||
}
|
||||
set
|
||||
{
|
||||
Flags = SetBits(Flags, 8, 1, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recursion Available
|
||||
/// </summary>
|
||||
public bool RA
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBits(Flags, 7, 1) == 1;
|
||||
}
|
||||
set
|
||||
{
|
||||
Flags = SetBits(Flags, 7, 1, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reserved for future use
|
||||
/// </summary>
|
||||
public ushort Z
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBits(Flags, 4, 3);
|
||||
}
|
||||
set
|
||||
{
|
||||
Flags = SetBits(Flags, 4, 3, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Response code
|
||||
/// </summary>
|
||||
public RCode RCODE
|
||||
{
|
||||
get
|
||||
{
|
||||
return (RCode)GetBits(Flags, 0, 4);
|
||||
}
|
||||
set
|
||||
{
|
||||
Flags = SetBits(Flags, 0, 4, (ushort)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
#region Rfc 1034/1035
|
||||
/*
|
||||
4.1.2. Question section format
|
||||
|
||||
The question section is used to carry the "question" in most queries,
|
||||
i.e., the parameters that define what is being asked. The section
|
||||
contains QDCOUNT (usually 1) entries, each of the following format:
|
||||
|
||||
1 1 1 1 1 1
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| |
|
||||
/ QNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| QTYPE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| QCLASS |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
QNAME a domain name represented as a sequence of labels, where
|
||||
each label consists of a length octet followed by that
|
||||
number of octets. The domain name terminates with the
|
||||
zero length octet for the null label of the root. Note
|
||||
that this field may be an odd number of octets; no
|
||||
padding is used.
|
||||
|
||||
QTYPE a two octet code which specifies the type of the query.
|
||||
The values for this field include all codes valid for a
|
||||
TYPE field, together with some more general codes which
|
||||
can match more than one type of RR.
|
||||
|
||||
|
||||
QCLASS a two octet code that specifies the class of the query.
|
||||
For example, the QCLASS field is IN for the Internet.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
public class Question
|
||||
{
|
||||
private string m_QName;
|
||||
public string QName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_QName;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_QName = value;
|
||||
if (!m_QName.EndsWith("."))
|
||||
m_QName += ".";
|
||||
}
|
||||
}
|
||||
public QType QType;
|
||||
public QClass QClass;
|
||||
|
||||
public Question(string QName,QType QType,QClass QClass)
|
||||
{
|
||||
this.QName = QName;
|
||||
this.QType = QType;
|
||||
this.QClass = QClass;
|
||||
}
|
||||
|
||||
public Question(RecordReader rr)
|
||||
{
|
||||
QName = rr.ReadDomainName();
|
||||
QType = (QType)rr.ReadUInt16();
|
||||
QClass = (QClass)rr.ReadUInt16();
|
||||
}
|
||||
|
||||
private byte[] WriteName(string src)
|
||||
{
|
||||
if (!src.EndsWith("."))
|
||||
src += ".";
|
||||
|
||||
if (src == ".")
|
||||
return new byte[1];
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int intI, intJ, intLen = src.Length;
|
||||
sb.Append('\0');
|
||||
for (intI = 0, intJ = 0; intI < intLen; intI++, intJ++)
|
||||
{
|
||||
sb.Append(src[intI]);
|
||||
if (src[intI] == '.')
|
||||
{
|
||||
sb[intI - intJ] = (char)(intJ & 0xff);
|
||||
intJ = -1;
|
||||
}
|
||||
}
|
||||
sb[sb.Length - 1] = '\0';
|
||||
return System.Text.Encoding.ASCII.GetBytes(sb.ToString());
|
||||
}
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
List<byte> data = new List<byte>();
|
||||
data.AddRange(WriteName(QName));
|
||||
data.AddRange(WriteShort((ushort)QType));
|
||||
data.AddRange(WriteShort((ushort)QClass));
|
||||
return data.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] WriteShort(ushort sValue)
|
||||
{
|
||||
return BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)sValue));
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0,-32}\t{1}\t{2}", QName, QClass, QType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
#region RFC info
|
||||
/*
|
||||
3.2. RR definitions
|
||||
|
||||
3.2.1. Format
|
||||
|
||||
All RRs have the same top level format shown below:
|
||||
|
||||
1 1 1 1 1 1
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| |
|
||||
/ /
|
||||
/ NAME /
|
||||
| |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| TYPE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| CLASS |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| TTL |
|
||||
| |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| RDLENGTH |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
|
||||
/ RDATA /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
|
||||
where:
|
||||
|
||||
NAME an owner name, i.e., the name of the node to which this
|
||||
resource record pertains.
|
||||
|
||||
TYPE two octets containing one of the RR TYPE codes.
|
||||
|
||||
CLASS two octets containing one of the RR CLASS codes.
|
||||
|
||||
TTL a 32 bit signed integer that specifies the time interval
|
||||
that the resource record may be cached before the source
|
||||
of the information should again be consulted. Zero
|
||||
values are interpreted to mean that the RR can only be
|
||||
used for the transaction in progress, and should not be
|
||||
cached. For example, SOA records are always distributed
|
||||
with a zero TTL to prohibit caching. Zero values can
|
||||
also be used for extremely volatile data.
|
||||
|
||||
RDLENGTH an unsigned 16 bit integer that specifies the length in
|
||||
octets of the RDATA field.
|
||||
|
||||
RDATA a variable length string of octets that describes the
|
||||
resource. The format of this information varies
|
||||
according to the TYPE and CLASS of the resource record.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Resource Record (rfc1034 3.6.)
|
||||
/// </summary>
|
||||
public class RR
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the node to which this resource record pertains
|
||||
/// </summary>
|
||||
public string NAME;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies type of resource record
|
||||
/// </summary>
|
||||
public Type Type;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies type class of resource record, mostly IN but can be CS, CH or HS
|
||||
/// </summary>
|
||||
public Class Class;
|
||||
|
||||
/// <summary>
|
||||
/// Time to live, the time interval that the resource record may be cached
|
||||
/// </summary>
|
||||
public uint TTL
|
||||
{
|
||||
get
|
||||
{
|
||||
return (uint)Math.Max(0, m_TTL - TimeLived);
|
||||
}
|
||||
set
|
||||
{
|
||||
m_TTL = value;
|
||||
}
|
||||
}
|
||||
private uint m_TTL;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public ushort RDLENGTH;
|
||||
|
||||
/// <summary>
|
||||
/// One of the Record* classes
|
||||
/// </summary>
|
||||
public Record RECORD;
|
||||
|
||||
public int TimeLived;
|
||||
|
||||
public RR(RecordReader rr)
|
||||
{
|
||||
TimeLived = 0;
|
||||
NAME = rr.ReadDomainName();
|
||||
Type = (Type)rr.ReadUInt16();
|
||||
Class = (Class)rr.ReadUInt16();
|
||||
TTL = rr.ReadUInt32();
|
||||
RDLENGTH = rr.ReadUInt16();
|
||||
RECORD = rr.ReadRecord(Type);
|
||||
RECORD.RR = this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0,-32} {1}\t{2}\t{3}\t{4}",
|
||||
NAME,
|
||||
TTL,
|
||||
Class,
|
||||
Type,
|
||||
RECORD);
|
||||
}
|
||||
}
|
||||
|
||||
public class AnswerRR : RR
|
||||
{
|
||||
public AnswerRR(RecordReader br)
|
||||
: base(br)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class AuthorityRR : RR
|
||||
{
|
||||
public AuthorityRR(RecordReader br)
|
||||
: base(br)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class AdditionalRR : RR
|
||||
{
|
||||
public AdditionalRR(RecordReader br)
|
||||
: base(br)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,243 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordReader
|
||||
{
|
||||
private byte[] m_Data;
|
||||
private int m_Position;
|
||||
public RecordReader(byte[] data)
|
||||
{
|
||||
m_Data = data;
|
||||
m_Position = 0;
|
||||
}
|
||||
|
||||
public int Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Position;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Position = value;
|
||||
}
|
||||
}
|
||||
|
||||
public RecordReader(byte[] data, int Position)
|
||||
{
|
||||
m_Data = data;
|
||||
m_Position = Position;
|
||||
}
|
||||
|
||||
|
||||
public byte ReadByte()
|
||||
{
|
||||
if (m_Position >= m_Data.Length)
|
||||
return 0;
|
||||
else
|
||||
return m_Data[m_Position++];
|
||||
}
|
||||
|
||||
public char ReadChar()
|
||||
{
|
||||
return (char)ReadByte();
|
||||
}
|
||||
|
||||
public UInt16 ReadUInt16()
|
||||
{
|
||||
return (UInt16)(ReadByte() << 8 | ReadByte());
|
||||
}
|
||||
|
||||
public UInt16 ReadUInt16(int offset)
|
||||
{
|
||||
m_Position += offset;
|
||||
return ReadUInt16();
|
||||
}
|
||||
|
||||
public UInt32 ReadUInt32()
|
||||
{
|
||||
return (UInt32)(ReadUInt16() << 16 | ReadUInt16());
|
||||
}
|
||||
|
||||
public string ReadDomainName()
|
||||
{
|
||||
StringBuilder name = new StringBuilder();
|
||||
int length = 0;
|
||||
|
||||
// get the length of the first label
|
||||
while ((length = ReadByte()) != 0)
|
||||
{
|
||||
// top 2 bits set denotes domain name compression and to reference elsewhere
|
||||
if ((length & 0xc0) == 0xc0)
|
||||
{
|
||||
// work out the existing domain name, copy this pointer
|
||||
RecordReader newRecordReader = new RecordReader(m_Data, (length & 0x3f) << 8 | ReadByte());
|
||||
|
||||
name.Append(newRecordReader.ReadDomainName());
|
||||
return name.ToString();
|
||||
}
|
||||
|
||||
// if not using compression, copy a char at a time to the domain name
|
||||
while (length > 0)
|
||||
{
|
||||
name.Append(ReadChar());
|
||||
length--;
|
||||
}
|
||||
name.Append('.');
|
||||
}
|
||||
if (name.Length == 0)
|
||||
return ".";
|
||||
else
|
||||
return name.ToString();
|
||||
}
|
||||
|
||||
public string ReadString()
|
||||
{
|
||||
short length = this.ReadByte();
|
||||
|
||||
StringBuilder name = new StringBuilder();
|
||||
for(int intI=0;intI<length;intI++)
|
||||
name.Append(ReadChar());
|
||||
return name.ToString();
|
||||
}
|
||||
|
||||
public byte[] ReadBytes(int intLength)
|
||||
{
|
||||
List<byte> list = new List<byte>();
|
||||
for(int intI=0;intI<intLength;intI++)
|
||||
list.Add(ReadByte());
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public Record ReadRecord(Type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Type.A:
|
||||
return new RecordA(this);
|
||||
case Type.NS:
|
||||
return new RecordNS(this);
|
||||
case Type.MD:
|
||||
return new RecordMD(this);
|
||||
case Type.MF:
|
||||
return new RecordMF(this);
|
||||
case Type.CNAME:
|
||||
return new RecordCNAME(this);
|
||||
case Type.SOA:
|
||||
return new RecordSOA(this);
|
||||
case Type.MB:
|
||||
return new RecordMB(this);
|
||||
case Type.MG:
|
||||
return new RecordMG(this);
|
||||
case Type.MR:
|
||||
return new RecordMR(this);
|
||||
case Type.NULL:
|
||||
return new RecordNULL(this);
|
||||
case Type.WKS:
|
||||
return new RecordWKS(this);
|
||||
case Type.PTR:
|
||||
return new RecordPTR(this);
|
||||
case Type.HINFO:
|
||||
return new RecordHINFO(this);
|
||||
case Type.MINFO:
|
||||
return new RecordMINFO(this);
|
||||
case Type.MX:
|
||||
return new RecordMX(this);
|
||||
case Type.TXT:
|
||||
return new RecordTXT(this);
|
||||
case Type.RP:
|
||||
return new RecordRP(this);
|
||||
case Type.AFSDB:
|
||||
return new RecordAFSDB(this);
|
||||
case Type.X25:
|
||||
return new RecordX25(this);
|
||||
case Type.ISDN:
|
||||
return new RecordISDN(this);
|
||||
case Type.RT:
|
||||
return new RecordRT(this);
|
||||
case Type.NSAP:
|
||||
return new RecordNSAP(this);
|
||||
case Type.NSAPPTR:
|
||||
return new RecordNSAPPTR(this);
|
||||
case Type.SIG:
|
||||
return new RecordSIG(this);
|
||||
case Type.KEY:
|
||||
return new RecordKEY(this);
|
||||
case Type.PX:
|
||||
return new RecordPX(this);
|
||||
case Type.GPOS:
|
||||
return new RecordGPOS(this);
|
||||
case Type.AAAA:
|
||||
return new RecordAAAA(this);
|
||||
case Type.LOC:
|
||||
return new RecordLOC(this);
|
||||
case Type.NXT:
|
||||
return new RecordNXT(this);
|
||||
case Type.EID:
|
||||
return new RecordEID(this);
|
||||
case Type.NIMLOC:
|
||||
return new RecordNIMLOC(this);
|
||||
case Type.SRV:
|
||||
return new RecordSRV(this);
|
||||
case Type.ATMA:
|
||||
return new RecordATMA(this);
|
||||
case Type.NAPTR:
|
||||
return new RecordNAPTR(this);
|
||||
case Type.KX:
|
||||
return new RecordKX(this);
|
||||
case Type.CERT:
|
||||
return new RecordCERT(this);
|
||||
case Type.A6:
|
||||
return new RecordA6(this);
|
||||
case Type.DNAME:
|
||||
return new RecordDNAME(this);
|
||||
case Type.SINK:
|
||||
return new RecordSINK(this);
|
||||
case Type.OPT:
|
||||
return new RecordOPT(this);
|
||||
case Type.APL:
|
||||
return new RecordAPL(this);
|
||||
case Type.DS:
|
||||
return new RecordDS(this);
|
||||
case Type.SSHFP:
|
||||
return new RecordSSHFP(this);
|
||||
case Type.IPSECKEY:
|
||||
return new RecordIPSECKEY(this);
|
||||
case Type.RRSIG:
|
||||
return new RecordRRSIG(this);
|
||||
case Type.NSEC:
|
||||
return new RecordNSEC(this);
|
||||
case Type.DNSKEY:
|
||||
return new RecordDNSKEY(this);
|
||||
case Type.DHCID:
|
||||
return new RecordDHCID(this);
|
||||
case Type.NSEC3:
|
||||
return new RecordNSEC3(this);
|
||||
case Type.NSEC3PARAM:
|
||||
return new RecordNSEC3PARAM(this);
|
||||
case Type.HIP:
|
||||
return new RecordHIP(this);
|
||||
case Type.SPF:
|
||||
return new RecordSPF(this);
|
||||
case Type.UINFO:
|
||||
return new RecordUINFO(this);
|
||||
case Type.UID:
|
||||
return new RecordUID(this);
|
||||
case Type.GID:
|
||||
return new RecordGID(this);
|
||||
case Type.UNSPEC:
|
||||
return new RecordUNSPEC(this);
|
||||
case Type.TKEY:
|
||||
return new RecordTKEY(this);
|
||||
case Type.TSIG:
|
||||
return new RecordTSIG(this);
|
||||
default:
|
||||
return new RecordUnknown(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordA6 : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordA6(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordAPL : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordAPL(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordATMA : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordATMA(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordCERT : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordCERT(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordDHCID : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordDHCID(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordDNSKEY : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordDNSKEY(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordEID : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordEID(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordGID : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordGID(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordHIP : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordHIP(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordIPSECKEY : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordIPSECKEY(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNIMLOC : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordNIMLOC(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNSEC : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordNSEC(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNSEC3 : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordNSEC3(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNSEC3PARAM : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordNSEC3PARAM(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordOPT : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordOPT(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordRRSIG : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordRRSIG(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordSINK : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordSINK(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordSPF : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordSPF(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordSSHFP : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordSSHFP(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordUID : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordUID(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordUINFO : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordUINFO(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordUNSPEC : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
|
||||
public RecordUNSPEC(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("not-used");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordUnknown : Record
|
||||
{
|
||||
public byte[] RDATA;
|
||||
public RecordUnknown(RecordReader rr)
|
||||
{
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16(-2);
|
||||
RDATA = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* http://tools.ietf.org/rfc/rfc1712.txt
|
||||
*
|
||||
3. RDATA Format
|
||||
|
||||
MSB LSB
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ LONGITUDE /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ LATITUDE /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ ALTITUDE /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
LONGITUDE The real number describing the longitude encoded as a
|
||||
printable string. The precision is limited by 256 charcters
|
||||
within the range -90..90 degrees. Positive numbers
|
||||
indicate locations north of the equator.
|
||||
|
||||
LATITUDE The real number describing the latitude encoded as a
|
||||
printable string. The precision is limited by 256 charcters
|
||||
within the range -180..180 degrees. Positive numbers
|
||||
indicate locations east of the prime meridian.
|
||||
|
||||
ALTITUDE The real number describing the altitude (in meters) from
|
||||
mean sea-level encoded as a printable string. The precision
|
||||
is limited by 256 charcters. Positive numbers indicate
|
||||
locations above mean sea-level.
|
||||
|
||||
Latitude/Longitude/Altitude values are encoded as strings as to avoid
|
||||
the precision limitations imposed by encoding as unsigned integers.
|
||||
Although this might not be considered optimal, it allows for a very
|
||||
high degree of precision with an acceptable average encoded record
|
||||
length.
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordGPOS : Record
|
||||
{
|
||||
public string LONGITUDE;
|
||||
public string LATITUDE;
|
||||
public string ALTITUDE;
|
||||
|
||||
public RecordGPOS(RecordReader rr)
|
||||
{
|
||||
LONGITUDE = rr.ReadString();
|
||||
LATITUDE = rr.ReadString();
|
||||
ALTITUDE = rr.ReadString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2}",
|
||||
LONGITUDE,
|
||||
LATITUDE,
|
||||
ALTITUDE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
3.3.4. MD RDATA format (Obsolete)
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ MADNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
MADNAME A <domain-name> which specifies a host which has a mail
|
||||
agent for the domain which should be able to deliver
|
||||
mail for the domain.
|
||||
|
||||
MD records cause additional section processing which looks up an A type
|
||||
record corresponding to MADNAME.
|
||||
|
||||
MD is obsolete. See the definition of MX and [RFC-974] for details of
|
||||
the new scheme. The recommended policy for dealing with MD RRs found in
|
||||
a master file is to reject them, or to convert them to MX RRs with a
|
||||
preference of 0.
|
||||
* */
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordMD : Record
|
||||
{
|
||||
public string MADNAME;
|
||||
|
||||
public RecordMD(RecordReader rr)
|
||||
{
|
||||
MADNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return MADNAME;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
*
|
||||
3.3.5. MF RDATA format (Obsolete)
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ MADNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
MADNAME A <domain-name> which specifies a host which has a mail
|
||||
agent for the domain which will accept mail for
|
||||
forwarding to the domain.
|
||||
|
||||
MF records cause additional section processing which looks up an A type
|
||||
record corresponding to MADNAME.
|
||||
|
||||
MF is obsolete. See the definition of MX and [RFC-974] for details ofw
|
||||
the new scheme. The recommended policy for dealing with MD RRs found in
|
||||
a master file is to reject them, or to convert them to MX RRs with a
|
||||
preference of 10. */
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordMF : Record
|
||||
{
|
||||
public string MADNAME;
|
||||
|
||||
public RecordMF(RecordReader rr)
|
||||
{
|
||||
MADNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return MADNAME;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* http://tools.ietf.org/rfc/rfc1348.txt
|
||||
|
||||
* The NSAP-PTR RR
|
||||
|
||||
The NSAP-PTR RR is defined with mnemonic NSAP-PTR and a type code 23
|
||||
(decimal).
|
||||
|
||||
Its function is analogous to the PTR record used for IP addresses [4,7].
|
||||
|
||||
NSAP-PTR has the following format:
|
||||
|
||||
<NSAP-suffix> <ttl> <class> NSAP-PTR <owner>
|
||||
|
||||
All fields are required.
|
||||
|
||||
<NSAP-suffix> enumerates the actual octet values assigned by the
|
||||
assigning authority for the LOCAL network. Its format in master
|
||||
files is a <character-string> syntactically identical to that used in
|
||||
TXT and HINFO.
|
||||
|
||||
The format of NSAP-PTR is class insensitive. NSAP-PTR RR causes no
|
||||
additional section processing.
|
||||
|
||||
For example:
|
||||
|
||||
In net ff08000574.nsap-in-addr.arpa:
|
||||
|
||||
444433332222111199990123000000ff NSAP-PTR foo.bar.com.
|
||||
|
||||
Or in net 11110031f67293.nsap-in-addr.arpa:
|
||||
|
||||
67894444333322220000 NSAP-PTR host.school.de.
|
||||
|
||||
The RR data is the ASCII representation of the digits. It is encoded
|
||||
as a <character-string>.
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNSAPPTR : Record
|
||||
{
|
||||
public string OWNER;
|
||||
|
||||
public RecordNSAPPTR(RecordReader rr)
|
||||
{
|
||||
OWNER = rr.ReadString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}",OWNER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
/*
|
||||
* http://tools.ietf.org/rfc/rfc2065.txt
|
||||
*
|
||||
5.2 NXT RDATA Format
|
||||
|
||||
The RDATA for an NXT RR consists simply of a domain name followed by
|
||||
a bit map.
|
||||
|
||||
The type number for the NXT RR is 30.
|
||||
|
||||
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
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| next domain name /
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| type bit map /
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
The NXT RR type bit map is one bit per RR type present for the owner
|
||||
name similar to the WKS socket bit map. The first bit represents RR
|
||||
type zero (an illegal type which should not be present.) A one bit
|
||||
indicates that at least one RR of that type is present for the owner
|
||||
name. A zero indicates that no such RR is present. All bits not
|
||||
specified because they are beyond the end of the bit map are assumed
|
||||
to be zero. Note that bit 30, for NXT, will always be on so the
|
||||
minimum bit map length is actually four octets. The NXT bit map
|
||||
should be printed as a list of RR type mnemonics or decimal numbers
|
||||
similar to the WKS RR.
|
||||
|
||||
The domain name may be compressed with standard DNS name compression
|
||||
when being transmitted over the network. The size of the bit map can
|
||||
be inferred from the RDLENGTH and the length of the next domain name.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNXT : Record
|
||||
{
|
||||
public string NEXTDOMAINNAME;
|
||||
public byte[] BITMAP;
|
||||
|
||||
public RecordNXT(RecordReader rr)
|
||||
{
|
||||
ushort length = rr.ReadUInt16(-2);
|
||||
NEXTDOMAINNAME = rr.ReadDomainName();
|
||||
length -= (ushort)rr.Position;
|
||||
BITMAP = new byte[length];
|
||||
BITMAP = rr.ReadBytes(length);
|
||||
}
|
||||
|
||||
private bool IsSet(int bitNr)
|
||||
{
|
||||
int intByte = (int)(bitNr / 8);
|
||||
int intOffset = (bitNr % 8);
|
||||
byte b = BITMAP[intByte];
|
||||
int intTest = 1 << intOffset;
|
||||
if ((b & intTest) == 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int bitNr = 1; bitNr < (BITMAP.Length * 8); bitNr++)
|
||||
{
|
||||
if (IsSet(bitNr))
|
||||
sb.Append(" " + (Type)bitNr);
|
||||
}
|
||||
return string.Format("{0}{1}", NEXTDOMAINNAME, sb.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
// Stuff records are made of
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public abstract class Record
|
||||
{
|
||||
/// <summary>
|
||||
/// The Resource Record this RDATA record belongs to
|
||||
/// </summary>
|
||||
public RR RR;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
3.4.1. A RDATA format
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| ADDRESS |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
ADDRESS A 32 bit Internet address.
|
||||
|
||||
Hosts that have multiple Internet addresses will have multiple A
|
||||
records.
|
||||
*
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordA : Record
|
||||
{
|
||||
public System.Net.IPAddress Address;
|
||||
|
||||
public RecordA(RecordReader rr)
|
||||
{
|
||||
System.Net.IPAddress.TryParse(string.Format("{0}.{1}.{2}.{3}",
|
||||
rr.ReadByte(),
|
||||
rr.ReadByte(),
|
||||
rr.ReadByte(),
|
||||
rr.ReadByte()), out this.Address);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Address.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
|
||||
#region Rfc info
|
||||
/*
|
||||
2.2 AAAA data format
|
||||
|
||||
A 128 bit IPv6 address is encoded in the data portion of an AAAA
|
||||
resource record in network byte order (high-order byte first).
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordAAAA : Record
|
||||
{
|
||||
public System.Net.IPAddress Address;
|
||||
|
||||
public RecordAAAA(RecordReader rr)
|
||||
{
|
||||
System.Net.IPAddress.TryParse(
|
||||
string.Format("{0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}:{6:x}:{7:x}",
|
||||
rr.ReadUInt16(),
|
||||
rr.ReadUInt16(),
|
||||
rr.ReadUInt16(),
|
||||
rr.ReadUInt16(),
|
||||
rr.ReadUInt16(),
|
||||
rr.ReadUInt16(),
|
||||
rr.ReadUInt16(),
|
||||
rr.ReadUInt16()), out this.Address);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Address.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
using System;
|
||||
/* http://tools.ietf.org/rfc/rfc1183.txt
|
||||
|
||||
* 1. AFS Data Base location
|
||||
|
||||
This section defines an extension of the DNS to locate servers both
|
||||
for AFS (AFS is a registered trademark of Transarc Corporation) and
|
||||
for the Open Software Foundation's (OSF) Distributed Computing
|
||||
Environment (DCE) authenticated naming system using HP/Apollo's NCA,
|
||||
both to be components of the OSF DCE. The discussion assumes that
|
||||
the reader is familiar with AFS [5] and NCA [6].
|
||||
|
||||
The AFS (originally the Andrew File System) system uses the DNS to
|
||||
map from a domain name to the name of an AFS cell database server.
|
||||
The DCE Naming service uses the DNS for a similar function: mapping
|
||||
from the domain name of a cell to authenticated name servers for that
|
||||
cell. The method uses a new RR type with mnemonic AFSDB and type
|
||||
code of 18 (decimal).
|
||||
|
||||
AFSDB has the following format:
|
||||
|
||||
<owner> <ttl> <class> AFSDB <subtype> <hostname>
|
||||
|
||||
Both RDATA fields are required in all AFSDB RRs. The <subtype> field
|
||||
is a 16 bit integer. The <hostname> field is a domain name of a host
|
||||
that has a server for the cell named by the owner name of the RR.
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordAFSDB : Record
|
||||
{
|
||||
public ushort SUBTYPE;
|
||||
public string HOSTNAME;
|
||||
|
||||
public RecordAFSDB(RecordReader rr)
|
||||
{
|
||||
SUBTYPE = rr.ReadUInt16();
|
||||
//HOSTNAME = rr.ReadString();
|
||||
HOSTNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}",
|
||||
SUBTYPE,
|
||||
HOSTNAME);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
*
|
||||
3.3.1. CNAME RDATA format
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ CNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
CNAME A <domain-name> which specifies the canonical or primary
|
||||
name for the owner. The owner name is an alias.
|
||||
|
||||
CNAME RRs cause no additional section processing, but name servers may
|
||||
choose to restart the query at the canonical name in certain cases. See
|
||||
the description of name server logic in [RFC-1034] for details.
|
||||
|
||||
*
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordCNAME : Record
|
||||
{
|
||||
public string CNAME;
|
||||
|
||||
public RecordCNAME(RecordReader rr)
|
||||
{
|
||||
CNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return CNAME;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* http://tools.ietf.org/rfc/rfc2672.txt
|
||||
*
|
||||
3. The DNAME Resource Record
|
||||
|
||||
The DNAME RR has mnemonic DNAME and type code 39 (decimal).
|
||||
DNAME has the following format:
|
||||
|
||||
<owner> <ttl> <class> DNAME <target>
|
||||
|
||||
The format is not class-sensitive. All fields are required. The
|
||||
RDATA field <target> is a <domain-name> [DNSIS].
|
||||
|
||||
*
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordDNAME : Record
|
||||
{
|
||||
public string TARGET;
|
||||
|
||||
public RecordDNAME(RecordReader rr)
|
||||
{
|
||||
TARGET = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return TARGET;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
/*
|
||||
* http://tools.ietf.org/rfc/rfc3658.txt
|
||||
*
|
||||
2.4. Wire Format of the DS record
|
||||
|
||||
The DS (type=43) record contains these fields: key tag, algorithm,
|
||||
digest type, and the digest of a public key KEY record that is
|
||||
allowed and/or used to sign the child's apex KEY RRset. Other keys
|
||||
MAY sign the child's apex KEY RRset.
|
||||
|
||||
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
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| key tag | algorithm | Digest type |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| digest (length depends on type) |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| (SHA-1 digest is 20 bytes) |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
|
||||
| |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
|
||||
| |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordDS : Record
|
||||
{
|
||||
public UInt16 KEYTAG;
|
||||
public byte ALGORITHM;
|
||||
public byte DIGESTTYPE;
|
||||
public byte[] DIGEST;
|
||||
|
||||
public RecordDS(RecordReader rr)
|
||||
{
|
||||
ushort length = rr.ReadUInt16(-2);
|
||||
KEYTAG = rr.ReadUInt16();
|
||||
ALGORITHM = rr.ReadByte();
|
||||
DIGESTTYPE = rr.ReadByte();
|
||||
length -= 4;
|
||||
DIGEST = new byte[length];
|
||||
DIGEST = rr.ReadBytes(length);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int intI = 0; intI < DIGEST.Length; intI++)
|
||||
sb.AppendFormat("{0:x2}", DIGEST[intI]);
|
||||
return string.Format("{0} {1} {2} {3}",
|
||||
KEYTAG,
|
||||
ALGORITHM,
|
||||
DIGESTTYPE,
|
||||
sb.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
using System;
|
||||
|
||||
/*
|
||||
3.3.2. HINFO RDATA format
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ CPU /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ OS /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
CPU A <character-string> which specifies the CPU type.
|
||||
|
||||
OS A <character-string> which specifies the operating
|
||||
system type.
|
||||
|
||||
Standard values for CPU and OS can be found in [RFC-1010].
|
||||
|
||||
HINFO records are used to acquire general information about a host. The
|
||||
main use is for protocols such as FTP that can use special procedures
|
||||
when talking between machines or operating systems of the same type.
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordHINFO : Record
|
||||
{
|
||||
public string CPU;
|
||||
public string OS;
|
||||
|
||||
public RecordHINFO(RecordReader rr)
|
||||
{
|
||||
CPU = rr.ReadString();
|
||||
OS = rr.ReadString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("CPU={0} OS={1}",CPU,OS);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
using System;
|
||||
/* http://tools.ietf.org/rfc/rfc1183.txt
|
||||
|
||||
3.2. The ISDN RR
|
||||
|
||||
The ISDN RR is defined with mnemonic ISDN and type code 20 (decimal).
|
||||
|
||||
An ISDN (Integrated Service Digital Network) number is simply a
|
||||
telephone number. The intent of the members of the CCITT is to
|
||||
upgrade all telephone and data network service to a common service.
|
||||
|
||||
The numbering plan (E.163/E.164) is the same as the familiar
|
||||
international plan for POTS (an un-official acronym, meaning Plain
|
||||
Old Telephone Service). In E.166, CCITT says "An E.163/E.164
|
||||
telephony subscriber may become an ISDN subscriber without a number
|
||||
change."
|
||||
|
||||
ISDN has the following format:
|
||||
|
||||
<owner> <ttl> <class> ISDN <ISDN-address> <sa>
|
||||
|
||||
The <ISDN-address> field is required; <sa> is optional.
|
||||
|
||||
<ISDN-address> identifies the ISDN number of <owner> and DDI (Direct
|
||||
Dial In) if any, as defined by E.164 [8] and E.163 [7], the ISDN and
|
||||
PSTN (Public Switched Telephone Network) numbering plan. E.163
|
||||
defines the country codes, and E.164 the form of the addresses. Its
|
||||
format in master files is a <character-string> syntactically
|
||||
identical to that used in TXT and HINFO.
|
||||
|
||||
<sa> specifies the subaddress (SA). The format of <sa> in master
|
||||
files is a <character-string> syntactically identical to that used in
|
||||
TXT and HINFO.
|
||||
|
||||
The format of ISDN is class insensitive. ISDN RRs cause no
|
||||
additional section processing.
|
||||
|
||||
The <ISDN-address> is a string of characters, normally decimal
|
||||
digits, beginning with the E.163 country code and ending with the DDI
|
||||
if any. Note that ISDN, in Q.931, permits any IA5 character in the
|
||||
general case.
|
||||
|
||||
The <sa> is a string of hexadecimal digits. For digits 0-9, the
|
||||
concrete encoding in the Q.931 call setup information element is
|
||||
identical to BCD.
|
||||
|
||||
For example:
|
||||
|
||||
Relay.Prime.COM. IN ISDN 150862028003217
|
||||
sh.Prime.COM. IN ISDN 150862028003217 004
|
||||
|
||||
(Note: "1" is the country code for the North American Integrated
|
||||
Numbering Area, i.e., the system of "area codes" familiar to people
|
||||
in those countries.)
|
||||
|
||||
The RR data is the ASCII representation of the digits. It is encoded
|
||||
as one or two <character-string>s, i.e., count followed by
|
||||
characters.
|
||||
|
||||
CCITT recommendation E.166 [9] defines prefix escape codes for the
|
||||
representation of ISDN (E.163/E.164) addresses in X.121, and PSDN
|
||||
(X.121) addresses in E.164. It specifies that the exact codes are a
|
||||
"national matter", i.e., different on different networks. A host
|
||||
connected to the ISDN may be able to use both the X25 and ISDN
|
||||
addresses, with the local prefix added.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordISDN : Record
|
||||
{
|
||||
public string ISDNADDRESS;
|
||||
public string SA;
|
||||
|
||||
public RecordISDN(RecordReader rr)
|
||||
{
|
||||
ISDNADDRESS = rr.ReadString();
|
||||
SA = rr.ReadString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}",
|
||||
ISDNADDRESS,
|
||||
SA);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
using System;
|
||||
|
||||
#region Rfc info
|
||||
/* http://www.ietf.org/rfc/rfc2535.txt
|
||||
*
|
||||
3.1 KEY RDATA format
|
||||
|
||||
The RDATA for a KEY RR consists of flags, a protocol octet, the
|
||||
algorithm number octet, and the public key itself. The format is as
|
||||
follows:
|
||||
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
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| flags | protocol | algorithm |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| /
|
||||
/ public key /
|
||||
/ /
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
|
||||
|
||||
The KEY RR is not intended for storage of certificates and a separate
|
||||
certificate RR has been developed for that purpose, defined in [RFC
|
||||
2538].
|
||||
|
||||
The meaning of the KEY RR owner name, flags, and protocol octet are
|
||||
described in Sections 3.1.1 through 3.1.5 below. The flags and
|
||||
algorithm must be examined before any data following the algorithm
|
||||
octet as they control the existence and format of any following data.
|
||||
The algorithm and public key fields are described in Section 3.2.
|
||||
The format of the public key is algorithm dependent.
|
||||
|
||||
KEY RRs do not specify their validity period but their authenticating
|
||||
SIG RR(s) do as described in Section 4 below.
|
||||
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordKEY : Record
|
||||
{
|
||||
public UInt16 FLAGS;
|
||||
public byte PROTOCOL;
|
||||
public byte ALGORITHM;
|
||||
public string PUBLICKEY;
|
||||
|
||||
public RecordKEY(RecordReader rr)
|
||||
{
|
||||
FLAGS = rr.ReadUInt16();
|
||||
PROTOCOL = rr.ReadByte();
|
||||
ALGORITHM = rr.ReadByte();
|
||||
PUBLICKEY = rr.ReadString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2} \"{3}\"",
|
||||
FLAGS,
|
||||
PROTOCOL,
|
||||
ALGORITHM,
|
||||
PUBLICKEY);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* http://tools.ietf.org/rfc/rfc2230.txt
|
||||
*
|
||||
* 3.1 KX RDATA format
|
||||
|
||||
The KX DNS record has the following RDATA format:
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| PREFERENCE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ EXCHANGER /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
PREFERENCE A 16 bit non-negative integer which specifies the
|
||||
preference given to this RR among other KX records
|
||||
at the same owner. Lower values are preferred.
|
||||
|
||||
EXCHANGER A <domain-name> which specifies a host willing to
|
||||
act as a mail exchange for the owner name.
|
||||
|
||||
KX records MUST cause type A additional section processing for the
|
||||
host specified by EXCHANGER. In the event that the host processing
|
||||
the DNS transaction supports IPv6, KX records MUST also cause type
|
||||
AAAA additional section processing.
|
||||
|
||||
The KX RDATA field MUST NOT be compressed.
|
||||
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordKX : Record, IComparable
|
||||
{
|
||||
public ushort PREFERENCE;
|
||||
public string EXCHANGER;
|
||||
|
||||
public RecordKX(RecordReader rr)
|
||||
{
|
||||
PREFERENCE = rr.ReadUInt16();
|
||||
EXCHANGER = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}", PREFERENCE, EXCHANGER);
|
||||
}
|
||||
|
||||
public int CompareTo(object objA)
|
||||
{
|
||||
RecordKX recordKX = objA as RecordKX;
|
||||
if (recordKX == null)
|
||||
return -1;
|
||||
else if (this.PREFERENCE > recordKX.PREFERENCE)
|
||||
return 1;
|
||||
else if (this.PREFERENCE < recordKX.PREFERENCE)
|
||||
return -1;
|
||||
else // they are the same, now compare case insensitive names
|
||||
return string.Compare(this.EXCHANGER, recordKX.EXCHANGER, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
/*
|
||||
* http://www.ietf.org/rfc/rfc1876.txt
|
||||
*
|
||||
2. RDATA Format
|
||||
|
||||
MSB LSB
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
0| VERSION | SIZE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
2| HORIZ PRE | VERT PRE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
4| LATITUDE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
6| LATITUDE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
8| LONGITUDE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
10| LONGITUDE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
12| ALTITUDE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
14| ALTITUDE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
VERSION Version number of the representation. This must be zero.
|
||||
Implementations are required to check this field and make
|
||||
no assumptions about the format of unrecognized versions.
|
||||
|
||||
SIZE The diameter of a sphere enclosing the described entity, in
|
||||
centimeters, expressed as a pair of four-bit unsigned
|
||||
integers, each ranging from zero to nine, with the most
|
||||
significant four bits representing the base and the second
|
||||
number representing the power of ten by which to multiply
|
||||
the base. This allows sizes from 0e0 (<1cm) to 9e9
|
||||
(90,000km) to be expressed. This representation was chosen
|
||||
such that the hexadecimal representation can be read by
|
||||
eye; 0x15 = 1e5. Four-bit values greater than 9 are
|
||||
undefined, as are values with a base of zero and a non-zero
|
||||
exponent.
|
||||
|
||||
Since 20000000m (represented by the value 0x29) is greater
|
||||
than the equatorial diameter of the WGS 84 ellipsoid
|
||||
(12756274m), it is therefore suitable for use as a
|
||||
"worldwide" size.
|
||||
|
||||
HORIZ PRE The horizontal precision of the data, in centimeters,
|
||||
expressed using the same representation as SIZE. This is
|
||||
the diameter of the horizontal "circle of error", rather
|
||||
than a "plus or minus" value. (This was chosen to match
|
||||
the interpretation of SIZE; to get a "plus or minus" value,
|
||||
divide by 2.)
|
||||
|
||||
VERT PRE The vertical precision of the data, in centimeters,
|
||||
expressed using the sane representation as for SIZE. This
|
||||
is the total potential vertical error, rather than a "plus
|
||||
or minus" value. (This was chosen to match the
|
||||
interpretation of SIZE; to get a "plus or minus" value,
|
||||
divide by 2.) Note that if altitude above or below sea
|
||||
level is used as an approximation for altitude relative to
|
||||
the [WGS 84] ellipsoid, the precision value should be
|
||||
adjusted.
|
||||
|
||||
LATITUDE The latitude of the center of the sphere described by the
|
||||
SIZE field, expressed as a 32-bit integer, most significant
|
||||
octet first (network standard byte order), in thousandths
|
||||
of a second of arc. 2^31 represents the equator; numbers
|
||||
above that are north latitude.
|
||||
|
||||
LONGITUDE The longitude of the center of the sphere described by the
|
||||
SIZE field, expressed as a 32-bit integer, most significant
|
||||
octet first (network standard byte order), in thousandths
|
||||
of a second of arc, rounded away from the prime meridian.
|
||||
2^31 represents the prime meridian; numbers above that are
|
||||
east longitude.
|
||||
|
||||
ALTITUDE The altitude of the center of the sphere described by the
|
||||
SIZE field, expressed as a 32-bit integer, most significant
|
||||
octet first (network standard byte order), in centimeters,
|
||||
from a base of 100,000m below the [WGS 84] reference
|
||||
spheroid used by GPS (semimajor axis a=6378137.0,
|
||||
reciprocal flattening rf=298.257223563). Altitude above
|
||||
(or below) sea level may be used as an approximation of
|
||||
altitude relative to the the [WGS 84] spheroid, though due
|
||||
to the Earth's surface not being a perfect spheroid, there
|
||||
will be differences. (For example, the geoid (which sea
|
||||
level approximates) for the continental US ranges from 10
|
||||
meters to 50 meters below the [WGS 84] spheroid.
|
||||
Adjustments to ALTITUDE and/or VERT PRE will be necessary
|
||||
in most cases. The Defense Mapping Agency publishes geoid
|
||||
height values relative to the [WGS 84] ellipsoid.
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordLOC : Record
|
||||
{
|
||||
public byte VERSION;
|
||||
public byte SIZE;
|
||||
public byte HORIZPRE;
|
||||
public byte VERTPRE;
|
||||
public UInt32 LATITUDE;
|
||||
public UInt32 LONGITUDE;
|
||||
public UInt32 ALTITUDE;
|
||||
|
||||
private string SizeToString(byte s)
|
||||
{
|
||||
string strUnit = "cm";
|
||||
int intBase = s >> 4;
|
||||
int intPow = s & 0x0f;
|
||||
if (intPow >= 2)
|
||||
{
|
||||
intPow -= 2;
|
||||
strUnit = "m";
|
||||
}
|
||||
/*
|
||||
if (intPow >= 3)
|
||||
{
|
||||
intPow -= 3;
|
||||
strUnit = "km";
|
||||
}
|
||||
*/
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat("{0}", intBase);
|
||||
for (; intPow > 0; intPow--)
|
||||
sb.Append('0');
|
||||
sb.Append(strUnit);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string LonToTime(UInt32 r)
|
||||
{
|
||||
UInt32 Mid = 2147483648; // 2^31
|
||||
char Dir = 'E';
|
||||
if (r > Mid)
|
||||
{
|
||||
Dir = 'W';
|
||||
r -= Mid;
|
||||
}
|
||||
double h = r / (360000.0 * 10.0);
|
||||
double m = 60.0 * (h - (int)h);
|
||||
double s = 60.0 * (m - (int)m);
|
||||
return string.Format("{0} {1} {2:0.000} {3}", (int)h, (int)m, s, Dir);
|
||||
}
|
||||
|
||||
private string ToTime(UInt32 r, char Below,char Above)
|
||||
{
|
||||
UInt32 Mid = 2147483648; // 2^31
|
||||
char Dir = '?';
|
||||
if (r > Mid)
|
||||
{
|
||||
Dir = Above;
|
||||
r -= Mid;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dir = Below;
|
||||
r = Mid - r;
|
||||
}
|
||||
double h = r / (360000.0 * 10.0);
|
||||
double m = 60.0 * (h - (int)h);
|
||||
double s = 60.0 * (m - (int)m);
|
||||
return string.Format("{0} {1} {2:0.000} {3}", (int)h, (int)m, s, Dir);
|
||||
}
|
||||
|
||||
private string ToAlt(UInt32 a)
|
||||
{
|
||||
double alt = (a / 100.0) - 100000.00;
|
||||
return string.Format("{0:0.00}m", alt);
|
||||
}
|
||||
|
||||
public RecordLOC(RecordReader rr)
|
||||
{
|
||||
VERSION = rr.ReadByte(); // must be 0!
|
||||
SIZE = rr.ReadByte();
|
||||
HORIZPRE = rr.ReadByte();
|
||||
VERTPRE = rr.ReadByte();
|
||||
LATITUDE = rr.ReadUInt32();
|
||||
LONGITUDE = rr.ReadUInt32();
|
||||
ALTITUDE = rr.ReadUInt32();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2} {3} {4} {5}",
|
||||
ToTime(LATITUDE,'S','N'),
|
||||
ToTime(LONGITUDE,'W','E'),
|
||||
ToAlt(ALTITUDE),
|
||||
SizeToString(SIZE),
|
||||
SizeToString(HORIZPRE),
|
||||
SizeToString(VERTPRE));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
3.3.3. MB RDATA format (EXPERIMENTAL)
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ MADNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
MADNAME A <domain-name> which specifies a host which has the
|
||||
specified mailbox.
|
||||
|
||||
MB records cause additional section processing which looks up an A type
|
||||
RRs corresponding to MADNAME.
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordMB : Record
|
||||
{
|
||||
public string MADNAME;
|
||||
|
||||
public RecordMB(RecordReader rr)
|
||||
{
|
||||
MADNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return MADNAME;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
3.3.6. MG RDATA format (EXPERIMENTAL)
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ MGMNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
MGMNAME A <domain-name> which specifies a mailbox which is a
|
||||
member of the mail group specified by the domain name.
|
||||
|
||||
MG records cause no additional section processing.
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordMG : Record
|
||||
{
|
||||
public string MGMNAME;
|
||||
|
||||
public RecordMG(RecordReader rr)
|
||||
{
|
||||
MGMNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return MGMNAME;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
3.3.7. MINFO RDATA format (EXPERIMENTAL)
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ RMAILBX /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ EMAILBX /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
RMAILBX A <domain-name> which specifies a mailbox which is
|
||||
responsible for the mailing list or mailbox. If this
|
||||
domain name names the root, the owner of the MINFO RR is
|
||||
responsible for itself. Note that many existing mailing
|
||||
lists use a mailbox X-request for the RMAILBX field of
|
||||
mailing list X, e.g., Msgroup-request for Msgroup. This
|
||||
field provides a more general mechanism.
|
||||
|
||||
|
||||
EMAILBX A <domain-name> which specifies a mailbox which is to
|
||||
receive error messages related to the mailing list or
|
||||
mailbox specified by the owner of the MINFO RR (similar
|
||||
to the ERRORS-TO: field which has been proposed). If
|
||||
this domain name names the root, errors should be
|
||||
returned to the sender of the message.
|
||||
|
||||
MINFO records cause no additional section processing. Although these
|
||||
records can be associated with a simple mailbox, they are usually used
|
||||
with a mailing list.
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordMINFO : Record
|
||||
{
|
||||
public string RMAILBX;
|
||||
public string EMAILBX;
|
||||
|
||||
public RecordMINFO(RecordReader rr)
|
||||
{
|
||||
RMAILBX = rr.ReadDomainName();
|
||||
EMAILBX = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}",RMAILBX,EMAILBX);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
3.3.8. MR RDATA format (EXPERIMENTAL)
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ NEWNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
NEWNAME A <domain-name> which specifies a mailbox which is the
|
||||
proper rename of the specified mailbox.
|
||||
|
||||
MR records cause no additional section processing. The main use for MR
|
||||
is as a forwarding entry for a user who has moved to a different
|
||||
mailbox.
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordMR : Record
|
||||
{
|
||||
public string NEWNAME;
|
||||
|
||||
public RecordMR(RecordReader rr)
|
||||
{
|
||||
NEWNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return NEWNAME;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
/*
|
||||
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].
|
||||
*/
|
||||
|
||||
public class RecordMX : Record, IComparable
|
||||
{
|
||||
public ushort PREFERENCE;
|
||||
public string EXCHANGE;
|
||||
|
||||
public RecordMX(RecordReader rr)
|
||||
{
|
||||
PREFERENCE = rr.ReadUInt16();
|
||||
EXCHANGE = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}", PREFERENCE, EXCHANGE);
|
||||
}
|
||||
|
||||
public int CompareTo(object objA)
|
||||
{
|
||||
RecordMX recordMX = objA as RecordMX;
|
||||
if (recordMX == null)
|
||||
return -1;
|
||||
else if (this.PREFERENCE > recordMX.PREFERENCE)
|
||||
return 1;
|
||||
else if (this.PREFERENCE < recordMX.PREFERENCE)
|
||||
return -1;
|
||||
else // they are the same, now compare case insensitive names
|
||||
return string.Compare(this.EXCHANGE, recordMX.EXCHANGE, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* http://www.faqs.org/rfcs/rfc2915.html
|
||||
*
|
||||
8. DNS Packet Format
|
||||
|
||||
The packet format for the NAPTR record is:
|
||||
|
||||
1 1 1 1 1 1
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| ORDER |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| PREFERENCE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ FLAGS /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ SERVICES /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ REGEXP /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ REPLACEMENT /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
FLAGS A <character-string> which contains various flags.
|
||||
|
||||
SERVICES A <character-string> which contains protocol and service
|
||||
identifiers.
|
||||
|
||||
REGEXP A <character-string> which contains a regular expression.
|
||||
|
||||
REPLACEMENT A <domain-name> which specifies the new value in the
|
||||
case where the regular expression is a simple replacement
|
||||
operation.
|
||||
|
||||
<character-string> and <domain-name> as used here are defined in
|
||||
RFC1035 [1].
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNAPTR : Record
|
||||
{
|
||||
public ushort ORDER;
|
||||
public ushort PREFERENCE;
|
||||
public string FLAGS;
|
||||
public string SERVICES;
|
||||
public string REGEXP;
|
||||
public string REPLACEMENT;
|
||||
|
||||
public RecordNAPTR(RecordReader rr)
|
||||
{
|
||||
ORDER = rr.ReadUInt16();
|
||||
PREFERENCE = rr.ReadUInt16();
|
||||
FLAGS = rr.ReadString();
|
||||
SERVICES = rr.ReadString();
|
||||
REGEXP = rr.ReadString();
|
||||
REPLACEMENT = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} \"{2}\" \"{3}\" \"{4}\" {5}",
|
||||
ORDER,
|
||||
PREFERENCE,
|
||||
FLAGS,
|
||||
SERVICES,
|
||||
REGEXP,
|
||||
REPLACEMENT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
3.3.11. NS RDATA format
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ NSDNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
NSDNAME A <domain-name> which specifies a host which should be
|
||||
authoritative for the specified class and domain.
|
||||
|
||||
NS records cause both the usual additional section processing to locate
|
||||
a type A record, and, when used in a referral, a special search of the
|
||||
zone in which they reside for glue information.
|
||||
|
||||
The NS RR states that the named host should be expected to have a zone
|
||||
starting at owner name of the specified class. Note that the class may
|
||||
not indicate the protocol family which should be used to communicate
|
||||
with the host, although it is typically a strong hint. For example,
|
||||
hosts which are name servers for either Internet (IN) or Hesiod (HS)
|
||||
class information are normally queried using IN class protocols.
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNS : Record
|
||||
{
|
||||
public string NSDNAME;
|
||||
|
||||
public RecordNS(RecordReader rr)
|
||||
{
|
||||
NSDNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return NSDNAME;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
/*
|
||||
* http://tools.ietf.org/rfc/rfc1348.txt
|
||||
* http://tools.ietf.org/html/rfc1706
|
||||
*
|
||||
* |--------------|
|
||||
| <-- IDP --> |
|
||||
|--------------|-------------------------------------|
|
||||
| AFI | IDI | <-- DSP --> |
|
||||
|-----|--------|-------------------------------------|
|
||||
| 47 | 0005 | DFI | AA |Rsvd | RD |Area | ID |Sel |
|
||||
|-----|--------|-----|----|-----|----|-----|----|----|
|
||||
octets | 1 | 2 | 1 | 3 | 2 | 2 | 2 | 6 | 1 |
|
||||
|-----|--------|-----|----|-----|----|-----|----|----|
|
||||
|
||||
IDP Initial Domain Part
|
||||
AFI Authority and Format Identifier
|
||||
IDI Initial Domain Identifier
|
||||
DSP Domain Specific Part
|
||||
DFI DSP Format Identifier
|
||||
AA Administrative Authority
|
||||
Rsvd Reserved
|
||||
RD Routing Domain Identifier
|
||||
Area Area Identifier
|
||||
ID System Identifier
|
||||
SEL NSAP Selector
|
||||
|
||||
Figure 1: GOSIP Version 2 NSAP structure.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNSAP : Record
|
||||
{
|
||||
public ushort LENGTH;
|
||||
public byte[] NSAPADDRESS;
|
||||
|
||||
public RecordNSAP(RecordReader rr)
|
||||
{
|
||||
LENGTH = rr.ReadUInt16();
|
||||
NSAPADDRESS = rr.ReadBytes(LENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat("{0} ", LENGTH);
|
||||
for (int intI = 0; intI < NSAPADDRESS.Length; intI++)
|
||||
sb.AppendFormat("{0:X00}", NSAPADDRESS[intI]);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string ToGOSIPV2()
|
||||
{
|
||||
return string.Format("{0:X}.{1:X}.{2:X}.{3:X}.{4:X}.{5:X}.{6:X}{7:X}.{8:X}",
|
||||
NSAPADDRESS[0], // AFI
|
||||
NSAPADDRESS[1] << 8 | NSAPADDRESS[2], // IDI
|
||||
NSAPADDRESS[3], // DFI
|
||||
NSAPADDRESS[4] << 16 | NSAPADDRESS[5] << 8 | NSAPADDRESS[6], // AA
|
||||
NSAPADDRESS[7] << 8 | NSAPADDRESS[8], // Rsvd
|
||||
NSAPADDRESS[9] << 8 | NSAPADDRESS[10],// RD
|
||||
NSAPADDRESS[11] << 8 | NSAPADDRESS[12],// Area
|
||||
NSAPADDRESS[13] << 16 | NSAPADDRESS[14] << 8 | NSAPADDRESS[15], // ID-High
|
||||
NSAPADDRESS[16] << 16 | NSAPADDRESS[17] << 8 | NSAPADDRESS[18], // ID-Low
|
||||
NSAPADDRESS[19]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
3.3.10. NULL RDATA format (EXPERIMENTAL)
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ <anything> /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
Anything at all may be in the RDATA field so long as it is 65535 octets
|
||||
or less.
|
||||
|
||||
NULL records cause no additional section processing. NULL RRs are not
|
||||
allowed in master files. NULLs are used as placeholders in some
|
||||
experimental extensions of the DNS.
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordNULL : Record
|
||||
{
|
||||
public byte[] ANYTHING;
|
||||
|
||||
public RecordNULL(RecordReader rr)
|
||||
{
|
||||
rr.Position -= 2;
|
||||
// re-read length
|
||||
ushort RDLENGTH = rr.ReadUInt16();
|
||||
ANYTHING = new byte[RDLENGTH];
|
||||
ANYTHING = rr.ReadBytes(RDLENGTH);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("...binary data... ({0}) bytes",ANYTHING.Length);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
3.3.12. PTR RDATA format
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ PTRDNAME /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
PTRDNAME A <domain-name> which points to some location in the
|
||||
domain name space.
|
||||
|
||||
PTR records cause no additional section processing. These RRs are used
|
||||
in special domains to point to some other location in the domain space.
|
||||
These records are simple data, and don't imply any special processing
|
||||
similar to that performed by CNAME, which identifies aliases. See the
|
||||
description of the IN-ADDR.ARPA domain for an example.
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordPTR : Record
|
||||
{
|
||||
public string PTRDNAME;
|
||||
|
||||
public RecordPTR(RecordReader rr)
|
||||
{
|
||||
PTRDNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return PTRDNAME;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* http://tools.ietf.org/rfc/rfc2163.txt
|
||||
*
|
||||
4. The new DNS resource record for MIXER mapping rules: PX
|
||||
|
||||
The specification of the Internet DNS (RFC1035) provides a number of
|
||||
specific resource records (RRs) to contain specific pieces of
|
||||
information. In particular they contain the Mail eXchanger (MX) RR
|
||||
and the host Address (A) records which are used by the Internet SMTP
|
||||
mailers. As we will store the RFC822 to X.400 mapping information in
|
||||
the already existing DNS name tree, we need to define a new DNS RR in
|
||||
order to avoid any possible clash or misuse of already existing data
|
||||
structures. The same new RR will also be used to store the mappings
|
||||
from X.400 to RFC822. More over the mapping information, i.e., the
|
||||
MCGAMs, has a specific format and syntax which require an appropriate
|
||||
data structure and processing. A further advantage of defining a new
|
||||
RR is the ability to include flexibility for some eventual future
|
||||
development.
|
||||
|
||||
The definition of the new 'PX' DNS resource record is:
|
||||
|
||||
class: IN (Internet)
|
||||
|
||||
name: PX (pointer to X.400/RFC822 mapping information)
|
||||
|
||||
value: 26
|
||||
|
||||
The PX RDATA format is:
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| PREFERENCE |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ MAP822 /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ MAPX400 /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
PREFERENCE A 16 bit integer which specifies the preference given to
|
||||
this RR among others at the same owner. Lower values
|
||||
are preferred;
|
||||
|
||||
MAP822 A <domain-name> element containing <rfc822-domain>, the
|
||||
RFC822 part of the MCGAM;
|
||||
|
||||
MAPX400 A <domain-name> element containing the value of
|
||||
<x400-in-domain-syntax> derived from the X.400 part of
|
||||
the MCGAM (see sect. 4.2);
|
||||
|
||||
PX records cause no additional section processing. The PX RR format
|
||||
is the usual one:
|
||||
|
||||
<name> [<class>] [<TTL>] <type> <RDATA>
|
||||
|
||||
When we store in DNS a 'table1' or a 'gate1' entry, then <name> will
|
||||
be an X.400 mail domain name in DNS syntax (see sect. 4.2). When we
|
||||
store a 'table2' or a 'gate2' table entry, <name> will be an RFC822
|
||||
mail domain name, including both fully qualified DNS domains and mail
|
||||
only domains (MX-only domains). All normal DNS conventions, like
|
||||
default values, wildcards, abbreviations and message compression,
|
||||
apply also for all the components of the PX RR. In particular <name>,
|
||||
MAP822 and MAPX400, as <domain-name> elements, must have the final
|
||||
"." (root) when they are fully qualified.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordPX : Record
|
||||
{
|
||||
public UInt16 PREFERENCE;
|
||||
public string MAP822;
|
||||
public string MAPX400;
|
||||
|
||||
public RecordPX(RecordReader rr)
|
||||
{
|
||||
PREFERENCE = rr.ReadUInt16();
|
||||
MAP822 = rr.ReadDomainName();
|
||||
MAPX400 = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2}",
|
||||
PREFERENCE,
|
||||
MAP822,
|
||||
MAPX400);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
using System;
|
||||
/* http://tools.ietf.org/rfc/rfc1183.txt
|
||||
|
||||
2.2. The Responsible Person RR
|
||||
|
||||
The method uses a new RR type with mnemonic RP and type code of 17
|
||||
(decimal).
|
||||
|
||||
RP has the following format:
|
||||
|
||||
<owner> <ttl> <class> RP <mbox-dname> <txt-dname>
|
||||
|
||||
Both RDATA fields are required in all RP RRs.
|
||||
|
||||
The first field, <mbox-dname>, is a domain name that specifies the
|
||||
mailbox for the responsible person. Its format in master files uses
|
||||
the DNS convention for mailbox encoding, identical to that used for
|
||||
the RNAME mailbox field in the SOA RR. The root domain name (just
|
||||
".") may be specified for <mbox-dname> to indicate that no mailbox is
|
||||
available.
|
||||
|
||||
The second field, <txt-dname>, is a domain name for which TXT RR's
|
||||
exist. A subsequent query can be performed to retrieve the
|
||||
associated TXT resource records at <txt-dname>. This provides a
|
||||
level of indirection so that the entity can be referred to from
|
||||
multiple places in the DNS. The root domain name (just ".") may be
|
||||
specified for <txt-dname> to indicate that the TXT_DNAME is absent,
|
||||
and no associated TXT RR exists.
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordRP : Record
|
||||
{
|
||||
public string MBOXDNAME;
|
||||
public string TXTDNAME;
|
||||
|
||||
public RecordRP(RecordReader rr)
|
||||
{
|
||||
//MBOXDNAME = rr.ReadString();
|
||||
MBOXDNAME = rr.ReadDomainName();
|
||||
TXTDNAME = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}",
|
||||
MBOXDNAME,
|
||||
TXTDNAME);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
using System;
|
||||
/* http://tools.ietf.org/rfc/rfc1183.txt
|
||||
|
||||
3.3. The Route Through RR
|
||||
|
||||
The Route Through RR is defined with mnemonic RT and type code 21
|
||||
(decimal).
|
||||
|
||||
The RT resource record provides a route-through binding for hosts
|
||||
that do not have their own direct wide area network addresses. It is
|
||||
used in much the same way as the MX RR.
|
||||
|
||||
RT has the following format:
|
||||
|
||||
<owner> <ttl> <class> RT <preference> <intermediate-host>
|
||||
|
||||
Both RDATA fields are required in all RT RRs.
|
||||
|
||||
The first field, <preference>, is a 16 bit integer, representing the
|
||||
preference of the route. Smaller numbers indicate more preferred
|
||||
routes.
|
||||
|
||||
<intermediate-host> is the domain name of a host which will serve as
|
||||
an intermediate in reaching the host specified by <owner>. The DNS
|
||||
RRs associated with <intermediate-host> are expected to include at
|
||||
least one A, X25, or ISDN record.
|
||||
|
||||
The format of the RT RR is class insensitive. RT records cause type
|
||||
X25, ISDN, and A additional section processing for <intermediate-
|
||||
host>.
|
||||
|
||||
For example,
|
||||
|
||||
sh.prime.com. IN RT 2 Relay.Prime.COM.
|
||||
IN RT 10 NET.Prime.COM.
|
||||
*.prime.com. IN RT 90 Relay.Prime.COM.
|
||||
|
||||
When a host is looking up DNS records to attempt to route a datagram,
|
||||
it first looks for RT records for the destination host, which point
|
||||
to hosts with address records (A, X25, ISDN) compatible with the wide
|
||||
area networks available to the host. If it is itself in the set of
|
||||
RT records, it discards any RTs with preferences higher or equal to
|
||||
its own. If there are no (remaining) RTs, it can then use address
|
||||
records of the destination itself.
|
||||
|
||||
Wild-card RTs are used exactly as are wild-card MXs. RT's do not
|
||||
"chain"; that is, it is not valid to use the RT RRs found for a host
|
||||
referred to by an RT.
|
||||
|
||||
The concrete encoding is identical to the MX RR.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordRT : Record
|
||||
{
|
||||
public ushort PREFERENCE;
|
||||
public string INTERMEDIATEHOST;
|
||||
|
||||
public RecordRT(RecordReader rr)
|
||||
{
|
||||
PREFERENCE = rr.ReadUInt16();
|
||||
INTERMEDIATEHOST = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}",
|
||||
PREFERENCE,
|
||||
INTERMEDIATEHOST);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
using System;
|
||||
|
||||
#region Rfc info
|
||||
/*
|
||||
* http://www.ietf.org/rfc/rfc2535.txt
|
||||
* 4.1 SIG RDATA Format
|
||||
|
||||
The RDATA portion of a SIG RR is as shown below. The integrity of
|
||||
the RDATA information is protected by the signature field.
|
||||
|
||||
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
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| type covered | algorithm | labels |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| original TTL |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| signature expiration |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| signature inception |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| key tag | |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ signer's name +
|
||||
| /
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-/
|
||||
/ /
|
||||
/ signature /
|
||||
/ /
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordSIG : Record
|
||||
{
|
||||
public UInt16 TYPECOVERED;
|
||||
public byte ALGORITHM;
|
||||
public byte LABELS;
|
||||
public UInt32 ORIGINALTTL;
|
||||
public UInt32 SIGNATUREEXPIRATION;
|
||||
public UInt32 SIGNATUREINCEPTION;
|
||||
public UInt16 KEYTAG;
|
||||
public string SIGNERSNAME;
|
||||
public string SIGNATURE;
|
||||
|
||||
public RecordSIG(RecordReader rr)
|
||||
{
|
||||
TYPECOVERED = rr.ReadUInt16();
|
||||
ALGORITHM = rr.ReadByte();
|
||||
LABELS = rr.ReadByte();
|
||||
ORIGINALTTL = rr.ReadUInt32();
|
||||
SIGNATUREEXPIRATION = rr.ReadUInt32();
|
||||
SIGNATUREINCEPTION = rr.ReadUInt32();
|
||||
KEYTAG = rr.ReadUInt16();
|
||||
SIGNERSNAME = rr.ReadDomainName();
|
||||
SIGNATURE = rr.ReadString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2} {3} {4} {5} {6} {7} \"{8}\"",
|
||||
TYPECOVERED,
|
||||
ALGORITHM,
|
||||
LABELS,
|
||||
ORIGINALTTL,
|
||||
SIGNATUREEXPIRATION,
|
||||
SIGNATUREINCEPTION,
|
||||
KEYTAG,
|
||||
SIGNERSNAME,
|
||||
SIGNATURE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
using System;
|
||||
|
||||
/*
|
||||
3.3.13. SOA RDATA format
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ MNAME /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ RNAME /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| SERIAL |
|
||||
| |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| REFRESH |
|
||||
| |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| RETRY |
|
||||
| |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| EXPIRE |
|
||||
| |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| MINIMUM |
|
||||
| |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
MNAME The <domain-name> of the name server that was the
|
||||
original or primary source of data for this zone.
|
||||
|
||||
RNAME A <domain-name> which specifies the mailbox of the
|
||||
person responsible for this zone.
|
||||
|
||||
SERIAL The unsigned 32 bit version number of the original copy
|
||||
of the zone. Zone transfers preserve this value. This
|
||||
value wraps and should be compared using sequence space
|
||||
arithmetic.
|
||||
|
||||
REFRESH A 32 bit time interval before the zone should be
|
||||
refreshed.
|
||||
|
||||
RETRY A 32 bit time interval that should elapse before a
|
||||
failed refresh should be retried.
|
||||
|
||||
EXPIRE A 32 bit time value that specifies the upper limit on
|
||||
the time interval that can elapse before the zone is no
|
||||
longer authoritative.
|
||||
|
||||
MINIMUM The unsigned 32 bit minimum TTL field that should be
|
||||
exported with any RR from this zone.
|
||||
|
||||
SOA records cause no additional section processing.
|
||||
|
||||
All times are in units of seconds.
|
||||
|
||||
Most of these fields are pertinent only for name server maintenance
|
||||
operations. However, MINIMUM is used in all query operations that
|
||||
retrieve RRs from a zone. Whenever a RR is sent in a response to a
|
||||
query, the TTL field is set to the maximum of the TTL field from the RR
|
||||
and the MINIMUM field in the appropriate SOA. Thus MINIMUM is a lower
|
||||
bound on the TTL field for all RRs in a zone. Note that this use of
|
||||
MINIMUM should occur when the RRs are copied into the response and not
|
||||
when the zone is loaded from a master file or via a zone transfer. The
|
||||
reason for this provison is to allow future dynamic update facilities to
|
||||
change the SOA RR with known semantics.
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordSOA : Record
|
||||
{
|
||||
public string MNAME;
|
||||
public string RNAME;
|
||||
public uint SERIAL;
|
||||
public uint REFRESH;
|
||||
public uint RETRY;
|
||||
public uint EXPIRE;
|
||||
public uint MINIMUM;
|
||||
|
||||
public RecordSOA(RecordReader rr)
|
||||
{
|
||||
MNAME = rr.ReadDomainName();
|
||||
RNAME = rr.ReadDomainName();
|
||||
SERIAL = rr.ReadUInt32();
|
||||
REFRESH = rr.ReadUInt32();
|
||||
RETRY = rr.ReadUInt32();
|
||||
EXPIRE = rr.ReadUInt32();
|
||||
MINIMUM = rr.ReadUInt32();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2} {3} {4} {5} {6}",
|
||||
MNAME,
|
||||
RNAME,
|
||||
SERIAL,
|
||||
REFRESH,
|
||||
RETRY,
|
||||
EXPIRE,
|
||||
MINIMUM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* http://www.ietf.org/rfc/rfc2782.txt
|
||||
*
|
||||
Priority
|
||||
The priority of this target host. A client MUST attempt to
|
||||
contact the target host with the lowest-numbered priority it can
|
||||
reach; target hosts with the same priority SHOULD be tried in an
|
||||
order defined by the weight field. The range is 0-65535. This
|
||||
is a 16 bit unsigned integer in network byte order.
|
||||
|
||||
Weight
|
||||
A server selection mechanism. The weight field specifies a
|
||||
relative weight for entries with the same priority. Larger
|
||||
weights SHOULD be given a proportionately higher probability of
|
||||
being selected. The range of this number is 0-65535. This is a
|
||||
16 bit unsigned integer in network byte order. Domain
|
||||
administrators SHOULD use Weight 0 when there isn't any server
|
||||
selection to do, to make the RR easier to read for humans (less
|
||||
noisy). In the presence of records containing weights greater
|
||||
than 0, records with weight 0 should have a very small chance of
|
||||
being selected.
|
||||
|
||||
In the absence of a protocol whose specification calls for the
|
||||
use of other weighting information, a client arranges the SRV
|
||||
RRs of the same Priority in the order in which target hosts,
|
||||
specified by the SRV RRs, will be contacted. The following
|
||||
algorithm SHOULD be used to order the SRV RRs of the same
|
||||
priority:
|
||||
|
||||
To select a target to be contacted next, arrange all SRV RRs
|
||||
(that have not been ordered yet) in any order, except that all
|
||||
those with weight 0 are placed at the beginning of the list.
|
||||
|
||||
Compute the sum of the weights of those RRs, and with each RR
|
||||
associate the running sum in the selected order. Then choose a
|
||||
uniform random number between 0 and the sum computed
|
||||
(inclusive), and select the RR whose running sum value is the
|
||||
first in the selected order which is greater than or equal to
|
||||
the random number selected. The target host specified in the
|
||||
selected SRV RR is the next one to be contacted by the client.
|
||||
Remove this SRV RR from the set of the unordered SRV RRs and
|
||||
apply the described algorithm to the unordered SRV RRs to select
|
||||
the next target host. Continue the ordering process until there
|
||||
are no unordered SRV RRs. This process is repeated for each
|
||||
Priority.
|
||||
|
||||
Port
|
||||
The port on this target host of this service. The range is 0-
|
||||
65535. This is a 16 bit unsigned integer in network byte order.
|
||||
This is often as specified in Assigned Numbers but need not be.
|
||||
|
||||
Target
|
||||
The domain name of the target host. There MUST be one or more
|
||||
address records for this name, the name MUST NOT be an alias (in
|
||||
the sense of RFC 1034 or RFC 2181). Implementors are urged, but
|
||||
not required, to return the address record(s) in the Additional
|
||||
Data section. Unless and until permitted by future standards
|
||||
action, name compression is not to be used for this field.
|
||||
|
||||
A Target of "." means that the service is decidedly not
|
||||
available at this domain.
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordSRV : Record
|
||||
{
|
||||
public ushort PRIORITY;
|
||||
public ushort WEIGHT;
|
||||
public ushort PORT;
|
||||
public string TARGET;
|
||||
|
||||
public RecordSRV(RecordReader rr)
|
||||
{
|
||||
PRIORITY = rr.ReadUInt16();
|
||||
WEIGHT = rr.ReadUInt16();
|
||||
PORT = rr.ReadUInt16();
|
||||
TARGET = rr.ReadDomainName();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2} {3}",
|
||||
PRIORITY,
|
||||
WEIGHT,
|
||||
PORT,
|
||||
TARGET);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* http://tools.ietf.org/rfc/rfc2930.txt
|
||||
*
|
||||
2. The TKEY Resource Record
|
||||
|
||||
The TKEY resource record (RR) has the structure given below. Its RR
|
||||
type code is 249.
|
||||
|
||||
Field Type Comment
|
||||
----- ---- -------
|
||||
Algorithm: domain
|
||||
Inception: u_int32_t
|
||||
Expiration: u_int32_t
|
||||
Mode: u_int16_t
|
||||
Error: u_int16_t
|
||||
Key Size: u_int16_t
|
||||
Key Data: octet-stream
|
||||
Other Size: u_int16_t
|
||||
Other Data: octet-stream undefined by this specification
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordTKEY : Record
|
||||
{
|
||||
public string ALGORITHM;
|
||||
public UInt32 INCEPTION;
|
||||
public UInt32 EXPIRATION;
|
||||
public UInt16 MODE;
|
||||
public UInt16 ERROR;
|
||||
public UInt16 KEYSIZE;
|
||||
public byte[] KEYDATA;
|
||||
public UInt16 OTHERSIZE;
|
||||
public byte[] OTHERDATA;
|
||||
|
||||
public RecordTKEY(RecordReader rr)
|
||||
{
|
||||
ALGORITHM = rr.ReadDomainName();
|
||||
INCEPTION = rr.ReadUInt32();
|
||||
EXPIRATION = rr.ReadUInt32();
|
||||
MODE = rr.ReadUInt16();
|
||||
ERROR = rr.ReadUInt16();
|
||||
KEYSIZE = rr.ReadUInt16();
|
||||
KEYDATA = rr.ReadBytes(KEYSIZE);
|
||||
OTHERSIZE = rr.ReadUInt16();
|
||||
OTHERDATA = rr.ReadBytes(OTHERSIZE);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2} {3} {4}",
|
||||
ALGORITHM,
|
||||
INCEPTION,
|
||||
EXPIRATION,
|
||||
MODE,
|
||||
ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* http://www.ietf.org/rfc/rfc2845.txt
|
||||
*
|
||||
* Field Name Data Type Notes
|
||||
--------------------------------------------------------------
|
||||
Algorithm Name domain-name Name of the algorithm
|
||||
in domain name syntax.
|
||||
Time Signed u_int48_t seconds since 1-Jan-70 UTC.
|
||||
Fudge u_int16_t seconds of error permitted
|
||||
in Time Signed.
|
||||
MAC Size u_int16_t number of octets in MAC.
|
||||
MAC octet stream defined by Algorithm Name.
|
||||
Original ID u_int16_t original message ID
|
||||
Error u_int16_t expanded RCODE covering
|
||||
TSIG processing.
|
||||
Other Len u_int16_t length, in octets, of
|
||||
Other Data.
|
||||
Other Data octet stream empty unless Error == BADTIME
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordTSIG : Record
|
||||
{
|
||||
public string ALGORITHMNAME;
|
||||
public long TIMESIGNED;
|
||||
public UInt16 FUDGE;
|
||||
public UInt16 MACSIZE;
|
||||
public byte[] MAC;
|
||||
public UInt16 ORIGINALID;
|
||||
public UInt16 ERROR;
|
||||
public UInt16 OTHERLEN;
|
||||
public byte[] OTHERDATA;
|
||||
|
||||
public RecordTSIG(RecordReader rr)
|
||||
{
|
||||
ALGORITHMNAME = rr.ReadDomainName();
|
||||
TIMESIGNED = rr.ReadUInt32() << 32 | rr.ReadUInt32();
|
||||
FUDGE = rr.ReadUInt16();
|
||||
MACSIZE = rr.ReadUInt16();
|
||||
MAC = rr.ReadBytes(MACSIZE);
|
||||
ORIGINALID = rr.ReadUInt16();
|
||||
ERROR = rr.ReadUInt16();
|
||||
OTHERLEN = rr.ReadUInt16();
|
||||
OTHERDATA = rr.ReadBytes(OTHERLEN);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
dateTime = dateTime.AddSeconds(TIMESIGNED);
|
||||
string printDate = dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString();
|
||||
return string.Format("{0} {1} {2} {3} {4}",
|
||||
ALGORITHMNAME,
|
||||
printDate,
|
||||
FUDGE,
|
||||
ORIGINALID,
|
||||
ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
|
||||
#region Rfc info
|
||||
/*
|
||||
3.3.14. TXT RDATA format
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
/ TXT-DATA /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
TXT-DATA One or more <character-string>s.
|
||||
|
||||
TXT RRs are used to hold descriptive text. The semantics of the text
|
||||
depends on the domain where it is found.
|
||||
*
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordTXT : Record
|
||||
{
|
||||
public string TXT;
|
||||
|
||||
public RecordTXT(RecordReader rr)
|
||||
{
|
||||
TXT = rr.ReadString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("\"{0}\"",TXT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
using System;
|
||||
/*
|
||||
* 3.4.2. WKS RDATA format
|
||||
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| ADDRESS |
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
| PROTOCOL | |
|
||||
+--+--+--+--+--+--+--+--+ |
|
||||
| |
|
||||
/ <BIT MAP> /
|
||||
/ /
|
||||
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
|
||||
where:
|
||||
|
||||
ADDRESS An 32 bit Internet address
|
||||
|
||||
PROTOCOL An 8 bit IP protocol number
|
||||
|
||||
<BIT MAP> A variable length bit map. The bit map must be a
|
||||
multiple of 8 bits long.
|
||||
|
||||
The WKS record is used to describe the well known services supported by
|
||||
a particular protocol on a particular internet address. The PROTOCOL
|
||||
field specifies an IP protocol number, and the bit map has one bit per
|
||||
port of the specified protocol. The first bit corresponds to port 0,
|
||||
the second to port 1, etc. If the bit map does not include a bit for a
|
||||
protocol of interest, that bit is assumed zero. The appropriate values
|
||||
and mnemonics for ports and protocols are specified in [RFC-1010].
|
||||
|
||||
For example, if PROTOCOL=TCP (6), the 26th bit corresponds to TCP port
|
||||
25 (SMTP). If this bit is set, a SMTP server should be listening on TCP
|
||||
port 25; if zero, SMTP service is not supported on the specified
|
||||
address.
|
||||
|
||||
The purpose of WKS RRs is to provide availability information for
|
||||
servers for TCP and UDP. If a server supports both TCP and UDP, or has
|
||||
multiple Internet addresses, then multiple WKS RRs are used.
|
||||
|
||||
WKS RRs cause no additional section processing.
|
||||
|
||||
In master files, both ports and protocols are expressed using mnemonics
|
||||
or decimal numbers.
|
||||
|
||||
*/
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordWKS : Record
|
||||
{
|
||||
public string ADDRESS;
|
||||
public int PROTOCOL;
|
||||
public byte[] BITMAP;
|
||||
|
||||
public RecordWKS(RecordReader rr)
|
||||
{
|
||||
ushort length = rr.ReadUInt16(-2);
|
||||
ADDRESS = string.Format("{0}.{1}.{2}.{3}",
|
||||
rr.ReadByte(),
|
||||
rr.ReadByte(),
|
||||
rr.ReadByte(),
|
||||
rr.ReadByte());
|
||||
PROTOCOL = (int)rr.ReadByte();
|
||||
length -= 5;
|
||||
BITMAP = new byte[length];
|
||||
BITMAP = rr.ReadBytes(length);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}",ADDRESS,PROTOCOL);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
using System;
|
||||
/* http://tools.ietf.org/rfc/rfc1183.txt
|
||||
|
||||
3.1. The X25 RR
|
||||
|
||||
The X25 RR is defined with mnemonic X25 and type code 19 (decimal).
|
||||
|
||||
X25 has the following format:
|
||||
|
||||
<owner> <ttl> <class> X25 <PSDN-address>
|
||||
|
||||
<PSDN-address> is required in all X25 RRs.
|
||||
|
||||
<PSDN-address> identifies the PSDN (Public Switched Data Network)
|
||||
address in the X.121 [10] numbering plan associated with <owner>.
|
||||
Its format in master files is a <character-string> syntactically
|
||||
identical to that used in TXT and HINFO.
|
||||
|
||||
The format of X25 is class insensitive. X25 RRs cause no additional
|
||||
section processing.
|
||||
|
||||
The <PSDN-address> is a string of decimal digits, beginning with the
|
||||
4 digit DNIC (Data Network Identification Code), as specified in
|
||||
X.121. National prefixes (such as a 0) MUST NOT be used.
|
||||
|
||||
For example:
|
||||
|
||||
Relay.Prime.COM. X25 311061700956
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class RecordX25 : Record
|
||||
{
|
||||
public string PSDNADDRESS;
|
||||
|
||||
public RecordX25(RecordReader rr)
|
||||
{
|
||||
PSDNADDRESS = rr.ReadString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}",
|
||||
PSDNADDRESS);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
Record.cs
|
||||
RecordA.cs
|
||||
RecordAAAA.cs
|
||||
RecordCNAME.cs
|
||||
RecordHINFO.cs
|
||||
RecordMB.cs
|
||||
RecordMD.cs
|
||||
RecordMF.cs
|
||||
RecordMG.cs
|
||||
RecordMINFO.cs
|
||||
RecordMR.cs
|
||||
RecordMX.cs
|
||||
RecordNS.cs
|
||||
RecordNULL.cs
|
||||
RecordPTR.cs
|
||||
RecordReader.cs
|
||||
RecordSOA.cs
|
||||
RecordTXT.cs
|
||||
RecordUnknown.cs
|
||||
RecordWKS.cs
|
||||
totla.txt
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class Request
|
||||
{
|
||||
public Header header;
|
||||
|
||||
private List<Question> questions;
|
||||
|
||||
public Request()
|
||||
{
|
||||
header = new Header();
|
||||
header.OPCODE = OPCode.Query;
|
||||
header.QDCOUNT = 0;
|
||||
|
||||
questions = new List<Question>();
|
||||
}
|
||||
|
||||
public void AddQuestion(Question question)
|
||||
{
|
||||
questions.Add(question);
|
||||
}
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
List<byte> data = new List<byte>();
|
||||
header.QDCOUNT = (ushort)questions.Count;
|
||||
data.AddRange(header.Data);
|
||||
foreach (Question q in questions)
|
||||
data.AddRange(q.Data);
|
||||
return data.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,987 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Net.Sockets;
|
||||
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
|
||||
|
||||
/*
|
||||
* Network Working Group P. Mockapetris
|
||||
* Request for Comments: 1035 ISI
|
||||
* November 1987
|
||||
*
|
||||
* DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolver is the main class to do DNS query lookups
|
||||
/// </summary>
|
||||
public class Resolver
|
||||
{
|
||||
/// <summary>
|
||||
/// Version of this set of routines, when not in a library
|
||||
/// </summary>
|
||||
public string Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default DNS port
|
||||
/// </summary>
|
||||
public const int DefaultPort = 53;
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of OPENDNS servers
|
||||
/// </summary>
|
||||
public static readonly IPEndPoint[] DefaultDnsServers =
|
||||
{
|
||||
new IPEndPoint(IPAddress.Parse("208.67.222.222"), DefaultPort),
|
||||
new IPEndPoint(IPAddress.Parse("208.67.220.220"), DefaultPort)
|
||||
};
|
||||
|
||||
private ushort m_Unique;
|
||||
private bool m_UseCache;
|
||||
private bool m_Recursion;
|
||||
private int m_Retries;
|
||||
private int m_Timeout;
|
||||
private TransportType m_TransportType;
|
||||
|
||||
private List<IPEndPoint> m_DnsServers;
|
||||
|
||||
private Dictionary<string,Response> m_ResponseCache;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of Resolver using DNS servers specified.
|
||||
/// </summary>
|
||||
/// <param name="DnsServers">Set of DNS servers</param>
|
||||
public Resolver(IPEndPoint[] DnsServers)
|
||||
{
|
||||
m_ResponseCache = new Dictionary<string, Response>();
|
||||
m_DnsServers = new List<IPEndPoint>();
|
||||
m_DnsServers.AddRange(DnsServers);
|
||||
|
||||
m_Unique = (ushort)(new Random()).Next();
|
||||
m_Retries = 3;
|
||||
m_Timeout = 1;
|
||||
m_Recursion = true;
|
||||
m_UseCache = true;
|
||||
m_TransportType = TransportType.Udp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of Resolver using DNS server specified.
|
||||
/// </summary>
|
||||
/// <param name="DnsServer">DNS server to use</param>
|
||||
public Resolver(IPEndPoint DnsServer)
|
||||
: this(new IPEndPoint[] { DnsServer })
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of Resolver using DNS server and port specified.
|
||||
/// </summary>
|
||||
/// <param name="ServerIpAddress">DNS server to use</param>
|
||||
/// <param name="ServerPortNumber">DNS port to use</param>
|
||||
public Resolver(IPAddress ServerIpAddress, int ServerPortNumber)
|
||||
: this(new IPEndPoint(ServerIpAddress,ServerPortNumber))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of Resolver using DNS address and port specified.
|
||||
/// </summary>
|
||||
/// <param name="ServerIpAddress">DNS server address to use</param>
|
||||
/// <param name="ServerPortNumber">DNS port to use</param>
|
||||
public Resolver(string ServerIpAddress, int ServerPortNumber)
|
||||
: this(IPAddress.Parse(ServerIpAddress), ServerPortNumber)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of Resolver using DNS address.
|
||||
/// </summary>
|
||||
/// <param name="ServerIpAddress">DNS server address to use</param>
|
||||
public Resolver(string ServerIpAddress)
|
||||
: this(IPAddress.Parse(ServerIpAddress), DefaultPort)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolver constructor, using DNS servers specified by Windows
|
||||
/// </summary>
|
||||
public Resolver()
|
||||
: this(GetDnsServers())
|
||||
{
|
||||
}
|
||||
|
||||
public class VerboseOutputEventArgs : EventArgs
|
||||
{
|
||||
public string Message;
|
||||
public VerboseOutputEventArgs(string Message)
|
||||
{
|
||||
this.Message = Message;
|
||||
}
|
||||
}
|
||||
|
||||
private void Verbose(string format, params object[] args)
|
||||
{
|
||||
if (OnVerbose != null)
|
||||
OnVerbose(this, new VerboseEventArgs(string.Format(format, args)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verbose messages from internal operations
|
||||
/// </summary>
|
||||
public event VerboseEventHandler OnVerbose;
|
||||
public delegate void VerboseEventHandler(object sender, VerboseEventArgs e);
|
||||
|
||||
public class VerboseEventArgs : EventArgs
|
||||
{
|
||||
public string Message;
|
||||
public VerboseEventArgs(string Message)
|
||||
{
|
||||
this.Message = Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets timeout in milliseconds
|
||||
/// </summary>
|
||||
public int TimeOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Timeout;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Timeout = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets number of retries before giving up
|
||||
/// </summary>
|
||||
public int Retries
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Retries;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value>=1)
|
||||
m_Retries = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set recursion for doing queries
|
||||
/// </summary>
|
||||
public bool Recursion
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Recursion;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Recursion = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets protocol to use
|
||||
/// </summary>
|
||||
public TransportType TransportType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_TransportType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_TransportType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of DNS servers to use
|
||||
/// </summary>
|
||||
public IPEndPoint[] DnsServers
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DnsServers.ToArray();
|
||||
}
|
||||
set
|
||||
{
|
||||
m_DnsServers.Clear();
|
||||
m_DnsServers.AddRange(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets first DNS server address or sets single DNS server to use
|
||||
/// </summary>
|
||||
public string DnsServer
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DnsServers[0].Address.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
IPAddress ip;
|
||||
if (IPAddress.TryParse(value, out ip))
|
||||
{
|
||||
m_DnsServers.Clear();
|
||||
m_DnsServers.Add(new IPEndPoint(ip, DefaultPort));
|
||||
return;
|
||||
}
|
||||
Response response = Query(value, QType.A);
|
||||
if (response.RecordsA.Length > 0)
|
||||
{
|
||||
m_DnsServers.Clear();
|
||||
m_DnsServers.Add(new IPEndPoint(response.RecordsA[0].Address, DefaultPort));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool UseCache
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UseCache;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_UseCache = value;
|
||||
if (!m_UseCache)
|
||||
m_ResponseCache.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the resolver cache
|
||||
/// </summary>
|
||||
public void ClearCache()
|
||||
{
|
||||
m_ResponseCache.Clear();
|
||||
}
|
||||
|
||||
private Response SearchInCache(Question question)
|
||||
{
|
||||
if (!m_UseCache)
|
||||
return null;
|
||||
|
||||
string strKey = question.QClass + "-" + question.QType + "-" + question.QName;
|
||||
|
||||
Response response = null;
|
||||
|
||||
lock (m_ResponseCache)
|
||||
{
|
||||
if (!m_ResponseCache.ContainsKey(strKey))
|
||||
return null;
|
||||
|
||||
response = m_ResponseCache[strKey];
|
||||
}
|
||||
|
||||
int TimeLived = (int)((DateTime.Now.Ticks - response.TimeStamp.Ticks) / TimeSpan.TicksPerSecond);
|
||||
foreach (RR rr in response.RecordsRR)
|
||||
{
|
||||
rr.TimeLived = TimeLived;
|
||||
// The TTL property calculates its actual time to live
|
||||
if (rr.TTL == 0)
|
||||
return null; // out of date
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private void AddToCache(Response response)
|
||||
{
|
||||
if (!m_UseCache)
|
||||
return;
|
||||
|
||||
// No question, no caching
|
||||
if (response.Questions.Count == 0)
|
||||
return;
|
||||
|
||||
// Only cached non-error responses
|
||||
if (response.header.RCODE != RCode.NoError)
|
||||
return;
|
||||
|
||||
Question question = response.Questions[0];
|
||||
|
||||
string strKey = question.QClass + "-" + question.QType + "-" + question.QName;
|
||||
|
||||
lock (m_ResponseCache)
|
||||
{
|
||||
if (m_ResponseCache.ContainsKey(strKey))
|
||||
m_ResponseCache.Remove(strKey);
|
||||
|
||||
m_ResponseCache.Add(strKey, response);
|
||||
}
|
||||
}
|
||||
|
||||
private Response UdpRequest(Request request)
|
||||
{
|
||||
// RFC1035 max. size of a UDP datagram is 512 bytes
|
||||
byte[] responseMessage = new byte[512];
|
||||
|
||||
for (int intAttempts = 0; intAttempts < m_Retries; intAttempts++)
|
||||
{
|
||||
for (int intDnsServer = 0; intDnsServer < m_DnsServers.Count; intDnsServer++)
|
||||
{
|
||||
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, m_Timeout * 1000);
|
||||
|
||||
try
|
||||
{
|
||||
socket.SendTo(request.Data, m_DnsServers[intDnsServer]);
|
||||
int intReceived = socket.Receive(responseMessage);
|
||||
byte[] data = new byte[intReceived];
|
||||
Array.Copy(responseMessage, data, intReceived);
|
||||
Response response = new Response(m_DnsServers[intDnsServer], data);
|
||||
AddToCache(response);
|
||||
return response;
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
Verbose(string.Format(";; Connection to nameserver {0} failed", (intDnsServer + 1)));
|
||||
continue; // next try
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_Unique++;
|
||||
|
||||
// close the socket
|
||||
socket.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Response responseTimeout = new Response();
|
||||
responseTimeout.Error = "Timeout Error";
|
||||
return responseTimeout;
|
||||
}
|
||||
|
||||
private Response TcpRequest(Request request)
|
||||
{
|
||||
//System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
|
||||
//sw.Start();
|
||||
|
||||
byte[] responseMessage = new byte[512];
|
||||
|
||||
for (int intAttempts = 0; intAttempts < m_Retries; intAttempts++)
|
||||
{
|
||||
for (int intDnsServer = 0; intDnsServer < m_DnsServers.Count; intDnsServer++)
|
||||
{
|
||||
TcpClient tcpClient = new TcpClient();
|
||||
tcpClient.ReceiveTimeout = m_Timeout * 1000;
|
||||
|
||||
try
|
||||
{
|
||||
IAsyncResult result = tcpClient.BeginConnect(m_DnsServers[intDnsServer].Address, m_DnsServers[intDnsServer].Port, null, null);
|
||||
|
||||
bool success = result.AsyncWaitHandle.WaitOne(m_Timeout*1000, true);
|
||||
|
||||
if (!success || !tcpClient.Connected)
|
||||
{
|
||||
tcpClient.Close();
|
||||
Verbose(string.Format(";; Connection to nameserver {0} failed", (intDnsServer + 1)));
|
||||
continue;
|
||||
}
|
||||
|
||||
BufferedStream bs = new BufferedStream(tcpClient.GetStream());
|
||||
|
||||
byte[] data = request.Data;
|
||||
bs.WriteByte((byte)((data.Length >> 8) & 0xff));
|
||||
bs.WriteByte((byte)(data.Length & 0xff));
|
||||
bs.Write(data, 0, data.Length);
|
||||
bs.Flush();
|
||||
|
||||
Response TransferResponse = new Response();
|
||||
int intSoa = 0;
|
||||
int intMessageSize = 0;
|
||||
|
||||
//Debug.WriteLine("Sending "+ (request.Length+2) + " bytes in "+ sw.ElapsedMilliseconds+" mS");
|
||||
|
||||
while (true)
|
||||
{
|
||||
int intLength = bs.ReadByte() << 8 | bs.ReadByte();
|
||||
if (intLength <= 0)
|
||||
{
|
||||
tcpClient.Close();
|
||||
Verbose(string.Format(";; Connection to nameserver {0} failed", (intDnsServer + 1)));
|
||||
throw new SocketException(); // next try
|
||||
}
|
||||
|
||||
intMessageSize += intLength;
|
||||
|
||||
data = new byte[intLength];
|
||||
bs.Read(data, 0, intLength);
|
||||
Response response = new Response(m_DnsServers[intDnsServer], data);
|
||||
|
||||
//Debug.WriteLine("Received "+ (intLength+2)+" bytes in "+sw.ElapsedMilliseconds +" mS");
|
||||
|
||||
if (response.header.RCODE != RCode.NoError)
|
||||
return response;
|
||||
|
||||
if (response.Questions[0].QType != QType.AXFR)
|
||||
{
|
||||
AddToCache(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Zone transfer!!
|
||||
|
||||
if(TransferResponse.Questions.Count==0)
|
||||
TransferResponse.Questions.AddRange(response.Questions);
|
||||
TransferResponse.Answers.AddRange(response.Answers);
|
||||
TransferResponse.Authorities.AddRange(response.Authorities);
|
||||
TransferResponse.Additionals.AddRange(response.Additionals);
|
||||
|
||||
if (response.Answers[0].Type == Type.SOA)
|
||||
intSoa++;
|
||||
|
||||
if (intSoa == 2)
|
||||
{
|
||||
TransferResponse.header.QDCOUNT = (ushort)TransferResponse.Questions.Count;
|
||||
TransferResponse.header.ANCOUNT = (ushort)TransferResponse.Answers.Count;
|
||||
TransferResponse.header.NSCOUNT = (ushort)TransferResponse.Authorities.Count;
|
||||
TransferResponse.header.ARCOUNT = (ushort)TransferResponse.Additionals.Count;
|
||||
TransferResponse.MessageSize = intMessageSize;
|
||||
return TransferResponse;
|
||||
}
|
||||
}
|
||||
} // try
|
||||
catch (SocketException)
|
||||
{
|
||||
continue; // next try
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_Unique++;
|
||||
|
||||
// close the socket
|
||||
tcpClient.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Response responseTimeout = new Response();
|
||||
responseTimeout.Error = "Timeout Error";
|
||||
return responseTimeout;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do Query on specified DNS servers
|
||||
/// </summary>
|
||||
/// <param name="name">Name to query</param>
|
||||
/// <param name="qtype">Question type</param>
|
||||
/// <param name="qclass">Class type</param>
|
||||
/// <returns>Response of the query</returns>
|
||||
public Response Query(string name, QType qtype, QClass qclass)
|
||||
{
|
||||
Question question = new Question(name, qtype, qclass);
|
||||
Response response = SearchInCache(question);
|
||||
if (response != null)
|
||||
return response;
|
||||
|
||||
Request request = new Request();
|
||||
request.AddQuestion(question);
|
||||
return GetResponse(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do an QClass=IN Query on specified DNS servers
|
||||
/// </summary>
|
||||
/// <param name="name">Name to query</param>
|
||||
/// <param name="qtype">Question type</param>
|
||||
/// <returns>Response of the query</returns>
|
||||
public Response Query(string name, QType qtype)
|
||||
{
|
||||
Question question = new Question(name, qtype, QClass.IN);
|
||||
Response response = SearchInCache(question);
|
||||
if (response != null)
|
||||
return response;
|
||||
|
||||
Request request = new Request();
|
||||
request.AddQuestion(question);
|
||||
return GetResponse(request);
|
||||
}
|
||||
|
||||
private Response GetResponse(Request request)
|
||||
{
|
||||
request.header.ID = m_Unique;
|
||||
request.header.RD = m_Recursion;
|
||||
|
||||
if (m_TransportType == TransportType.Udp)
|
||||
return UdpRequest(request);
|
||||
|
||||
if (m_TransportType == TransportType.Tcp)
|
||||
return TcpRequest(request);
|
||||
|
||||
Response response = new Response();
|
||||
response.Error = "Unknown TransportType";
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of default DNS servers used on the Windows machine.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IPEndPoint[] GetDnsServers()
|
||||
{
|
||||
List<IPEndPoint> list = new List<IPEndPoint>();
|
||||
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
|
||||
foreach (NetworkInterface n in adapters)
|
||||
{
|
||||
if (n.OperationalStatus == OperationalStatus.Up)
|
||||
{
|
||||
IPInterfaceProperties ipProps = n.GetIPProperties();
|
||||
// thanks to Jon Webster on May 20, 2008
|
||||
foreach (IPAddress ipAddr in ipProps.DnsAddresses)
|
||||
{
|
||||
IPEndPoint entry = new IPEndPoint(ipAddr, DefaultPort);
|
||||
if (!list.Contains(entry))
|
||||
list.Add(entry);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
private IPHostEntry MakeEntry(string HostName)
|
||||
{
|
||||
IPHostEntry entry = new IPHostEntry();
|
||||
|
||||
entry.HostName = HostName;
|
||||
|
||||
Response response = Query(HostName, QType.A, QClass.IN);
|
||||
|
||||
// fill AddressList and aliases
|
||||
List<IPAddress> AddressList = new List<IPAddress>();
|
||||
List<string> Aliases = new List<string>();
|
||||
foreach (AnswerRR answerRR in response.Answers)
|
||||
{
|
||||
if (answerRR.Type == Type.A)
|
||||
{
|
||||
// answerRR.RECORD.ToString() == (answerRR.RECORD as RecordA).Address
|
||||
AddressList.Add(IPAddress.Parse((answerRR.RECORD.ToString())));
|
||||
entry.HostName = answerRR.NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (answerRR.Type == Type.CNAME)
|
||||
Aliases.Add(answerRR.NAME);
|
||||
}
|
||||
}
|
||||
entry.AddressList = AddressList.ToArray();
|
||||
entry.Aliases = Aliases.ToArray();
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates the IPV4 or IPV6 address into an arpa address
|
||||
/// </summary>
|
||||
/// <param name="ip">IP address to get the arpa address form</param>
|
||||
/// <returns>The 'mirrored' IPV4 or IPV6 arpa address</returns>
|
||||
public static string GetArpaFromIp(IPAddress ip)
|
||||
{
|
||||
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("in-addr.arpa.");
|
||||
foreach (byte b in ip.GetAddressBytes())
|
||||
{
|
||||
sb.Insert(0, string.Format("{0}.", b));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
if (ip.AddressFamily == AddressFamily.InterNetworkV6)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("ip6.arpa.");
|
||||
foreach (byte b in ip.GetAddressBytes())
|
||||
{
|
||||
sb.Insert(0, string.Format("{0:x}.", (b >> 4) & 0xf));
|
||||
sb.Insert(0, string.Format("{0:x}.", (b >> 0) & 0xf));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
public static string GetArpaFromEnum(string strEnum)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string Number = System.Text.RegularExpressions.Regex.Replace(strEnum, "[^0-9]", "");
|
||||
sb.Append("e164.arpa.");
|
||||
foreach (char c in Number)
|
||||
{
|
||||
sb.Insert(0, string.Format("{0}.", c));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
#region Deprecated methods in the original System.Net.DNS class
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Internet Protocol (IP) addresses for the specified host.
|
||||
/// </summary>
|
||||
/// <param name="hostNameOrAddress">The host name or IP address to resolve.</param>
|
||||
/// <returns>
|
||||
/// An array of type System.Net.IPAddress that holds the IP addresses for the
|
||||
/// host that is specified by the hostNameOrAddress parameter.
|
||||
///</returns>
|
||||
public IPAddress[] GetHostAddresses(string hostNameOrAddress)
|
||||
{
|
||||
IPHostEntry entry = GetHostEntry(hostNameOrAddress);
|
||||
return entry.AddressList;
|
||||
}
|
||||
|
||||
private delegate IPAddress[] GetHostAddressesDelegate(string hostNameOrAddress);
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously returns the Internet Protocol (IP) addresses for the specified
|
||||
/// host.
|
||||
/// </summary>
|
||||
/// <param name="hostNameOrAddress">The host name or IP address to resolve.</param>
|
||||
/// <param name="requestCallback">
|
||||
/// An System.AsyncCallback delegate that references the method to invoke when
|
||||
/// the operation is complete.
|
||||
/// </param>
|
||||
/// <param name="stateObject">
|
||||
/// A user-defined object that contains information about the operation. This
|
||||
/// object is passed to the requestCallback delegate when the operation is complete.
|
||||
///</param>
|
||||
/// <returns>An System.IAsyncResult instance that references the asynchronous request.</returns>
|
||||
public IAsyncResult BeginGetHostAddresses(string hostNameOrAddress, AsyncCallback requestCallback, object stateObject)
|
||||
{
|
||||
GetHostAddressesDelegate g = new GetHostAddressesDelegate(GetHostAddresses);
|
||||
return g.BeginInvoke(hostNameOrAddress, requestCallback, stateObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends an asynchronous request for DNS information.
|
||||
/// </summary>
|
||||
/// <param name="AsyncResult">
|
||||
/// An System.IAsyncResult instance returned by a call to the Heijden.Dns.Resolver.BeginGetHostAddresses(System.String,System.AsyncCallback,System.Object)
|
||||
/// method.
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public IPAddress[] EndGetHostAddresses(IAsyncResult AsyncResult)
|
||||
{
|
||||
AsyncResult aResult = (AsyncResult)AsyncResult;
|
||||
GetHostAddressesDelegate g = (GetHostAddressesDelegate)aResult.AsyncDelegate;
|
||||
return g.EndInvoke(AsyncResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an System.Net.IPHostEntry instance from the specified System.Net.IPAddress.
|
||||
/// </summary>
|
||||
/// <param name="ip">An System.Net.IPAddress.</param>
|
||||
/// <returns>An System.Net.IPHostEntry.</returns>
|
||||
public IPHostEntry GetHostByAddress(IPAddress ip)
|
||||
{
|
||||
return GetHostEntry(ip);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an System.Net.IPHostEntry instance from an IP address.
|
||||
/// </summary>
|
||||
/// <param name="address">An IP address.</param>
|
||||
/// <returns>An System.Net.IPHostEntry instance.</returns>
|
||||
public IPHostEntry GetHostByAddress(string address)
|
||||
{
|
||||
return GetHostEntry(address);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DNS information for the specified DNS host name.
|
||||
/// </summary>
|
||||
/// <param name="hostName">The DNS name of the host</param>
|
||||
/// <returns>An System.Net.IPHostEntry object that contains host information for the address specified in hostName.</returns>
|
||||
public IPHostEntry GetHostByName(string hostName)
|
||||
{
|
||||
return MakeEntry(hostName);
|
||||
}
|
||||
|
||||
private delegate IPHostEntry GetHostByNameDelegate(string hostName);
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously resolves an IP address to an System.Net.IPHostEntry instance.
|
||||
/// </summary>
|
||||
/// <param name="hostName">The DNS name of the host</param>
|
||||
/// <param name="requestCallback">An System.AsyncCallback delegate that references the method to invoke when the operation is complete.</param>
|
||||
/// <param name="stateObject">
|
||||
/// A user-defined object that contains information about the operation. This
|
||||
/// object is passed to the requestCallback delegate when the operation is complete.
|
||||
/// </param>
|
||||
/// <returns>An System.IAsyncResult instance that references the asynchronous request.</returns>
|
||||
public IAsyncResult BeginGetHostByName(string hostName, AsyncCallback requestCallback, object stateObject)
|
||||
{
|
||||
GetHostByNameDelegate g = new GetHostByNameDelegate(GetHostByName);
|
||||
return g.BeginInvoke(hostName, requestCallback, stateObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends an asynchronous request for DNS information.
|
||||
/// </summary>
|
||||
/// <param name="AsyncResult">
|
||||
/// An System.IAsyncResult instance returned by a call to an
|
||||
/// Heijden.Dns.Resolver.BeginGetHostByName method.
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public IPHostEntry EndGetHostByName(IAsyncResult AsyncResult)
|
||||
{
|
||||
AsyncResult aResult = (AsyncResult)AsyncResult;
|
||||
GetHostByNameDelegate g = (GetHostByNameDelegate)aResult.AsyncDelegate;
|
||||
return g.EndInvoke(AsyncResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves a host name or IP address to an System.Net.IPHostEntry instance.
|
||||
/// </summary>
|
||||
/// <param name="hostName">A DNS-style host name or IP address.</param>
|
||||
/// <returns></returns>
|
||||
//[Obsolete("no problem",false)]
|
||||
public IPHostEntry Resolve(string hostName)
|
||||
{
|
||||
return MakeEntry(hostName);
|
||||
}
|
||||
|
||||
private delegate IPHostEntry ResolveDelegate(string hostName);
|
||||
|
||||
/// <summary>
|
||||
/// Begins an asynchronous request to resolve a DNS host name or IP address to
|
||||
/// an System.Net.IPAddress instance.
|
||||
/// </summary>
|
||||
/// <param name="hostName">The DNS name of the host.</param>
|
||||
/// <param name="requestCallback">
|
||||
/// An System.AsyncCallback delegate that references the method to invoke when
|
||||
/// the operation is complete.
|
||||
/// </param>
|
||||
/// <param name="stateObject">
|
||||
/// A user-defined object that contains information about the operation. This
|
||||
/// object is passed to the requestCallback delegate when the operation is complete.
|
||||
/// </param>
|
||||
/// <returns>An System.IAsyncResult instance that references the asynchronous request.</returns>
|
||||
public IAsyncResult BeginResolve(string hostName, AsyncCallback requestCallback, object stateObject)
|
||||
{
|
||||
ResolveDelegate g = new ResolveDelegate(Resolve);
|
||||
return g.BeginInvoke(hostName, requestCallback, stateObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends an asynchronous request for DNS information.
|
||||
/// </summary>
|
||||
/// <param name="AsyncResult">
|
||||
/// An System.IAsyncResult instance that is returned by a call to the System.Net.Dns.BeginResolve(System.String,System.AsyncCallback,System.Object)
|
||||
/// method.
|
||||
/// </param>
|
||||
/// <returns>An System.Net.IPHostEntry object that contains DNS information about a host.</returns>
|
||||
public IPHostEntry EndResolve(IAsyncResult AsyncResult)
|
||||
{
|
||||
AsyncResult aResult = (AsyncResult)AsyncResult;
|
||||
ResolveDelegate g = (ResolveDelegate)aResult.AsyncDelegate;
|
||||
return g.EndInvoke(AsyncResult);
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Resolves an IP address to an System.Net.IPHostEntry instance.
|
||||
/// </summary>
|
||||
/// <param name="ip">An IP address.</param>
|
||||
/// <returns>
|
||||
/// An System.Net.IPHostEntry instance that contains address information about
|
||||
/// the host specified in address.
|
||||
///</returns>
|
||||
public IPHostEntry GetHostEntry(IPAddress ip)
|
||||
{
|
||||
Response response = Query(GetArpaFromIp(ip), QType.PTR, QClass.IN);
|
||||
if (response.RecordsPTR.Length > 0)
|
||||
return MakeEntry(response.RecordsPTR[0].PTRDNAME);
|
||||
else
|
||||
return new IPHostEntry();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves a host name or IP address to an System.Net.IPHostEntry instance.
|
||||
/// </summary>
|
||||
/// <param name="hostNameOrAddress">The host name or IP address to resolve.</param>
|
||||
/// <returns>
|
||||
/// An System.Net.IPHostEntry instance that contains address information about
|
||||
/// the host specified in hostNameOrAddress.
|
||||
///</returns>
|
||||
public IPHostEntry GetHostEntry(string hostNameOrAddress)
|
||||
{
|
||||
IPAddress iPAddress;
|
||||
if (IPAddress.TryParse(hostNameOrAddress, out iPAddress))
|
||||
return GetHostEntry(iPAddress);
|
||||
else
|
||||
return MakeEntry(hostNameOrAddress);
|
||||
}
|
||||
|
||||
private delegate IPHostEntry GetHostEntryViaIPDelegate(IPAddress ip);
|
||||
private delegate IPHostEntry GetHostEntryDelegate(string hostNameOrAddress);
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously resolves a host name or IP address to an System.Net.IPHostEntry instance.
|
||||
/// </summary>
|
||||
/// <param name="hostNameOrAddress">The host name or IP address to resolve.</param>
|
||||
/// <param name="requestCallback">
|
||||
/// An System.AsyncCallback delegate that references the method to invoke when
|
||||
/// the operation is complete.
|
||||
///</param>
|
||||
/// <param name="stateObject">
|
||||
/// A user-defined object that contains information about the operation. This
|
||||
/// object is passed to the requestCallback delegate when the operation is complete.
|
||||
/// </param>
|
||||
/// <returns>An System.IAsyncResult instance that references the asynchronous request.</returns>
|
||||
public IAsyncResult BeginGetHostEntry(string hostNameOrAddress, AsyncCallback requestCallback, object stateObject)
|
||||
{
|
||||
GetHostEntryDelegate g = new GetHostEntryDelegate(GetHostEntry);
|
||||
return g.BeginInvoke(hostNameOrAddress, requestCallback, stateObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously resolves an IP address to an System.Net.IPHostEntry instance.
|
||||
/// </summary>
|
||||
/// <param name="ip">The IP address to resolve.</param>
|
||||
/// <param name="requestCallback">
|
||||
/// An System.AsyncCallback delegate that references the method to invoke when
|
||||
/// the operation is complete.
|
||||
/// </param>
|
||||
/// <param name="stateObject">
|
||||
/// A user-defined object that contains information about the operation. This
|
||||
/// object is passed to the requestCallback delegate when the operation is complete.
|
||||
/// </param>
|
||||
/// <returns>An System.IAsyncResult instance that references the asynchronous request.</returns>
|
||||
public IAsyncResult BeginGetHostEntry(IPAddress ip, AsyncCallback requestCallback, object stateObject)
|
||||
{
|
||||
GetHostEntryViaIPDelegate g = new GetHostEntryViaIPDelegate(GetHostEntry);
|
||||
return g.BeginInvoke(ip, requestCallback, stateObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends an asynchronous request for DNS information.
|
||||
/// </summary>
|
||||
/// <param name="AsyncResult">
|
||||
/// An System.IAsyncResult instance returned by a call to an
|
||||
/// Overload:Heijden.Dns.Resolver.BeginGetHostEntry method.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// An System.Net.IPHostEntry instance that contains address information about
|
||||
/// the host.
|
||||
///</returns>
|
||||
public IPHostEntry EndGetHostEntry(IAsyncResult AsyncResult)
|
||||
{
|
||||
AsyncResult aResult = (AsyncResult)AsyncResult;
|
||||
if (aResult.AsyncDelegate is GetHostEntryDelegate)
|
||||
{
|
||||
GetHostEntryDelegate g = (GetHostEntryDelegate)aResult.AsyncDelegate;
|
||||
return g.EndInvoke(AsyncResult);
|
||||
}
|
||||
if (aResult.AsyncDelegate is GetHostEntryViaIPDelegate)
|
||||
{
|
||||
GetHostEntryViaIPDelegate g = (GetHostEntryViaIPDelegate)aResult.AsyncDelegate;
|
||||
return g.EndInvoke(AsyncResult);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private enum RRRecordStatus
|
||||
{
|
||||
UNKNOWN,
|
||||
NAME,
|
||||
TTL,
|
||||
CLASS,
|
||||
TYPE,
|
||||
VALUE
|
||||
}
|
||||
|
||||
public void LoadRootFile(string strPath)
|
||||
{
|
||||
StreamReader sr = new StreamReader(strPath);
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
string strLine = sr.ReadLine();
|
||||
if (strLine == null)
|
||||
break;
|
||||
int intI = strLine.IndexOf(';');
|
||||
if (intI >= 0)
|
||||
strLine = strLine.Substring(0, intI);
|
||||
strLine = strLine.Trim();
|
||||
if (strLine.Length == 0)
|
||||
continue;
|
||||
RRRecordStatus status = RRRecordStatus.NAME;
|
||||
string Name="";
|
||||
string Ttl="";
|
||||
string Class="";
|
||||
string Type="";
|
||||
string Value="";
|
||||
string strW = "";
|
||||
for (intI = 0; intI < strLine.Length; intI++)
|
||||
{
|
||||
char C = strLine[intI];
|
||||
|
||||
if (C <= ' ' && strW!="")
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case RRRecordStatus.NAME:
|
||||
Name = strW;
|
||||
status = RRRecordStatus.TTL;
|
||||
break;
|
||||
case RRRecordStatus.TTL:
|
||||
Ttl = strW;
|
||||
status = RRRecordStatus.CLASS;
|
||||
break;
|
||||
case RRRecordStatus.CLASS:
|
||||
Class = strW;
|
||||
status = RRRecordStatus.TYPE;
|
||||
break;
|
||||
case RRRecordStatus.TYPE:
|
||||
Type = strW;
|
||||
status = RRRecordStatus.VALUE;
|
||||
break;
|
||||
case RRRecordStatus.VALUE:
|
||||
Value = strW;
|
||||
status = RRRecordStatus.UNKNOWN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
strW = "";
|
||||
}
|
||||
if (C > ' ')
|
||||
strW += C;
|
||||
}
|
||||
|
||||
}
|
||||
sr.Close();
|
||||
}
|
||||
} // class
|
||||
}
|
||||
|
|
@ -1,288 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
public class Response
|
||||
{
|
||||
/// <summary>
|
||||
/// List of Question records
|
||||
/// </summary>
|
||||
public List<Question> Questions;
|
||||
/// <summary>
|
||||
/// List of AnswerRR records
|
||||
/// </summary>
|
||||
public List<AnswerRR> Answers;
|
||||
/// <summary>
|
||||
/// List of AuthorityRR records
|
||||
/// </summary>
|
||||
public List<AuthorityRR> Authorities;
|
||||
/// <summary>
|
||||
/// List of AdditionalRR records
|
||||
/// </summary>
|
||||
public List<AdditionalRR> Additionals;
|
||||
|
||||
public Header header;
|
||||
|
||||
/// <summary>
|
||||
/// Error message, empty when no error
|
||||
/// </summary>
|
||||
public string Error;
|
||||
|
||||
/// <summary>
|
||||
/// The Size of the message
|
||||
/// </summary>
|
||||
public int MessageSize;
|
||||
|
||||
/// <summary>
|
||||
/// TimeStamp when cached
|
||||
/// </summary>
|
||||
public DateTime TimeStamp;
|
||||
|
||||
/// <summary>
|
||||
/// Server which delivered this response
|
||||
/// </summary>
|
||||
public IPEndPoint Server;
|
||||
|
||||
public Response()
|
||||
{
|
||||
Questions = new List<Question>();
|
||||
Answers = new List<AnswerRR>();
|
||||
Authorities = new List<AuthorityRR>();
|
||||
Additionals = new List<AdditionalRR>();
|
||||
|
||||
Server = new IPEndPoint(0,0);
|
||||
Error = "";
|
||||
MessageSize = 0;
|
||||
TimeStamp = DateTime.Now;
|
||||
header = new Header();
|
||||
}
|
||||
|
||||
public Response(IPEndPoint iPEndPoint, byte[] data)
|
||||
{
|
||||
Error = "";
|
||||
Server = iPEndPoint;
|
||||
TimeStamp = DateTime.Now;
|
||||
MessageSize = data.Length;
|
||||
RecordReader rr = new RecordReader(data);
|
||||
|
||||
Questions = new List<Question>();
|
||||
Answers = new List<AnswerRR>();
|
||||
Authorities = new List<AuthorityRR>();
|
||||
Additionals = new List<AdditionalRR>();
|
||||
|
||||
header = new Header(rr);
|
||||
|
||||
for (int intI = 0; intI < header.QDCOUNT; intI++)
|
||||
{
|
||||
Questions.Add(new Question(rr));
|
||||
}
|
||||
|
||||
for (int intI = 0; intI < header.ANCOUNT; intI++)
|
||||
{
|
||||
Answers.Add(new AnswerRR(rr));
|
||||
}
|
||||
|
||||
for (int intI = 0; intI < header.NSCOUNT; intI++)
|
||||
{
|
||||
Authorities.Add(new AuthorityRR(rr));
|
||||
}
|
||||
for (int intI = 0; intI < header.ARCOUNT; intI++)
|
||||
{
|
||||
Additionals.Add(new AdditionalRR(rr));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of RecordMX in Response.Answers
|
||||
/// </summary>
|
||||
public RecordMX[] RecordsMX
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RecordMX> list = new List<RecordMX>();
|
||||
foreach (AnswerRR answerRR in this.Answers)
|
||||
{
|
||||
RecordMX record = answerRR.RECORD as RecordMX;
|
||||
if(record!=null)
|
||||
list.Add(record);
|
||||
}
|
||||
list.Sort();
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of RecordTXT in Response.Answers
|
||||
/// </summary>
|
||||
public RecordTXT[] RecordsTXT
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RecordTXT> list = new List<RecordTXT>();
|
||||
foreach (AnswerRR answerRR in this.Answers)
|
||||
{
|
||||
RecordTXT record = answerRR.RECORD as RecordTXT;
|
||||
if (record != null)
|
||||
list.Add(record);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of RecordA in Response.Answers
|
||||
/// </summary>
|
||||
public RecordA[] RecordsA
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RecordA> list = new List<RecordA>();
|
||||
foreach (AnswerRR answerRR in this.Answers)
|
||||
{
|
||||
RecordA record = answerRR.RECORD as RecordA;
|
||||
if (record != null)
|
||||
list.Add(record);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of RecordPTR in Response.Answers
|
||||
/// </summary>
|
||||
public RecordPTR[] RecordsPTR
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RecordPTR> list = new List<RecordPTR>();
|
||||
foreach (AnswerRR answerRR in this.Answers)
|
||||
{
|
||||
RecordPTR record = answerRR.RECORD as RecordPTR;
|
||||
if (record != null)
|
||||
list.Add(record);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of RecordCNAME in Response.Answers
|
||||
/// </summary>
|
||||
public RecordCNAME[] RecordsCNAME
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RecordCNAME> list = new List<RecordCNAME>();
|
||||
foreach (AnswerRR answerRR in this.Answers)
|
||||
{
|
||||
RecordCNAME record = answerRR.RECORD as RecordCNAME;
|
||||
if (record != null)
|
||||
list.Add(record);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of RecordAAAA in Response.Answers
|
||||
/// </summary>
|
||||
public RecordAAAA[] RecordsAAAA
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RecordAAAA> list = new List<RecordAAAA>();
|
||||
foreach (AnswerRR answerRR in this.Answers)
|
||||
{
|
||||
RecordAAAA record = answerRR.RECORD as RecordAAAA;
|
||||
if (record != null)
|
||||
list.Add(record);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of RecordNS in Response.Answers
|
||||
/// </summary>
|
||||
public RecordNS[] RecordsNS
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RecordNS> list = new List<RecordNS>();
|
||||
foreach (AnswerRR answerRR in this.Answers)
|
||||
{
|
||||
RecordNS record = answerRR.RECORD as RecordNS;
|
||||
if (record != null)
|
||||
list.Add(record);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of RecordSOA in Response.Answers
|
||||
/// </summary>
|
||||
public RecordSOA[] RecordsSOA
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RecordSOA> list = new List<RecordSOA>();
|
||||
foreach (AnswerRR answerRR in this.Answers)
|
||||
{
|
||||
RecordSOA record = answerRR.RECORD as RecordSOA;
|
||||
if (record != null)
|
||||
list.Add(record);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of RecordSRV in Response.Answers
|
||||
/// </summary>
|
||||
public RecordSRV[] RecordsSRV
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RecordSRV> list = new List<RecordSRV>();
|
||||
foreach (AnswerRR answerRR in this.Answers)
|
||||
{
|
||||
RecordSRV record = answerRR.RECORD as RecordSRV;
|
||||
if (record != null)
|
||||
list.Add(record);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public RR[] RecordsRR
|
||||
{
|
||||
get
|
||||
{
|
||||
List<RR> list = new List<RR>();
|
||||
foreach (RR rr in this.Answers)
|
||||
{
|
||||
list.Add(rr);
|
||||
}
|
||||
foreach (RR rr in this.Answers)
|
||||
{
|
||||
list.Add(rr);
|
||||
}
|
||||
foreach (RR rr in this.Authorities)
|
||||
{
|
||||
list.Add(rr);
|
||||
}
|
||||
foreach (RR rr in this.Additionals)
|
||||
{
|
||||
list.Add(rr);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,331 +0,0 @@
|
|||
/*
|
||||
* http://www.iana.org/assignments/dns-parameters
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace Heijden.DNS
|
||||
{
|
||||
/*
|
||||
* 3.2.2. TYPE values
|
||||
*
|
||||
* TYPE fields are used in resource records.
|
||||
* Note that these types are a subset of QTYPEs.
|
||||
*
|
||||
* TYPE value meaning
|
||||
*/
|
||||
public enum Type : ushort
|
||||
{
|
||||
A = 1, // a IPV4 host address
|
||||
NS = 2, // an authoritative name server
|
||||
MD = 3, // a mail destination (Obsolete - use MX)
|
||||
MF = 4, // a mail forwarder (Obsolete - use MX)
|
||||
CNAME = 5, // the canonical name for an alias
|
||||
SOA = 6, // marks the start of a zone of authority
|
||||
MB = 7, // a mailbox domain name (EXPERIMENTAL)
|
||||
MG = 8, // a mail group member (EXPERIMENTAL)
|
||||
MR = 9, // a mail rename domain name (EXPERIMENTAL)
|
||||
NULL = 10, // a null RR (EXPERIMENTAL)
|
||||
WKS = 11, // a well known service description
|
||||
PTR = 12, // a domain name pointer
|
||||
HINFO = 13, // host information
|
||||
MINFO = 14, // mailbox or mail list information
|
||||
MX = 15, // mail exchange
|
||||
TXT = 16, // text strings
|
||||
|
||||
RP = 17, // The Responsible Person rfc1183
|
||||
AFSDB = 18, // AFS Data Base location
|
||||
X25 = 19, // X.25 address rfc1183
|
||||
ISDN = 20, // ISDN address rfc1183
|
||||
RT = 21, // The Route Through rfc1183
|
||||
|
||||
NSAP = 22, // Network service access point address rfc1706
|
||||
NSAPPTR = 23, // Obsolete, rfc1348
|
||||
|
||||
SIG = 24, // Cryptographic public key signature rfc2931 / rfc2535
|
||||
KEY = 25, // Public key as used in DNSSEC rfc2535
|
||||
|
||||
PX = 26, // Pointer to X.400/RFC822 mail mapping information rfc2163
|
||||
|
||||
GPOS = 27, // Geographical position rfc1712 (obsolete)
|
||||
|
||||
AAAA = 28, // a IPV6 host address, rfc3596
|
||||
|
||||
LOC = 29, // Location information rfc1876
|
||||
|
||||
NXT = 30, // Next Domain, Obsolete rfc2065 / rfc2535
|
||||
|
||||
EID = 31, // *** Endpoint Identifier (Patton)
|
||||
NIMLOC = 32, // *** Nimrod Locator (Patton)
|
||||
|
||||
SRV = 33, // Location of services rfc2782
|
||||
|
||||
ATMA = 34, // *** ATM Address (Dobrowski)
|
||||
|
||||
NAPTR = 35, // The Naming Authority Pointer rfc3403
|
||||
|
||||
KX = 36, // Key Exchange Delegation Record rfc2230
|
||||
|
||||
CERT = 37, // *** CERT RFC2538
|
||||
|
||||
A6 = 38, // IPv6 address rfc3363 (rfc2874 rfc3226)
|
||||
DNAME = 39, // A way to provide aliases for a whole domain, not just a single domain name as with CNAME. rfc2672
|
||||
|
||||
SINK = 40, // *** SINK Eastlake
|
||||
OPT = 41, // *** OPT RFC2671
|
||||
|
||||
APL = 42, // *** APL [RFC3123]
|
||||
|
||||
DS = 43, // Delegation Signer rfc3658
|
||||
|
||||
SSHFP = 44, // SSH Key Fingerprint rfc4255
|
||||
IPSECKEY = 45, // IPSECKEY rfc4025
|
||||
RRSIG = 46, // RRSIG rfc3755
|
||||
NSEC = 47, // NSEC rfc3755
|
||||
DNSKEY = 48, // DNSKEY 3755
|
||||
DHCID = 49, // DHCID rfc4701
|
||||
|
||||
NSEC3 = 50, // NSEC3 rfc5155
|
||||
NSEC3PARAM = 51, // NSEC3PARAM rfc5155
|
||||
|
||||
HIP = 55, // Host Identity Protocol [RFC-ietf-hip-dns-09.txt]
|
||||
|
||||
SPF = 99, // SPF rfc4408
|
||||
|
||||
UINFO = 100, // *** IANA-Reserved
|
||||
UID = 101, // *** IANA-Reserved
|
||||
GID = 102, // *** IANA-Reserved
|
||||
UNSPEC = 103, // *** IANA-Reserved
|
||||
|
||||
TKEY = 249, // Transaction key rfc2930
|
||||
TSIG = 250, // Transaction signature rfc2845
|
||||
|
||||
TA=32768, // DNSSEC Trust Authorities [Weiler] 13 December 2005
|
||||
DLV=32769 // DNSSEC Lookaside Validation [RFC4431]
|
||||
}
|
||||
|
||||
/*
|
||||
* 3.2.3. QTYPE values
|
||||
*
|
||||
* QTYPE fields appear in the question part of a query. QTYPES are a
|
||||
* superset of TYPEs, hence all TYPEs are valid QTYPEs. In addition, the
|
||||
* following QTYPEs are defined:
|
||||
*
|
||||
* QTYPE value meaning
|
||||
*/
|
||||
public enum QType : ushort
|
||||
{
|
||||
A = Type.A, // a IPV4 host address
|
||||
NS = Type.NS, // an authoritative name server
|
||||
MD = Type.MD, // a mail destination (Obsolete - use MX)
|
||||
MF = Type.MF, // a mail forwarder (Obsolete - use MX)
|
||||
CNAME = Type.CNAME, // the canonical name for an alias
|
||||
SOA = Type.SOA, // marks the start of a zone of authority
|
||||
MB = Type.MB, // a mailbox domain name (EXPERIMENTAL)
|
||||
MG = Type.MG, // a mail group member (EXPERIMENTAL)
|
||||
MR = Type.MR, // a mail rename domain name (EXPERIMENTAL)
|
||||
NULL = Type.NULL, // a null RR (EXPERIMENTAL)
|
||||
WKS = Type.WKS, // a well known service description
|
||||
PTR = Type.PTR, // a domain name pointer
|
||||
HINFO = Type.HINFO, // host information
|
||||
MINFO = Type.MINFO, // mailbox or mail list information
|
||||
MX = Type.MX, // mail exchange
|
||||
TXT = Type.TXT, // text strings
|
||||
|
||||
RP = Type.RP, // The Responsible Person rfc1183
|
||||
AFSDB = Type.AFSDB, // AFS Data Base location
|
||||
X25 = Type.X25, // X.25 address rfc1183
|
||||
ISDN = Type.ISDN, // ISDN address rfc1183
|
||||
RT = Type.RT, // The Route Through rfc1183
|
||||
|
||||
NSAP = Type.NSAP, // Network service access point address rfc1706
|
||||
NSAP_PTR = Type.NSAPPTR, // Obsolete, rfc1348
|
||||
|
||||
SIG = Type.SIG, // Cryptographic public key signature rfc2931 / rfc2535
|
||||
KEY = Type.KEY, // Public key as used in DNSSEC rfc2535
|
||||
|
||||
PX = Type.PX, // Pointer to X.400/RFC822 mail mapping information rfc2163
|
||||
|
||||
GPOS = Type.GPOS, // Geographical position rfc1712 (obsolete)
|
||||
|
||||
AAAA = Type.AAAA, // a IPV6 host address
|
||||
|
||||
LOC = Type.LOC, // Location information rfc1876
|
||||
|
||||
NXT = Type.NXT, // Obsolete rfc2065 / rfc2535
|
||||
|
||||
EID = Type.EID, // *** Endpoint Identifier (Patton)
|
||||
NIMLOC = Type.NIMLOC,// *** Nimrod Locator (Patton)
|
||||
|
||||
SRV = Type.SRV, // Location of services rfc2782
|
||||
|
||||
ATMA = Type.ATMA, // *** ATM Address (Dobrowski)
|
||||
|
||||
NAPTR = Type.NAPTR, // The Naming Authority Pointer rfc3403
|
||||
|
||||
KX = Type.KX, // Key Exchange Delegation Record rfc2230
|
||||
|
||||
CERT = Type.CERT, // *** CERT RFC2538
|
||||
|
||||
A6 = Type.A6, // IPv6 address rfc3363
|
||||
DNAME = Type.DNAME, // A way to provide aliases for a whole domain, not just a single domain name as with CNAME. rfc2672
|
||||
|
||||
SINK = Type.SINK, // *** SINK Eastlake
|
||||
OPT = Type.OPT, // *** OPT RFC2671
|
||||
|
||||
APL = Type.APL, // *** APL [RFC3123]
|
||||
|
||||
DS = Type.DS, // Delegation Signer rfc3658
|
||||
|
||||
SSHFP = Type.SSHFP, // *** SSH Key Fingerprint RFC-ietf-secsh-dns
|
||||
IPSECKEY = Type.IPSECKEY, // rfc4025
|
||||
RRSIG = Type.RRSIG, // *** RRSIG RFC-ietf-dnsext-dnssec-2535
|
||||
NSEC = Type.NSEC, // *** NSEC RFC-ietf-dnsext-dnssec-2535
|
||||
DNSKEY = Type.DNSKEY,// *** DNSKEY RFC-ietf-dnsext-dnssec-2535
|
||||
DHCID = Type.DHCID, // rfc4701
|
||||
|
||||
NSEC3 = Type.NSEC3, // RFC5155
|
||||
NSEC3PARAM = Type.NSEC3PARAM, // RFC5155
|
||||
|
||||
HIP = Type.HIP, // RFC-ietf-hip-dns-09.txt
|
||||
|
||||
SPF = Type.SPF, // RFC4408
|
||||
UINFO = Type.UINFO, // *** IANA-Reserved
|
||||
UID = Type.UID, // *** IANA-Reserved
|
||||
GID = Type.GID, // *** IANA-Reserved
|
||||
UNSPEC = Type.UNSPEC,// *** IANA-Reserved
|
||||
|
||||
TKEY = Type.TKEY, // Transaction key rfc2930
|
||||
TSIG = Type.TSIG, // Transaction signature rfc2845
|
||||
|
||||
IXFR = 251, // incremental transfer [RFC1995]
|
||||
AXFR = 252, // transfer of an entire zone [RFC1035]
|
||||
MAILB = 253, // mailbox-related RRs (MB, MG or MR) [RFC1035]
|
||||
MAILA = 254, // mail agent RRs (Obsolete - see MX) [RFC1035]
|
||||
ANY = 255, // A request for all records [RFC1035]
|
||||
|
||||
TA = Type.TA, // DNSSEC Trust Authorities [Weiler] 13 December 2005
|
||||
DLV = Type.DLV // DNSSEC Lookaside Validation [RFC4431]
|
||||
}
|
||||
/*
|
||||
* 3.2.4. CLASS values
|
||||
*
|
||||
* CLASS fields appear in resource records. The following CLASS mnemonics
|
||||
*and values are defined:
|
||||
*
|
||||
* CLASS value meaning
|
||||
*/
|
||||
public enum Class : ushort
|
||||
{
|
||||
IN = 1, // the Internet
|
||||
CS = 2, // the CSNET class (Obsolete - used only for examples in some obsolete RFCs)
|
||||
CH = 3, // the CHAOS class
|
||||
HS = 4 // Hesiod [Dyer 87]
|
||||
}
|
||||
/*
|
||||
* 3.2.5. QCLASS values
|
||||
*
|
||||
* QCLASS fields appear in the question section of a query. QCLASS values
|
||||
* are a superset of CLASS values; every CLASS is a valid QCLASS. In
|
||||
* addition to CLASS values, the following QCLASSes are defined:
|
||||
*
|
||||
* QCLASS value meaning
|
||||
*/
|
||||
public enum QClass : ushort
|
||||
{
|
||||
IN = Class.IN, // the Internet
|
||||
CS = Class.CS, // the CSNET class (Obsolete - used only for examples in some obsolete RFCs)
|
||||
CH = Class.CH, // the CHAOS class
|
||||
HS = Class.HS, // Hesiod [Dyer 87]
|
||||
|
||||
ANY = 255 // any class
|
||||
}
|
||||
|
||||
/*
|
||||
RCODE Response code - this 4 bit field is set as part of
|
||||
responses. The values have the following
|
||||
interpretation:
|
||||
*/
|
||||
public enum RCode
|
||||
{
|
||||
NoError = 0, // No Error [RFC1035]
|
||||
FormErr = 1, // Format Error [RFC1035]
|
||||
ServFail = 2, // Server Failure [RFC1035]
|
||||
NXDomain = 3, // Non-Existent Domain [RFC1035]
|
||||
NotImp = 4, // Not Implemented [RFC1035]
|
||||
Refused = 5, // Query Refused [RFC1035]
|
||||
YXDomain = 6, // Name Exists when it should not [RFC2136]
|
||||
YXRRSet = 7, // RR Set Exists when it should not [RFC2136]
|
||||
NXRRSet = 8, // RR Set that should exist does not [RFC2136]
|
||||
NotAuth = 9, // Server Not Authoritative for zone [RFC2136]
|
||||
NotZone = 10, // Name not contained in zone [RFC2136]
|
||||
|
||||
RESERVED11 = 11, // Reserved
|
||||
RESERVED12 = 12, // Reserved
|
||||
RESERVED13 = 13, // Reserved
|
||||
RESERVED14 = 14, // Reserved
|
||||
RESERVED15 = 15, // Reserved
|
||||
|
||||
BADVERSSIG = 16, // Bad OPT Version [RFC2671]
|
||||
// TSIG Signature Failure [RFC2845]
|
||||
BADKEY = 17, // Key not recognized [RFC2845]
|
||||
BADTIME = 18, // Signature out of time window [RFC2845]
|
||||
BADMODE = 19, // Bad TKEY Mode [RFC2930]
|
||||
BADNAME = 20, // Duplicate key name [RFC2930]
|
||||
BADALG = 21, // Algorithm not supported [RFC2930]
|
||||
BADTRUNC = 22 // Bad Truncation [RFC4635]
|
||||
/*
|
||||
23-3840 available for assignment
|
||||
0x0016-0x0F00
|
||||
3841-4095 Private Use
|
||||
0x0F01-0x0FFF
|
||||
4096-65535 available for assignment
|
||||
0x1000-0xFFFF
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
OPCODE A four bit field that specifies kind of query in this
|
||||
message. This value is set by the originator of a query
|
||||
and copied into the response. The values are:
|
||||
|
||||
0 a standard query (QUERY)
|
||||
|
||||
1 an inverse query (IQUERY)
|
||||
|
||||
2 a server status request (STATUS)
|
||||
|
||||
3-15 reserved for future use
|
||||
*/
|
||||
public enum OPCode
|
||||
{
|
||||
Query = 0, // a standard query (QUERY)
|
||||
IQUERY = 1, // OpCode Retired (previously IQUERY - No further [RFC3425]
|
||||
// assignment of this code available)
|
||||
Status = 2, // a server status request (STATUS) RFC1035
|
||||
RESERVED3 = 3, // IANA
|
||||
|
||||
Notify = 4, // RFC1996
|
||||
Update = 5, // RFC2136
|
||||
|
||||
RESERVED6 = 6,
|
||||
RESERVED7 = 7,
|
||||
RESERVED8 = 8,
|
||||
RESERVED9 = 9,
|
||||
RESERVED10 = 10,
|
||||
RESERVED11 = 11,
|
||||
RESERVED12 = 12,
|
||||
RESERVED13 = 13,
|
||||
RESERVED14 = 14,
|
||||
RESERVED15 = 15,
|
||||
}
|
||||
|
||||
public enum TransportType
|
||||
{
|
||||
Udp,
|
||||
Tcp
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
private string autocomplete_result = "";
|
||||
private bool encrypted = false;
|
||||
private int protocolversion;
|
||||
private Thread netRead;
|
||||
private Tuple<Thread, CancellationTokenSource>? netRead = null;
|
||||
Crypto.IAesStream s;
|
||||
TcpClient c;
|
||||
|
||||
|
|
@ -60,20 +60,28 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
this.c = Client;
|
||||
}
|
||||
|
||||
private void Updater()
|
||||
private void Updater(object? o)
|
||||
{
|
||||
if (((CancellationToken) o!).IsCancellationRequested)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
do
|
||||
while (!((CancellationToken) o!).IsCancellationRequested)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
do
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
} while (Update());
|
||||
}
|
||||
while (Update());
|
||||
}
|
||||
catch (System.IO.IOException) { }
|
||||
catch (SocketException) { }
|
||||
catch (ObjectDisposedException) { }
|
||||
|
||||
if (((CancellationToken) o!).IsCancellationRequested)
|
||||
return;
|
||||
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, "");
|
||||
}
|
||||
|
||||
|
|
@ -194,11 +202,11 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
return true; //packet has been successfully skipped
|
||||
}
|
||||
|
||||
private void StartUpdating()
|
||||
private void StartUpdating()
|
||||
{
|
||||
netRead = new Thread(new ThreadStart(Updater));
|
||||
netRead.Name = "ProtocolPacketHandler";
|
||||
netRead.Start();
|
||||
netRead = new(new Thread(new ParameterizedThreadStart(Updater)), new CancellationTokenSource());
|
||||
netRead.Item1.Name = "ProtocolPacketHandler";
|
||||
netRead.Item1.Start(netRead.Item2.Token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -207,7 +215,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// <returns>Net read thread ID</returns>
|
||||
public int GetNetReadThreadId()
|
||||
{
|
||||
return netRead != null ? netRead.ManagedThreadId : -1;
|
||||
return netRead != null ? netRead.Item1.ManagedThreadId : -1;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
@ -216,7 +224,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
if (netRead != null)
|
||||
{
|
||||
netRead.Abort();
|
||||
netRead.Item2.Cancel();
|
||||
c.Close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ using MinecraftClient.Mapping.BlockPalettes;
|
|||
using MinecraftClient.Mapping.EntityPalettes;
|
||||
using MinecraftClient.Protocol.Handlers.Forge;
|
||||
using MinecraftClient.Inventory;
|
||||
using System.Windows.Forms;
|
||||
using System.Data.SqlClient;
|
||||
using System.Diagnostics;
|
||||
using MinecraftClient.Inventory.ItemPalettes;
|
||||
|
|
@ -72,7 +71,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
PacketTypePalette packetPalette;
|
||||
SocketWrapper socketWrapper;
|
||||
DataTypes dataTypes;
|
||||
Thread netRead; // main thread
|
||||
Tuple<Thread, CancellationTokenSource>? netRead = null; // main thread
|
||||
ILogger log;
|
||||
|
||||
public Protocol18Handler(TcpClient Client, int protocolVersion, IMinecraftComHandler handler, ForgeInfo forgeInfo)
|
||||
|
|
@ -153,14 +152,22 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// <summary>
|
||||
/// Separate thread. Network reading loop.
|
||||
/// </summary>
|
||||
private void Updater()
|
||||
private void Updater(object? o)
|
||||
{
|
||||
try
|
||||
|
||||
if (((CancellationToken) o!).IsCancellationRequested)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
bool keepUpdating = true;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
while (keepUpdating)
|
||||
while (keepUpdating)
|
||||
{
|
||||
|
||||
((CancellationToken)o!).ThrowIfCancellationRequested();
|
||||
|
||||
stopWatch.Start();
|
||||
keepUpdating = Update();
|
||||
stopWatch.Stop();
|
||||
|
|
@ -173,7 +180,11 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
catch (System.IO.IOException) { }
|
||||
catch (SocketException) { }
|
||||
catch (ObjectDisposedException) { }
|
||||
catch (OperationCanceledException) { }
|
||||
|
||||
if (((CancellationToken) o!).IsCancellationRequested)
|
||||
return;
|
||||
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, "");
|
||||
}
|
||||
|
||||
|
|
@ -1160,11 +1171,12 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// <summary>
|
||||
/// Start the updating thread. Should be called after login success.
|
||||
/// </summary>
|
||||
private void StartUpdating()
|
||||
private void StartUpdating()
|
||||
{
|
||||
netRead = new Thread(new ThreadStart(Updater));
|
||||
netRead.Name = "ProtocolPacketHandler";
|
||||
netRead.Start();
|
||||
|
||||
netRead = new Tuple<Thread, CancellationTokenSource>(new Thread(new ParameterizedThreadStart(Updater)), new CancellationTokenSource());
|
||||
netRead.Item1.Name = "ProtocolPacketHandler";
|
||||
netRead.Item1.Start(netRead.Item2.Token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1173,7 +1185,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// <returns>Net read thread ID</returns>
|
||||
public int GetNetReadThreadId()
|
||||
{
|
||||
return netRead != null ? netRead.ManagedThreadId : -1;
|
||||
return netRead != null ? netRead.Item1.ManagedThreadId : -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1185,7 +1197,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
if (netRead != null)
|
||||
{
|
||||
netRead.Abort();
|
||||
netRead.Item2.Cancel();
|
||||
socketWrapper.Disconnect();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Net.Sockets;
|
||||
using System.Net.Security;
|
||||
using System.Threading;
|
||||
using DnsClient;
|
||||
using MinecraftClient.Proxy;
|
||||
using MinecraftClient.Protocol.Handlers;
|
||||
using MinecraftClient.Protocol.Handlers.Forge;
|
||||
|
|
@ -41,20 +43,20 @@ namespace MinecraftClient.Protocol
|
|||
try
|
||||
{
|
||||
Translations.WriteLine("mcc.resolve", domainVal);
|
||||
Heijden.DNS.Response response = new Heijden.DNS.Resolver().Query("_minecraft._tcp." + domainVal, Heijden.DNS.QType.SRV);
|
||||
Heijden.DNS.RecordSRV[] srvRecords = response.RecordsSRV;
|
||||
if (srvRecords != null && srvRecords.Any())
|
||||
var lookupClient = new LookupClient();
|
||||
var response = lookupClient.Query(new DnsQuestion($"_minecraft._tcp.{domainVal}", QueryType.SRV));
|
||||
if (response.HasError != true && response.Answers.SrvRecords().Any())
|
||||
{
|
||||
//Order SRV records by priority and weight, then randomly
|
||||
Heijden.DNS.RecordSRV result = srvRecords
|
||||
.OrderBy(record => record.PRIORITY)
|
||||
.ThenByDescending(record => record.WEIGHT)
|
||||
var result = response.Answers.SrvRecords()
|
||||
.OrderBy(record => record.Priority)
|
||||
.ThenByDescending(record => record.Weight)
|
||||
.ThenBy(record => Guid.NewGuid())
|
||||
.First();
|
||||
string target = result.TARGET.Trim('.');
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.found", target, result.PORT, domainVal));
|
||||
string target = result.Target.Value.Trim('.');
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.found", target, result.Port, domainVal));
|
||||
domainVal = target;
|
||||
portVal = result.PORT;
|
||||
portVal = result.Port;
|
||||
foundService = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ using MinecraftClient.Protocol.Handlers;
|
|||
using System.Runtime.InteropServices;
|
||||
using Ionic.Zip;
|
||||
using MinecraftClient.Mapping;
|
||||
using Org.BouncyCastle.Crypto.Utilities;
|
||||
using MinecraftClient.Protocol.Handlers.PacketPalettes;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
|
||||
namespace MinecraftClient.Protocol
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue