Windows 8 problem.

Apr 1, 2013 at 10:20 AM
Edited Apr 1, 2013 at 10:48 AM
Hi There,

I am building some kind of forwarding DNS server using your library.
Thanks for the great library.

It was working fine on Windows 7.
But not working on Windows 8.

So I tried your simple forwarding DNS server example.
It was working fine.
But when I tried to use a custom DNSClient it's not working again.
Seems like sending query is fine but not getting an answer.

This is the code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using ARSoft.Tools.Net.Dns;

namespace dclt
{
class Program
{
    static DnsClient resolver = null;

    static void Main(string[] args)
    {
        resolver = new DnsClient(IPAddress.Parse("8.8.4.4"), 6);

        using (DnsServer server = new DnsServer(IPAddress.Any, 10, 10, ProcessQuery))
        {
            server.Start();

            Console.WriteLine("Press any key to stop server");
            Console.ReadLine();
        }
    }

    static DnsMessageBase ProcessQuery(DnsMessageBase message, IPAddress clientAddress, ProtocolType protocol)
    {
        message.IsQuery = false;

        DnsMessage query = message as DnsMessage;

        if ((query != null) && (query.Questions.Count == 1))
        {
            // send query to upstream server
            DnsQuestion question = query.Questions[0];
            DnsMessage answer = resolver.Resolve(question.Name, question.RecordType, question.RecordClass);

            // if got an answer, copy it to the message sent to the client
            if (answer != null)
            {
                foreach (DnsRecordBase record in (answer.AnswerRecords))
                {
                    query.AnswerRecords.Add(record);
                }
                foreach (DnsRecordBase record in (answer.AdditionalRecords))
                {
                    query.AnswerRecords.Add(record);
                }

                query.ReturnCode = ReturnCode.NoError;
                return query;
            }
        }

        // Not a valid query or upstream server did not answer correct
        message.ReturnCode = ReturnCode.ServerFailure;
        return message;
    }
}

}

Did I make any mistake?
Or is there any problem with Windows 8?

Thanks,

Jinhee