Пример #1
0
        } // End Function OnClientConnected

        private static async System.Threading.Tasks.Task OnQueryReceived(object sender, ARSoft.Tools.Net.Dns.QueryReceivedEventArgs e)
        {
            ARSoft.Tools.Net.Dns.DnsMessage query = e.Query as ARSoft.Tools.Net.Dns.DnsMessage;

            if (query == null)
            {
                return;
            }


            // e.RemoteEndpoint.Address

            ARSoft.Tools.Net.Dns.DnsMessage response = query.CreateResponseInstance();

            // check for valid query
            if ((query.Questions.Count == 1) &&
                (query.Questions[0].RecordType == ARSoft.Tools.Net.Dns.RecordType.Txt) &&
                (query.Questions[0].Name.Equals(ARSoft.Tools.Net.DomainName.Parse("example.com"))))
            {
                response.ReturnCode = ARSoft.Tools.Net.Dns.ReturnCode.NoError;
                response.AnswerRecords.Add(new ARSoft.Tools.Net.Dns.TxtRecord(ARSoft.Tools.Net.DomainName.Parse("example.com"), 3600, "Hello world"));
            }
            else
            {
                response.ReturnCode = ARSoft.Tools.Net.Dns.ReturnCode.ServerFailure;
            }

            // set the response
            e.Response = response;
        } // End Function OnQueryReceived
Пример #2
0
        } // End Function OnClientConnected

        static async System.Threading.Tasks.Task OnQueryReceived(object sender, ARSoft.Tools.Net.Dns.QueryReceivedEventArgs e)
        {
            // process query as you like
        } // End Function OnQueryReceived