Ejemplo n.º 1
0
        public static DNSResource ReadFrom(BinaryReader aSrc)
        {
            DNSResource resource;
            string      str    = DNSPacket.ParseName(aSrc, aSrc.BaseStream);
            DNSType     aType  = (DNSType)DNSPacket.N2H(aSrc.ReadUInt16());
            DNSClass    class2 = (DNSClass)DNSPacket.N2H(aSrc.ReadUInt16());
            bool        flag   = false;

            if (0 != (((ushort)class2) & 0x8000))
            {
                flag = true;
            }
            class2 &= (DNSClass)(-32769);
            uint   num  = DNSPacket.N2H(aSrc.ReadUInt32());
            ushort num2 = DNSPacket.N2H(aSrc.ReadUInt16());

            byte[]  aData = aSrc.ReadBytes((int)num2);
            DNSType type2 = aType;

            if (type2 == DNSType.A)
            {
                resource = new DNSARecord();
            }
            else if (type2 == DNSType.AAAA)
            {
                resource = new DNSAAAARecord();
            }
            else if (type2 == DNSType.PTR)
            {
                resource = new DNSPTRRecord();
            }
            else if (type2 == DNSType.NS)
            {
                resource = new DNSNSRecord();
            }
            else if (type2 == DNSType.TXT)
            {
                resource = new DNSTXTRecord();
            }
            else if (type2 == DNSType.CNAME)
            {
                resource = new DNSCNameRecord();
            }
            else if (type2 == DNSType.SRV)
            {
                resource = new DNSSRVRecord();
            }
            else
            {
                resource = new DNSUnknownRecord(aType);
            }
            resource.fName       = str;
            resource.fParseTime  = DateTime.UtcNow;
            resource.fClass      = class2;
            resource.fClearCache = flag;
            resource.fTTL        = (ushort)num;
            resource.BodyReadFrom(aData, aSrc.BaseStream);
            return(resource);
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            DNSNSRecord record = obj as DNSNSRecord;

            if (record != null)
            {
                return(this.IntEquals(obj) && (record.fNSHost == this.fNSHost));
            }
            return(base.Equals(obj));
        }
Ejemplo n.º 3
0
        public override DNSResource Clone()
        {
            DNSNSRecord record   = new DNSNSRecord();
            DNSResource resource = record;

            record.Name       = this.Name;
            record.Class      = this.Class;
            record.ClearCache = this.ClearCache;
            record.TTL        = this.TTL;
            record.fNSHost    = this.fNSHost;
            return(resource);
        }
Ejemplo n.º 4
0
 public static DNSResource ReadFrom(BinaryReader aSrc)
 {
     DNSResource resource;
     string str = DNSPacket.ParseName(aSrc, aSrc.BaseStream);
     DNSType aType = (DNSType)DNSPacket.N2H(aSrc.ReadUInt16());
     DNSClass class2 = (DNSClass)DNSPacket.N2H(aSrc.ReadUInt16());
     bool flag = false;
     if (0 != (((ushort)class2) & 0x8000))
     {
         flag = true;
     }
     class2 &= (DNSClass)(-32769);
     uint num = DNSPacket.N2H(aSrc.ReadUInt32());
     ushort num2 = DNSPacket.N2H(aSrc.ReadUInt16());
     byte[] aData = aSrc.ReadBytes((int)num2);
     DNSType type2 = aType;
     if (type2 == DNSType.A)
     {
         resource = new DNSARecord();
     }
     else if (type2 == DNSType.AAAA)
     {
         resource = new DNSAAAARecord();
     }
     else if (type2 == DNSType.PTR)
     {
         resource = new DNSPTRRecord();
     }
     else if (type2 == DNSType.NS)
     {
         resource = new DNSNSRecord();
     }
     else if (type2 == DNSType.TXT)
     {
         resource = new DNSTXTRecord();
     }
     else if (type2 == DNSType.CNAME)
     {
         resource = new DNSCNameRecord();
     }
     else if (type2 == DNSType.SRV)
     {
         resource = new DNSSRVRecord();
     }
     else
     {
         resource = new DNSUnknownRecord(aType);
     }
     resource.fName = str;
     resource.fParseTime = DateTime.UtcNow;
     resource.fClass = class2;
     resource.fClearCache = flag;
     resource.fTTL = (ushort)num;
     resource.BodyReadFrom(aData, aSrc.BaseStream);
     return resource;
 }
Ejemplo n.º 5
0
 public override DNSResource Clone()
 {
     DNSNSRecord record = new DNSNSRecord();
     DNSResource resource = record;
     record.Name = this.Name;
     record.Class = this.Class;
     record.ClearCache = this.ClearCache;
     record.TTL = this.TTL;
     record.fNSHost = this.fNSHost;
     return resource;
 }