comparison net/resolvers/basic.lua @ 14111:1cf6e3f49d10 13.0

net.resolvers: Fix to avoid SRV lookups for IP addresses SRV lookups of the form _service._tcp.192.0.0.8 IN SRV makes no sense. Problem was, what would a service without a default port do? Now this problem belongs to the basic resolver, which gets to return the error.
author Kim Alvefur <zash@zash.se>
date Tue, 24 Mar 2026 16:34:06 +0100
parents ba409c67353b
children 59064f0f8b4e
comparison
equal deleted inserted replaced
14110:f587496eb08f 14111:1cf6e3f49d10
68 local next_target = table.remove(self.targets, 1); 68 local next_target = table.remove(self.targets, 1);
69 cb(next_target[1], next_target[2], next_target[3], next_target[4], not not self.targets[1]); 69 cb(next_target[1], next_target[2], next_target[3], next_target[4], not not self.targets[1]);
70 return; 70 return;
71 end 71 end
72 72
73 if not self.port then
74 self.last_error = "indeterminate port";
75 cb(nil);
76 return;
77 end
78
73 if not self.hostname then 79 if not self.hostname then
74 self.last_error = "hostname failed IDNA"; 80 self.last_error = "hostname failed IDNA";
75 cb(nil); 81 cb(nil);
76 return; 82 return;
77 end 83 end
126 132
127 local is_ip = inet_pton(hostname); 133 local is_ip = inet_pton(hostname);
128 if not is_ip and hostname:sub(1,1) == '[' then 134 if not is_ip and hostname:sub(1,1) == '[' then
129 is_ip = inet_pton(hostname:sub(2,-2)); 135 is_ip = inet_pton(hostname:sub(2,-2));
130 end 136 end
131 if is_ip then 137 if is_ip and port then
132 hostname = inet_ntop(is_ip); 138 hostname = inet_ntop(is_ip);
133 if #is_ip == 16 then 139 if #is_ip == 16 then
134 targets = { { conn_type.."6", hostname, port, extra } }; 140 targets = { { conn_type.."6", hostname, port, extra } };
135 elseif #is_ip == 4 then 141 elseif #is_ip == 4 then
136 targets = { { conn_type.."4", hostname, port, extra } }; 142 targets = { { conn_type.."4", hostname, port, extra } };