Mercurial > prosody-hg
changeset 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 | f587496eb08f |
| children | 59064f0f8b4e b9688ac25255 |
| files | net/resolvers/basic.lua net/resolvers/service.lua |
| diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/net/resolvers/basic.lua Tue Jan 13 07:13:25 2026 +0100 +++ b/net/resolvers/basic.lua Tue Mar 24 16:34:06 2026 +0100 @@ -70,6 +70,12 @@ return; end + if not self.port then + self.last_error = "indeterminate port"; + cb(nil); + return; + end + if not self.hostname then self.last_error = "hostname failed IDNA"; cb(nil); @@ -128,7 +134,7 @@ if not is_ip and hostname:sub(1,1) == '[' then is_ip = inet_pton(hostname:sub(2,-2)); end - if is_ip then + if is_ip and port then hostname = inet_ntop(is_ip); if #is_ip == 16 then targets = { { conn_type.."6", hostname, port, extra } };
--- a/net/resolvers/service.lua Tue Jan 13 07:13:25 2026 +0100 +++ b/net/resolvers/service.lua Tue Mar 24 16:34:06 2026 +0100 @@ -154,8 +154,8 @@ if not is_ip and hostname:sub(1,1) == '[' then is_ip = inet_pton(hostname:sub(2,-2)); end - if is_ip and extra and extra.default_port then - return basic.new(hostname, extra.default_port, conn_type, extra); + if is_ip then + return basic.new(hostname, extra and extra.default_port, conn_type, extra); end return setmetatable({
