Exemplo n.º 1
0
        internal static void LogResponse(IDnsClient client, int byteLength, DNS.Header header, System.Net.IPEndPoint remote)
        {
            ((IMessageLogger)client).LogMessageCreate(LogMessageText.RESPONSE.INFO.ResponseReceived(byteLength, remote));

              if (header.RCODEValue != 0)
            ((IMessageLogger)client).LogMessageCreate(LogMessageText.RESPONSE.WARN.ResponseNonZero(header.RCODEValue, header.RCODE));

              if (header.TC)
            ((IMessageLogger)client).LogMessageCreate(LogMessageText.RESPONSE.WARN.ResponseTruncated());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new QUERY DNS request.
        /// </summary>
        /// <param name="rd">Recursion Desired - If RD is set, it directs the name server to pursue the query recursively.</param>
        /// <param name="question">The DNS question.</param>
        public Request(bool rd, DNS.Question question)
        {
            if (Object.ReferenceEquals(null, question))
            throw new ArgumentNullException("question");

              Header.ID = (ushort)System.DateTime.Now.Ticks;
              Header.QR = DNS.QR.Q;
              Header.RD = rd;
              Header.OPCODE = DNS.OPCODE.QUERY;
              Questions.Add(question);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a new DNS request.
        /// </summary>
        /// <param name="id">A 16 bit identifier assigned by the program that generates any kind of query.</param>
        /// <param name="rd">Recursion Desired - If RD is set, it directs the name server to pursue the query recursively.</param>
        /// <param name="opcode">A four bit field that specifies kind of query in this message.</param>
        /// <param name="question"></param>
        public Request(ushort id, bool rd, DNS.OPCODE opcode, DNS.Question question)
        {
            if (Object.ReferenceEquals(null, question))
            throw new ArgumentNullException("question");

              Header.ID = id;
              Header.QR = DNS.QR.Q;
              Header.RD = rd;
              Header.OPCODE = opcode;
              Questions.Add(question);
        }
Exemplo n.º 4
0
        public void Get()
        {
            var dns = new DNS
            {
                Bytes = new Byte[32]
            };

            dns.SetByte(4, 0x12);
            dns.SetByte(5, 0x34);

            dns.QueriesCount.Should().Be(0x1234);
        }
Exemplo n.º 5
0
 public static string[] GetIPAddresses(string domain, DNS.Protocol.RecordType type)
 {
     // This client is probably heavy? Maybe I should have just one
     // NOTE: This is hardcoded to Google's DNS servers. I'd prefer to use
     // the system DNS but ATM (a) I don't know how to find it and (b)
     // .NET/mono is broken
     DNS.Client.DnsClient client = new DNS.Client.DnsClient("8.8.8.8");
     IList<System.Net.IPAddress> ips = client.Lookup(domain, type);
     List<string> addresses = new List<string>();
     foreach (var ip in ips)
     {
         addresses.Add(ip.ToString());
     }
     return addresses.ToArray();
 }
Exemplo n.º 6
0
 internal SRV(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 7
0
 internal Address(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 8
0
 internal AAAA(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 9
0
 internal NS(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 10
0
 internal Default(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 11
0
 internal OPT(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 12
0
 internal SOA(DNS.RRBase @base)
     : base(@base)
 {
 }
Exemplo n.º 13
0
 internal MX(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 14
0
 internal SPF(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 15
0
 internal PTR(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 16
0
 internal CNAME(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }
Exemplo n.º 17
0
 string[] GetIPAddresses(DNS.Protocol.RecordType type)
 {
     // This part sucks. Basically I don't know how to make ipv6 and ipv4 requests in .NET
     // so my hacky workaround is to look up the addresses directly
     // BUT, if the user specifices an address URL or a local URL I'm SOL basically
     // I just pass them through if I can't find them
     if (rendezvousUri_.HostNameType != System.UriHostNameType.IPv4 &&
         rendezvousUri_.HostNameType != System.UriHostNameType.IPv6)
     {
         string[] addresses = HFTDnsUtils.GetIPAddresses(rendezvousUri_.DnsSafeHost, type);
         if (addresses != null && addresses.Length > 0)
         {
             return addresses;
         }
     }
     return new string[] {
         rendezvousUri_.Host,
     };
 }
Exemplo n.º 18
0
 internal MessageEventArgs(DNS.Message message, Stream data, IPEndPoint ep)
 {
     _Message = message;
       _Data = data;
       _EndPoint = ep;
 }
Exemplo n.º 19
0
 internal TXT(DNS.RRBase rrbase)
     : base(rrbase)
 {
 }