# HG changeset patch # User Kim Alvefur # Date 1636408994 -3600 # Node ID a754f7e380b2c721565f8a30d6ec1425c2b3b73d # Parent 91077c928c5799852631870b57bfbcd9026f2c38 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. diff -r 91077c928c57 -r a754f7e380b2 mod_dnsupdate/mod_dnsupdate.lua --- 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");