Ejemplo n.º 1
0
        public bool Search(string host, QueryType?qtype, string dns, byte[] id)
        {
            string _dns = string.IsNullOrEmpty(dns) ? "8.8.8.8" : dns;

            byte[] _id = id == null?newid() : id;

            QueryType _qtype = qtype == null ? QueryType.A : (QueryType)qtype;

            header = new MyDnsHeader();
            header.NewID(_id);
            question       = new MyDnsQuestion();
            question.Class = QueryClass.IN;
            question.Type  = _qtype;
            question.Qname = host;
            byte[] data_head     = header.GetBytes();
            byte[] data_question = question.GetBytes();
            byte[] sendData      = new byte[data_head.Length + data_question.Length];
            data_head.CopyTo(sendData, 0);
            data_question.CopyTo(sendData, data_head.Length);

            byte[] recvData;
            recvData = udpSend(sendData, _dns);
            Parse(recvData);
            return(header.RCODE == 0 ? true : false);
        }
Ejemplo n.º 2
0
 void Parse(byte[] data)
 {
     header.Parse(data);
     question.Parse(data);
     record = new MyDnsRecord();
     record.Parse(data, question.GetBytes().Length + 12);
 }
Ejemplo n.º 3
0
        public bool Search(string host, QueryType? qtype, string dns, byte[] id)
        {
            string _dns = string.IsNullOrEmpty(dns) ? "8.8.8.8" : dns;
            byte[] _id = id == null ? newid() : id;
            QueryType _qtype = qtype == null ? QueryType.A : (QueryType)qtype;

            header = new MyDnsHeader();
            header.NewID(_id);
            question = new MyDnsQuestion();
            question.Class = QueryClass.IN;
            question.Type = _qtype;
            question.Qname = host;
            byte[] data_head = header.GetBytes();
            byte[] data_question = question.GetBytes();
            byte[] sendData = new byte[data_head.Length + data_question.Length];
            data_head.CopyTo(sendData, 0);
            data_question.CopyTo(sendData, data_head.Length);

            byte[] recvData;
            recvData = udpSend(sendData, _dns);
            Parse(recvData);
            return header.RCODE == 0 ? true : false;
        }