Ejemplo n.º 1
0
        void HandleRequest(IAsyncResult result)
        {
            try
            {
                using (Socket socket = m_listener.EndAcceptSocket(result))
                {
                    TestTCPClient client   = new TestTCPClient(socket); // Chunk sends
                    DnsRequest    request  = client.ReceiveRequest();
                    DnsResponse   response = null;
                    try
                    {
                        response = m_store.Get(request);
                        if (response == null)
                        {
                            response = new DnsResponse(request);
                            response.Header.ResponseCode = DnsStandard.ResponseCode.NameError;
                        }
                    }
                    catch
                    {
                        response = new DnsResponse(request);
                        response.Header.ResponseCode = DnsStandard.ResponseCode.NameError;
                    }

                    if (response != null)
                    {
                        client.Send(response);
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        void TestType <T>(DnsStandard.RecordType recordType, string domain, Func <T, bool> verify)
            where T : DnsResourceRecord
        {
            bool threw = false;

            try
            {
                using (Socket socket = TestServer.Default.CreateTCPSocket())
                {
                    TestTCPClient client  = new TestTCPClient(socket);
                    DnsRequest    request = new DnsRequest(recordType, domain);
                    client.Send(request);

                    DnsResourceRecord record = client.Receive();
                    Assert.True(record.Type == recordType);
                    Assert.True(record.Name.Equals(request.Question.Domain, StringComparison.OrdinalIgnoreCase));

                    T rr = null;

                    Assert.Null(Record.Exception(() => rr = (T)record));
                    Assert.True(verify(rr));
                }
            }
            catch
            {
                threw = true;
            }

            Assert.False(threw);
        }
Ejemplo n.º 3
0
 void HandleRequest(IAsyncResult result)
 {
     try
     {
         using(Socket socket = m_listener.EndAcceptSocket(result))
         {
             TestTCPClient client = new TestTCPClient(socket); // Chunk sends
             DnsRequest request = client.ReceiveRequest();
             DnsResponse response = null;
             try
             {
                 response = m_store.Get(request);
                 if (response == null)
                 {
                     response = new DnsResponse(request);
                     response.Header.ResponseCode = DnsStandard.ResponseCode.NameError;
                 }
             }
             catch
             {
                 response = new DnsResponse(request);
                 response.Header.ResponseCode = DnsStandard.ResponseCode.NameError;
             }
             
             if (response != null)
             {
                 client.Send(response);
             }
         }
     }
     catch
     {
     }
 }