ExtractName() публичный статический Метод

public static ExtractName ( Stream DNSStream ) : String
DNSStream Stream
Результат String
Пример #1
0
        public TXT(String Name,
                   Stream Stream)

            : base(Name, TypeId, Stream)

        {
            this._Text = DNSTools.ExtractName(Stream);
        }
Пример #2
0
        public MX(Stream Stream)

            : base(Stream, TypeId)

        {
            this._Preference = (Stream.ReadByte() << 8) | (Stream.ReadByte() & Byte.MaxValue);
            this._Exchange   = DNSTools.ExtractName(Stream);
        }
Пример #3
0
        public SSHFP(Stream Stream)

            : base(Stream, TypeId)

        {
            this._Algorithm   = (SSHFP_Algorithm)(Stream.ReadByte() & Byte.MaxValue);
            this._Typ         = (SSHFP_FingerprintType)(Stream.ReadByte() & Byte.MaxValue);
            this._Fingerprint = DNSTools.ExtractName(Stream);
        }
Пример #4
0
        public SOA(Stream Stream)

            : base(Stream, TypeId)

        {
            this._Server  = DNSTools.ExtractName(Stream);
            this._Email   = DNSTools.ExtractName(Stream);
            this._Serial  = (Stream.ReadByte() & Byte.MaxValue) << 24 | (Stream.ReadByte() & Byte.MaxValue) << 16 | (Stream.ReadByte() & Byte.MaxValue) << 8 | Stream.ReadByte() & Byte.MaxValue;
            this._Refresh = (Stream.ReadByte() & Byte.MaxValue) << 24 | (Stream.ReadByte() & Byte.MaxValue) << 16 | (Stream.ReadByte() & Byte.MaxValue) << 8 | Stream.ReadByte() & Byte.MaxValue;
            this._Retry   = (Stream.ReadByte() & Byte.MaxValue) << 24 | (Stream.ReadByte() & Byte.MaxValue) << 16 | (Stream.ReadByte() & Byte.MaxValue) << 8 | Stream.ReadByte() & Byte.MaxValue;
            this._Expire  = (Stream.ReadByte() & Byte.MaxValue) << 24 | (Stream.ReadByte() & Byte.MaxValue) << 16 | (Stream.ReadByte() & Byte.MaxValue) << 8 | Stream.ReadByte() & Byte.MaxValue;
            this._Minimum = (Stream.ReadByte() & Byte.MaxValue) << 24 | (Stream.ReadByte() & Byte.MaxValue) << 16 | (Stream.ReadByte() & Byte.MaxValue) << 8 | Stream.ReadByte() & Byte.MaxValue;
        }
Пример #5
0
        protected ADNSResourceRecord(Stream DNSStream, UInt16 Type)
        {
            this._Name = DNSTools.ExtractName(DNSStream);

            this._Type = Type;
            //this._Type          = (DNSResourceRecordTypes) ((DNSStream.ReadByte() & byte.MaxValue) << 8 | DNSStream.ReadByte() & byte.MaxValue);

            //if (_Type != Type)
            //    throw new ArgumentException("Invalid DNS RR Type!");

            this._Class      = (DNSQueryClasses)((DNSStream.ReadByte() & byte.MaxValue) << 8 | DNSStream.ReadByte() & byte.MaxValue);
            this._TimeToLive = TimeSpan.FromSeconds((DNSStream.ReadByte() & byte.MaxValue) << 24 | (DNSStream.ReadByte() & byte.MaxValue) << 16 | (DNSStream.ReadByte() & byte.MaxValue) << 8 | DNSStream.ReadByte() & byte.MaxValue);
            this._EndOfLife  = DateTime.Now + _TimeToLive;

            var RDLength = (DNSStream.ReadByte() & byte.MaxValue) << 8 | DNSStream.ReadByte() & byte.MaxValue;
        }
