Beispiel #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);
        }
Beispiel #2
0
        public override DNSResource Clone()
        {
            DNSTXTRecord record   = new DNSTXTRecord();
            DNSResource  resource = record;

            record.Name       = this.Name;
            record.Class      = this.Class;
            record.ClearCache = this.ClearCache;
            record.TTL        = this.TTL;
            record.fData      = this.fData;
            return(resource);
        }
Beispiel #3
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;
 }
Beispiel #4
0
 public override DNSResource Clone()
 {
     DNSTXTRecord record = new DNSTXTRecord();
     DNSResource resource = record;
     record.Name = this.Name;
     record.Class = this.Class;
     record.ClearCache = this.ClearCache;
     record.TTL = this.TTL;
     record.fData = this.fData;
     return resource;
 }