Software /
code /
prosody-modules
Diff
mod_dnsupdate/mod_dnsupdate.lua @ 4764:a754f7e380b2
mod_dnsupdate: Rewrite port config vs DNS comparison code
I'm not sure if it was correct, which means it was hard to understand
and thus needed to be simplified. Hope this accomplishes that.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 08 Nov 2021 23:03:14 +0100 |
parent | 4763:91077c928c57 |
child | 4765:3632836f35b0 |
line wrap: on
line diff
--- a/mod_dnsupdate/mod_dnsupdate.lua Mon Nov 08 22:28:00 2021 +0100 +++ b/mod_dnsupdate/mod_dnsupdate.lua Mon Nov 08 23:03:14 2021 +0100 @@ -98,20 +98,18 @@ for _, service in ipairs(services) do local ports = set.new(configured_ports[service]); local records = (async.wait_for(existing_srv[service])); - local replace = opts.reset; - for _, rr in ipairs(records) do - if not ports:contains(rr.srv.port) or target ~= nameprep(rr.srv.target):gsub("%.$", "") then - if not opts.each then - replace = true; - break + if opts.reset then + print(("del _%s._tcp.%s IN SRV"):format(service, ihost)); + else + for _, rr in ipairs(records) do + if ports:contains(rr.srv.port) and target == nameprep(rr.srv.target):gsub("%.$", "") then + ports:remove(rr.srv.port) + else + print(("del _%s._tcp.%s IN SRV %s"):format(service, ihost, rr)); end - print(("del _%s._tcp.%s IN SRV %s"):format(service, ihost, rr)); end end - if replace then - print(("del _%s._tcp.%s IN SRV"):format(service, ihost)); - for port in ports do print(("add _%s._tcp.%s IN SRV 1 1 %d %s"):format(service, ihost, port, target)); end - end + for port in ports do print(("add _%s._tcp.%s IN SRV 1 1 %d %s"):format(service, ihost, port, target)); end end print("show");