Пример #6
0
        private ADNSResourceRecord ReadResourceRecord(Stream DNSStream)
        {
            var ResourceName = DNSTools.ExtractName(DNSStream);
            var TypeId       = (UInt16)((DNSStream.ReadByte() & Byte.MaxValue) << 8 | DNSStream.ReadByte() & Byte.MaxValue);

            ConstructorInfo Constructor;

            if (_RRLookup.TryGetValue(TypeId, out Constructor))
            {
                return((ADNSResourceRecord)Constructor.Invoke(new Object[2] {
                    ResourceName,
                    DNSStream
                }));
            }

            Debug.WriteLine("Unknown DNS resource record '" + TypeId + "' for '" + ResourceName + "' received!");

            return(null);
        }
Пример #7
0
 public TXT(Stream Stream)
     : base(Stream, TypeId)
 {
     this._Text = DNSTools.ExtractName(Stream);
 }
Пример #8
0
        private DNSInfo ReadResponse(IPSocket Origin, Int32 ExpectedTransactionId, Stream DNSBuffer)
        {
            #region DNS Header

            var RequestId = ((DNSBuffer.ReadByte() & Byte.MaxValue) << 8) + (DNSBuffer.ReadByte() & Byte.MaxValue);

            if (ExpectedTransactionId != RequestId)
            {
                throw new Exception("Security Alert: Mallory might send us faked DNS replies! [" + ExpectedTransactionId + " != " + RequestId + "]");
            }

            var Byte2  = DNSBuffer.ReadByte();
            var IS     = (Byte2 & 128) == 128;
            var OpCode = (Byte2 >> 3 & 15);
            var AA     = (Byte2 & 4) == 4;
            var TC     = (Byte2 & 2) == 2;
            var RD     = (Byte2 & 1) == 1;

            var Byte3        = DNSBuffer.ReadByte();
            var RA           = (Byte3 & 128) == 128;
            var Z            = (Byte3 & 1);       //reserved, not used
            var ResponseCode = (DNSResponseCodes)(Byte3 & 15);

            var QuestionCount   = ((DNSBuffer.ReadByte() & Byte.MaxValue) << 8) | (DNSBuffer.ReadByte() & Byte.MaxValue);
            var AnswerCount     = ((DNSBuffer.ReadByte() & Byte.MaxValue) << 8) | (DNSBuffer.ReadByte() & Byte.MaxValue);
            var AuthorityCount  = ((DNSBuffer.ReadByte() & Byte.MaxValue) << 8) | (DNSBuffer.ReadByte() & Byte.MaxValue);
            var AdditionalCount = ((DNSBuffer.ReadByte() & Byte.MaxValue) << 8) | (DNSBuffer.ReadByte() & Byte.MaxValue);

            #endregion

            //ToDo: Does this make sense?
            #region Process Questions

            DNSBuffer.Seek(12, SeekOrigin.Begin);

            for (var i = 0; i < QuestionCount; ++i)
            {
                var QuestionName = DNSTools.ExtractName(DNSBuffer);
                var TypeId       = (UInt16)((DNSBuffer.ReadByte() & Byte.MaxValue) << 8 | DNSBuffer.ReadByte() & Byte.MaxValue);
                var ClassId      = (DNSQueryClasses)((DNSBuffer.ReadByte() & Byte.MaxValue) << 8 | DNSBuffer.ReadByte() & Byte.MaxValue);
            }

            #endregion

            var Answers           = new List <ADNSResourceRecord>();
            var Authorities       = new List <ADNSResourceRecord>();
            var AdditionalRecords = new List <ADNSResourceRecord>();

            for (var i = 0; i < AnswerCount; ++i)
            {
                Answers.Add(ReadResourceRecord(DNSBuffer));
            }

            for (var i = 0; i < AuthorityCount; ++i)
            {
                Authorities.Add(ReadResourceRecord(DNSBuffer));
            }

            for (var i = 0; i < AdditionalCount; ++i)
            {
                AdditionalRecords.Add(ReadResourceRecord(DNSBuffer));
            }

            return(new DNSInfo(Origin, RequestId, AA, TC, RD, RA, ResponseCode, Answers, Authorities, AdditionalRecords));
        }