Mercurial > prosody-hg
diff net/dns.lua @ 13925:a4c47203a9eb
various: Do not mutate loop variables as they are treated as const in Lua 5.5
Loop variables are treated as <const> in Lua 5.5 and can't be modified
without declaring another local.
Ref https://github.com/lua/lua/commit/b2f7b3b79f3117885b265575f6c5dbf934757797
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 23 Feb 2024 18:44:13 +0100 |
| parents | ba409c67353b |
| children | d649d011df45 |
line wrap: on
line diff
--- a/net/dns.lua Tue Aug 05 22:35:01 2025 +0200 +++ b/net/dns.lua Fri Feb 23 18:44:13 2024 +0100 @@ -701,10 +701,10 @@ local resolv_conf = io.open("/etc/resolv.conf"); if resolv_conf then for line in resolv_conf:lines() do - line = line:gsub("#.*$", "") + local nameserver = line:gsub("#.*$", "") :match('^%s*nameserver%s+([%x:%.]*%%?%S*)%s*$'); - if line then - local ip = new_ip(line); + if nameserver then + local ip = new_ip(nameserver); if ip then self:addnameserver(ip.addr); end
