// TODO: Finish adding TCP Support /// <summary> /// /// </summary> /// <param name="dnsServer"></param> /// <param name="host"></param> /// <param name="queryType"></param> /// <param name="queryClass"></param> /// <param name="protocol"></param> /// <returns>A <see cref="T:DnDns.Net.Dns.DnsQueryResponse"></see> instance that contains the Dns Answer for the request query.</returns> /// <PermissionSet> /// <IPermission class="System.Net.DnsPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// </PermissionSet> public DnsQueryResponse Resolve(string dnsServer, string host, NsType queryType, NsClass queryClass, ProtocolType protocol) { byte[] bDnsQuery = this.BuildDnsRequest(host, queryType, queryClass, protocol); // Connect to DNS server and get the record for the current server. IPHostEntry ipe = System.Net.Dns.GetHostEntry(dnsServer); IPAddress ipa = ipe.AddressList[0]; IPEndPoint ipep = new IPEndPoint(ipa, (int)UdpServices.Domain); byte[] recvBytes = null; switch (protocol) { case ProtocolType.Tcp: { recvBytes = this.ResolveTcp(bDnsQuery, ipep); break; } case ProtocolType.Udp: { recvBytes = this.ResolveUdp(bDnsQuery, ipep); break; } default: { throw new InvalidOperationException("Invalid Protocol: " + protocol.ToString()); } } Trace.Assert(recvBytes != null, "Failed to retrieve data from the remote DNS server."); DnsQueryResponse dnsQR = new DnsQueryResponse(); dnsQR.ParseResponse(recvBytes); return(dnsQR); }
// TODO: Finish adding TCP Support /// <summary> /// /// </summary> /// <param name="dnsServer"></param> /// <param name="host"></param> /// <param name="queryType"></param> /// <param name="queryClass"></param> /// <param name="protocol"></param> /// <returns>A <see cref="T:DnDns.Net.Dns.DnsQueryResponse"></see> instance that contains the Dns Answer for the request query.</returns> /// <PermissionSet> /// <IPermission class="System.Net.DnsPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// </PermissionSet> public DnsQueryResponse Resolve(string dnsServer, string host, NsType queryType, NsClass queryClass, ProtocolType protocol) { byte[] bDnsQuery = this.BuildDnsRequest(host, queryType, queryClass, protocol); // Connect to DNS server and get the record for the current server. IPHostEntry ipe = System.Net.Dns.GetHostEntry(dnsServer); IPAddress ipa = ipe.AddressList[0]; IPEndPoint ipep = new IPEndPoint(ipa, (int)UdpServices.Domain); byte[] recvBytes = null; switch (protocol) { case ProtocolType.Tcp: { recvBytes = this.ResolveTcp(bDnsQuery, ipep); break; } case ProtocolType.Udp: { recvBytes = this.ResolveUdp(bDnsQuery, ipep); break; } default: { throw new InvalidOperationException("Invalid Protocol: " + protocol.ToString()); } } Trace.Assert(recvBytes != null, "Failed to retrieve data from the remote DNS server."); DnsQueryResponse dnsQR = new DnsQueryResponse(); dnsQR.ParseResponse(recvBytes); return dnsQR; }