コード例 #1
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteUInt16(Priority);
     writer.WriteUInt16(Weight);
     writer.WriteUInt16(Port);
     writer.WriteDomainName(Target, appendSpace: false);
 }
コード例 #2
0
        /// <inheritdoc />
        public override void WriteData(PresentationWriter writer)
        {
            writer.WriteByte((byte)HashAlgorithm);
            writer.WriteByte((byte)Flags);
            writer.WriteUInt16(Iterations);

            if (Salt == null || Salt.Length == 0)
            {
                writer.WriteString("-");
            }
            else
            {
                writer.WriteBase16String(Salt);
            }

            writer.WriteString(Base32.ExtendedHex.Encode(NextHashedOwnerName, padding: false).ToLowerInvariant());

            bool next = false;

            foreach (var type in Types)
            {
                if (next)
                {
                    writer.WriteSpace();
                }
                writer.WriteDnsType(type, appendSpace: false);
                next = true;
            }
        }
コード例 #3
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteUInt16((ushort)Flags);
     writer.WriteByte(Protocol);
     writer.WriteByte((byte)Algorithm);
     writer.WriteBase64String(PublicKey, appendSpace: false);
 }
コード例 #4
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteUInt16(KeyTag);
     writer.WriteByte((byte)Algorithm);
     writer.WriteByte((byte)HashAlgorithm);
     writer.WriteBase16String(Digest, appendSpace: false);
 }
コード例 #5
0
        public void WriteDomainName_Escaped()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteDomainName(new DomainName(@"dr\. smith.com"), false);
            Assert.AreEqual(@"dr\.\032smith.com", text.ToString());
        }
コード例 #6
0
        public void WriteDnsClass()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteDnsClass(DnsClass.IN);
            writer.WriteDnsClass((DnsClass)1234, appendSpace: false);
            Assert.AreEqual("IN CLASS1234", text.ToString());
        }
コード例 #7
0
        public void WriteDnsType()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteDnsType(DnsType.ANY);
            writer.WriteDnsType((DnsType)1234, appendSpace: false);
            Assert.AreEqual("ANY TYPE1234", text.ToString());
        }
コード例 #8
0
        public void WriteIPAddress()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteIPAddress(IPAddress.Loopback);
            writer.WriteIPAddress(IPAddress.IPv6Loopback, appendSpace: false);
            Assert.AreEqual("127.0.0.1 ::1", text.ToString());
        }
コード例 #9
0
        public void WriteDateTime()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteDateTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc));
            writer.WriteDateTime(DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc), appendSpace: false);
            Assert.AreEqual("19700101000000 99991231235959", text.ToString());
        }
コード例 #10
0
        public void WriteTimeSpan32()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteTimeSpan32(TimeSpan.FromSeconds(int.MaxValue));
            writer.WriteTimeSpan32(TimeSpan.Zero, appendSpace: false);
            Assert.AreEqual("2147483647 0", text.ToString());
        }
コード例 #11
0
        public void WriteByte()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteByte(byte.MaxValue);
            writer.WriteByte(1, appendSpace: false);
            Assert.AreEqual("255 1", text.ToString());
        }
コード例 #12
0
        public void WriteTimeSpan16()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteTimeSpan16(TimeSpan.FromSeconds(ushort.MaxValue));
            writer.WriteTimeSpan16(TimeSpan.Zero, appendSpace: false);
            Assert.AreEqual("65535 0", text.ToString());
        }
コード例 #13
0
        public void WriteBase64String()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteBase64String(new byte[] { 1, 2, 3 });
            writer.WriteBase64String(new byte[] { 1, 2, 3 }, appendSpace: false);
            Assert.AreEqual("AQID AQID", text.ToString());
        }
コード例 #14
0
        public void WriteUInt16()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteUInt16(ushort.MaxValue);
            writer.WriteUInt16(1, appendSpace: false);
            Assert.AreEqual("65535 1", text.ToString());
        }
コード例 #15
0
        public void WriteUInt32()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteUInt32(int.MaxValue);
            writer.WriteUInt32(1, appendSpace: false);
            Assert.AreEqual("2147483647 1", text.ToString());
        }
コード例 #16
0
        public void WriteStringUnencoded()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteStringUnencoded("\\a");
            writer.WriteStringUnencoded("\\b", appendSpace: false);
            Assert.AreEqual("\\a \\b", text.ToString());
        }
コード例 #17
0
ファイル: TKEYRecord.cs プロジェクト: schmitch/net-dns
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteDomainName(Algorithm);
     writer.WriteDateTime(Inception);
     writer.WriteDateTime(Expiration);
     writer.WriteUInt16((ushort)Mode);
     writer.WriteUInt16((ushort)Error);
     writer.WriteBase64String(Key);
     writer.WriteBase64String(OtherData ?? NoData, appendSpace: false);
 }
コード例 #18
0
ファイル: TSIGRecord.cs プロジェクト: schmitch/net-dns
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteDomainName(Algorithm);
     writer.WriteDateTime(TimeSigned);
     writer.WriteTimeSpan16(Fudge);
     writer.WriteBase64String(MAC);
     writer.WriteUInt16(OriginalMessageId);
     writer.WriteUInt16((ushort)Error);
     writer.WriteBase64String(OtherData ?? NoData, appendSpace: false);
 }
