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); }
public DNSEntry(string name, DNSType type, DNSClass cls) { this.Key = name.ToLower(); this.Name = name; this.Type = type; this.Class = cls & DNSClass.MASK; this.Unique = (cls & DNSClass.UNIQUE) != 0; }
private static DNSRRBase ReadResourceRecord(byte[] data, DataReader reader) { DNSRRBase rr = null; string name = ReadString(data, reader); DNSType type = (DNSType)reader.ReadUInt16(false); DNSClass cls = (DNSClass)reader.ReadUInt16(false); uint ttl = reader.ReadUInt32(false); ushort rlen = reader.ReadUInt16(false); byte[] rdata = reader.ReadBytes(rlen); switch (type) { case DNSType.CNAME: { CNameDNSRR newRec = new CNameDNSRR(data, rdata); rr = newRec; } break; case DNSType.A: { ADNSRR aRec = new ADNSRR(rdata); rr = aRec; } break; case DNSType.AAAA: { AAAADNSRR aRec = new AAAADNSRR(rdata); rr = aRec; } break; case DNSType.PTR: { PTRDNSRR aRec = new PTRDNSRR(data, rdata); rr = aRec; } break; default: { UnknownDNSRR newRec = new UnknownDNSRR(); newRec.RData = rdata; rr = newRec; } break; } rr.Name = name; rr.Class = cls; rr.Type = type; rr.TimeToLive = ttl; return(rr); }
public DNSService(String name, DNSType type, DNSClass cls, uint ttl, ushort priority, ushort weight, ushort port, string server) : base(name, type, cls, ttl) { this.Priority = priority; this.Weight = weight; this.Port = port; this.Server = server; }
public static string GetType(DNSType type) { string ret; if (!Mapping.DnsType.TryGetValue(type, out ret)) { ret = String.Format("?({0})", (int)type); } return(ret); }
public void ReadFrom(BinaryReader aSrc) { this.fName = DNSPacket.ParseName(aSrc, aSrc.BaseStream); this.fType = (DNSType)DNSPacket.N2H(aSrc.ReadUInt16()); ushort num = DNSPacket.N2H(aSrc.ReadUInt16()); if (0 != (num & 0x8000)) { this.fClearCache = true; } this.fClass = ((DNSClass)num) & ((DNSClass)(-32769)); }
public void BeginRequest(DNSClass cl, DNSType type, string name, bool clearcache, Action<DNSResource> action) { DNSQuestion q= new DNSQuestion(); q.Class = cl; q.ClearCache = clearcache; if (!name.EndsWith(".")) name += "."; // domain names technically end with a . q.Name = name; q.Type = type; BeginRequest(q, action); }
public void BeginRequest(DNSClass cl, DNSType type, string name, bool clearcache, Action <DNSResource> action) { DNSQuestion q = new DNSQuestion(); q.Class = cl; q.ClearCache = clearcache; if (!name.EndsWith(".")) { name += "."; // domain names technically end with a . } q.Name = name; q.Type = type; BeginRequest(q, action); }
public RR(RecordReader rr) { TimeLived = 0; NAME = rr.ReadDomainName(); Type = (DNSType)rr.ReadShort(); Class = (Class)rr.ReadShort(); TTL = rr.ReadInt(); RDLENGTH = rr.ReadShort(); //Console.WriteLine("RDLENGTH : " + RDLENGTH.ToString()); RECORD = rr.ReadRecord(Type); //Console.WriteLine("Type : " + Type.ToString()); RECORD.RR = this; //Console.WriteLine("TTL=" + TTL + "."); if (TTL <= 0) { TTL = MIN_TTL; } }
private async Task CreateDNSRecord(DNSType Type, string Name, string Value, DNSTTL TTL) { if (dnsRecords == null) { GetDNSRecord(); } if (dnsRecords.Exists(r => r.Name == Name)) { throw new ArgumentException("A entry with the same name and type already exists."); } Dictionary <string, string> content = GetDNSRequestParameters(Type, Name, Value, TTL); var createResult = new HttpRequestMessage(HttpMethod.Post, new Uri(context.baseUrl + "/domain/dnseditor/add-record-async")) { Content = new FormUrlEncodedContent(content) }; context.ChangeDomain(this); var response = await context.client.SendAsync(createResult); EvaluateDNSModifyResponse(response, DNSModificationType.Create); }
/// <summary> /// Returns the parameter including validation to submit as FormUrlEncodedContent to my.cyon.ch. /// Used in create und update method. /// </summary> /// <param name="Type"></param> /// <param name="Name"></param> /// <param name="Value"></param> /// <param name="TTL"></param> /// <returns></returns> private Dictionary <string, string> GetDNSRequestParameters(DNSType Type, string Name, string Value, DNSTTL TTL) { Dictionary <string, string> content = new Dictionary <string, string>(); if (Type == DNSType.CNAME) { string name = Name.EndsWith(this.Name) ? Name.Substring(0, Name.IndexOf(this.Name)) : Name; content.Add("zonePrefix", name); content.Add("zone", this.Name); } else { if (Name.EndsWith(".")) { content.Add("zone", Name); } else { content.Add("zone", Name + "."); } } content.Add("ttl", ((int)TTL).ToString()); content.Add("type", Type.ToString().ToUpper()); if (Type == DNSType.AAAA) { content.Add("value", WebUtility.UrlEncode(Value)); } else { content.Add("value", Value); } return(content); }
public DNSUnknownRecord(DNSType aType) { this.fType = aType; }
public DNSHinfo(String name, DNSType type, DNSClass cls, uint ttl, String cpu, String os) : base(name, type, cls, ttl) { this.CPU = cpu; this.OS = cpu; }
public DNSText(String name, DNSType type, DNSClass cls, uint ttl, byte[] text) : base(name, type, cls, ttl) { this.Text = text; }
/// <summary> /// Gets an entry by details /// </summary> /// <returns><c>DNSEntry</c> if entry is found, <c>null</c> otherwise</returns> /// <param name="name">Name.</param> /// <param name="type">Type.</param> /// <param name="cls">Cls.</param> public DNSEntry GetByDetails(string name, DNSType type, DNSClass cls) { DNSEntry entry = new DNSEntry(name, type, cls); return(Get(entry)); }
public DNSRecord(String name, DNSType type, DNSClass cls, uint ttl) : base(name, type, cls) { this.TTL = ttl; this.Created = Utilities.CurrentTimeMilliseconds(); }
public Record ReadRecord(DNSType type) { switch (type) { case DNSType.A: return(new RecordA(this)); case DNSType.NS: return(new RecordNS(this)); case DNSType.CNAME: return(new RecordCNAME(this)); case DNSType.SOA: return(new RecordSOA(this)); case DNSType.PTR: return(new RecordPTR(this)); case DNSType.HINFO: return(new RecordHINFO(this)); case DNSType.MINFO: return(new RecordMINFO(this)); case DNSType.MX: return(new RecordMX(this)); case DNSType.TXT: return(new RecordTXT(this)); // old stuff case DNSType.MD: return(new RecordMD(this)); case DNSType.MF: return(new RecordMF(this)); case DNSType.MB: return(new RecordMB(this)); case DNSType.MG: return(new RecordMG(this)); case DNSType.MR: return(new RecordMR(this)); case DNSType.NULL: return(new RecordNULL(this)); case DNSType.WKS: return(new RecordWKS(this)); // RFC 1886 IPV6 case DNSType.AAAA: return(new RecordAAAA(this)); // ENUM Lookups case DNSType.NAPTR: return(new RecordNAPTR(this)); // SRV Lookups case DNSType.SRV: return(new RecordSRV(this)); default: return(new RecordUnknown(this)); } }
public DNSQuestion(String name, DNSType type, DNSClass cls) : base(name, type, cls) { }
public DNSPointer(String name, DNSType type, DNSClass cls, uint ttl, String alias) : base(name, type, cls, ttl) { this.Alias = alias; }
public Record ReadRecord(DNSType type) { switch (type) { case DNSType.A: return new RecordA(this); case DNSType.NS: return new RecordNS(this); case DNSType.CNAME: return new RecordCNAME(this); case DNSType.SOA: return new RecordSOA(this); case DNSType.PTR: return new RecordPTR(this); case DNSType.HINFO: return new RecordHINFO(this); case DNSType.MINFO: return new RecordMINFO(this); case DNSType.MX: return new RecordMX(this); case DNSType.TXT: return new RecordTXT(this); // old stuff case DNSType.MD: return new RecordMD(this); case DNSType.MF: return new RecordMF(this); case DNSType.MB: return new RecordMB(this); case DNSType.MG: return new RecordMG(this); case DNSType.MR: return new RecordMR(this); case DNSType.NULL: return new RecordNULL(this); case DNSType.WKS: return new RecordWKS(this); // RFC 1886 IPV6 case DNSType.AAAA: return new RecordAAAA(this); // ENUM Lookups case DNSType.NAPTR: return new RecordNAPTR(this); // SRV Lookups case DNSType.SRV: return new RecordSRV(this); default: return new RecordUnknown(this); } }
public DNSAddress(String name, DNSType type, DNSClass cls, uint ttl, byte[] address) : base(name, type, cls, ttl) { this.Address = address; }