Software /
code /
prosody
Comparison
net/dns.lua @ 10955:7bcfac630b65
net.dns: Add some debug logging
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 25 Jun 2020 15:22:40 +0100 |
parent | 10664:c2b79b44ded7 |
child | 10956:03a09fa02e8e |
comparison
equal
deleted
inserted
replaced
10954:fc310727adfb | 10955:7bcfac630b65 |
---|---|
14 | 14 |
15 local socket = require "socket"; | 15 local socket = require "socket"; |
16 local have_timer, timer = pcall(require, "util.timer"); | 16 local have_timer, timer = pcall(require, "util.timer"); |
17 local new_ip = require "util.ip".new_ip; | 17 local new_ip = require "util.ip".new_ip; |
18 local have_util_net, util_net = pcall(require, "util.net"); | 18 local have_util_net, util_net = pcall(require, "util.net"); |
19 | |
20 local log = require "util.logger".init("dns"); | |
19 | 21 |
20 local _, windows = pcall(require, "util.windows"); | 22 local _, windows = pcall(require, "util.windows"); |
21 local is_windows = (_ and windows) or os.getenv("WINDIR"); | 23 local is_windows = (_ and windows) or os.getenv("WINDIR"); |
22 | 24 |
23 local coroutine, io, math, string, table = | 25 local coroutine, io, math, string, table = |
875 local num_servers = #self.server; | 877 local num_servers = #self.server; |
876 local i = 1; | 878 local i = 1; |
877 timer.add_task(self.timeout, function () | 879 timer.add_task(self.timeout, function () |
878 if get(self.wanted, qclass, qtype, qname, co) then | 880 if get(self.wanted, qclass, qtype, qname, co) then |
879 if i < num_servers then | 881 if i < num_servers then |
882 log("debug", "DNS request timeout %d/%d", i, num_servers) | |
880 i = i + 1; | 883 i = i + 1; |
881 self:servfail(conn); | 884 self:servfail(conn); |
882 o.server = self.best_server; | 885 o.server = self.best_server; |
883 conn, err = self:getsocket(o.server); | 886 conn, err = self:getsocket(o.server); |
884 if conn then | 887 if conn then |
902 -- Socket is dead now | 905 -- Socket is dead now |
903 sock = self:voidsocket(sock); | 906 sock = self:voidsocket(sock); |
904 | 907 |
905 -- Find all requests to the down server, and retry on the next server | 908 -- Find all requests to the down server, and retry on the next server |
906 self.time = socket.gettime(); | 909 self.time = socket.gettime(); |
910 log("debug", "servfail %d (of %d)", num, #self.server); | |
907 for id,queries in pairs(self.active) do | 911 for id,queries in pairs(self.active) do |
908 for question,o in pairs(queries) do | 912 for question,o in pairs(queries) do |
909 if o.server == num then -- This request was to the broken server | 913 if o.server == num then -- This request was to the broken server |
910 o.server = o.server + 1 -- Use next server | 914 o.server = o.server + 1 -- Use next server |
911 if o.server > #self.server then | 915 if o.server > #self.server then |