equal
deleted
inserted
replaced
342 -- 2 server failure |
342 -- 2 server failure |
343 -- 3 name error |
343 -- 3 name error |
344 -- 4 not implemented |
344 -- 4 not implemented |
345 -- 5 refused |
345 -- 5 refused |
346 -- 6-15 reserved |
346 -- 6-15 reserved |
347 o.z = o.z or 0; -- 3b 0 resvered |
347 o.z = o.z or 0; -- 3b 0 reserved |
348 o.ra = o.ra or 0; -- 1b 1 recursion available |
348 o.ra = o.ra or 0; -- 1b 1 recursion available |
349 |
349 |
350 o.qdcount = o.qdcount or 1; -- 16b number of question RRs |
350 o.qdcount = o.qdcount or 1; -- 16b number of question RRs |
351 o.ancount = o.ancount or 0; -- 16b number of answers RRs |
351 o.ancount = o.ancount or 0; -- 16b number of answers RRs |
352 o.nscount = o.nscount or 0; -- 16b number of nameservers RRs |
352 o.nscount = o.nscount or 0; -- 16b number of nameservers RRs |
883 |
883 |
884 -- remember which coroutine wants the answer |
884 -- remember which coroutine wants the answer |
885 if co then |
885 if co then |
886 set(self.wanted, qclass, qtype, qname, co, true); |
886 set(self.wanted, qclass, qtype, qname, co, true); |
887 end |
887 end |
888 |
888 |
889 if have_timer and self.timeout then |
889 if have_timer and self.timeout then |
890 local num_servers = #self.server; |
890 local num_servers = #self.server; |
891 local i = 1; |
891 local i = 1; |
892 timer.add_task(self.timeout, function () |
892 timer.add_task(self.timeout, function () |
893 if get(self.wanted, qclass, qtype, qname, co) then |
893 if get(self.wanted, qclass, qtype, qname, co) then |
939 else |
939 else |
940 log("debug", "retry %d (immediate)", o.retries); |
940 log("debug", "retry %d (immediate)", o.retries); |
941 sock:send(o.packet); |
941 sock:send(o.packet); |
942 end |
942 end |
943 end |
943 end |
944 end |
944 end |
945 if not retried then |
945 if not retried then |
946 log("debug", 'tried all servers, giving up'); |
946 log("debug", 'tried all servers, giving up'); |
947 self:cancel(o.qclass, o.qtype, o.qname); |
947 self:cancel(o.qclass, o.qtype, o.qname); |
948 queries[question] = nil; |
948 queries[question] = nil; |
949 end |
949 end |
992 end |
992 end |
993 |
993 |
994 -- retire the query |
994 -- retire the query |
995 local queries = self.active[response.header.id]; |
995 local queries = self.active[response.header.id]; |
996 queries[response.question.raw] = nil; |
996 queries[response.question.raw] = nil; |
997 |
997 |
998 if not next(queries) then self.active[response.header.id] = nil; end |
998 if not next(queries) then self.active[response.header.id] = nil; end |
999 if not next(self.active) then self:closeall(); end |
999 if not next(self.active) then self:closeall(); end |
1000 |
1000 |
1001 -- was the query on the wanted list? |
1001 -- was the query on the wanted list? |
1002 local q = response.question[1]; |
1002 local q = response.question[1]; |
1006 if coroutine.status(co) == "suspended" then coroutine.resume(co); end |
1006 if coroutine.status(co) == "suspended" then coroutine.resume(co); end |
1007 end |
1007 end |
1008 set(self.wanted, q.class, q.type, q.name, nil); |
1008 set(self.wanted, q.class, q.type, q.name, nil); |
1009 end |
1009 end |
1010 end |
1010 end |
1011 |
1011 |
1012 end |
1012 end |
1013 end |
1013 end |
1014 end |
1014 end |
1015 |
1015 |
1016 return response; |
1016 return response; |