コード例 #19
0
ファイル: SOARecord.cs プロジェクト: schmitch/net-dns
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteDomainName(PrimaryName);
     writer.WriteDomainName(Mailbox);
     writer.WriteUInt32(SerialNumber);
     writer.WriteTimeSpan32(Refresh);
     writer.WriteTimeSpan32(Retry);
     writer.WriteTimeSpan32(Expire);
     writer.WriteTimeSpan32(Minimum, appendSpace: false);
 }
コード例 #20
0
 /// <inheritdoc />
 public override string ToString()
 {
     using (var s = new StringWriter())
     {
         var writer = new PresentationWriter(s);
         writer.WriteDomainName(Name);
         writer.WriteDnsClass(Class);
         writer.WriteDnsType(Type, appendSpace: false);
         return(s.ToString());
     }
 }
コード例 #21
0
ファイル: RRSIGRecord.cs プロジェクト: schmitch/net-dns
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteDnsType(TypeCovered);
     writer.WriteByte((byte)Algorithm);
     writer.WriteByte(Labels);
     writer.WriteTimeSpan32(OriginalTTL);
     writer.WriteDateTime(SignatureExpiration);
     writer.WriteDateTime(SignatureInception);
     writer.WriteUInt16(KeyTag);
     writer.WriteDomainName(SignerName);
     writer.WriteBase64String(Signature, appendSpace: false);
 }
コード例 #22
0
ファイル: ResourceRecord.cs プロジェクト: schmitch/net-dns
        /// <summary>
        ///   Write the textual representation of the data that is specific to
        ///   the resource record.
        /// </summary>
        /// <param name="writer">
        ///   The destination for the resource record's data.
        /// </param>
        /// <remarks>
        ///   Derived classes should implement this method.
        ///   <para>
        ///   By default, this will write the hex encoding of
        ///   the <see cref="GetData">RDATA</see> preceeded by
        ///   "\#" and the number integer bytes.
        ///   </para>
        /// </remarks>
        public virtual void WriteData(PresentationWriter writer)
        {
            var rdata   = GetData();
            var hasData = rdata.Length > 0;

            writer.WriteStringUnencoded("\\#");
            writer.WriteUInt32((uint)rdata.Length, appendSpace: hasData);
            if (hasData)
            {
                writer.WriteBase16String(rdata, appendSpace: false);
            }
        }
コード例 #23
0
ファイル: ResourceRecord.cs プロジェクト: schmitch/net-dns
        /// <inheritdoc />
        public void Write(PresentationWriter writer)
        {
            writer.WriteDomainName(Name);
            if (TTL != DefaultTTL)
            {
                writer.WriteTimeSpan32(TTL);
            }
            writer.WriteDnsClass(Class);
            writer.WriteDnsType(Type);

            WriteData(writer);
            writer.WriteEndOfLine();
        }
コード例 #24
0
        /// <inheritdoc />
        public override void WriteData(PresentationWriter writer)
        {
            bool next = false;

            foreach (var s in Strings)
            {
                if (next)
                {
                    writer.WriteSpace();
                }
                writer.WriteString(s, appendSpace: false);
                next = true;
            }
        }
コード例 #25
0
        public void WriteDomainName()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteString("alpha.com");
            writer.WriteString("omega.com", appendSpace: false);
            Assert.AreEqual("alpha.com omega.com", text.ToString());

            text   = new StringWriter();
            writer = new PresentationWriter(text);
            writer.WriteDomainName(new DomainName("alpha.com"), false);
            Assert.AreEqual("alpha.com", text.ToString());
        }
コード例 #26
0
ファイル: NSEC3PARAMRecord .cs プロジェクト: schmitch/net-dns
        /// <inheritdoc />
        public override void WriteData(PresentationWriter writer)
        {
            writer.WriteByte((byte)HashAlgorithm);
            writer.WriteByte((byte)Flags);
            writer.WriteUInt16(Iterations);

            if (Salt == null || Salt.Length == 0)
            {
                writer.WriteString("-");
            }
            else
            {
                writer.WriteBase16String(Salt, appendSpace: false);
            }
        }
コード例 #27
0
        public void WriteString()
        {
            var text   = new StringWriter();
            var writer = new PresentationWriter(text);

            writer.WriteString("alpha");
            writer.WriteString("a b");
            writer.WriteString(null);
            writer.WriteString("");
            writer.WriteString(" ");
            writer.WriteString("a\\b");
            writer.WriteString("a\"b");
            writer.WriteString("end", appendSpace: false);
            Assert.AreEqual("alpha \"a b\" \"\" \"\" \" \" a\\\\b a\\\"b end", text.ToString());
        }
コード例 #28
0
        /// <inheritdoc />
        public override void WriteData(PresentationWriter writer)
        {
            writer.WriteDomainName(NextOwnerName);

            bool next = false;

            foreach (var type in Types)
            {
                if (next)
                {
                    writer.WriteSpace();
                }
                writer.WriteDnsType(type, appendSpace: false);
                next = true;
            }
        }
コード例 #29
0
ファイル: RPRecord.cs プロジェクト: schmitch/net-dns
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteDomainName(Mailbox);
     writer.WriteDomainName(TextName, appendSpace: false);
 }
コード例 #30
0
 /// <inheritdoc />
 public override void WriteData(PresentationWriter writer)
 {
     writer.WriteDomainName(Authority, appendSpace: false);
 }