# HG changeset patch # User Kim Alvefur # Date 1645059564 -3600 # Node ID 54fa2116bbf37b9347003b197ab359dec0d42ab7 # Parent 2542fd80cd159c8f640a84932b9ebc46a541c3ee mod_dnsupdate: Add a --remove option to delete all SRV records diff -r 2542fd80cd15 -r 54fa2116bbf3 mod_dnsupdate/mod_dnsupdate.lua --- a/mod_dnsupdate/mod_dnsupdate.lua Tue Feb 15 21:51:52 2022 +0100 +++ b/mod_dnsupdate/mod_dnsupdate.lua Thu Feb 17 01:59:24 2022 +0100 @@ -42,6 +42,7 @@ out:write("\t-l --ttl\tTTL to use\n"); out:write("\t--each\tremove and replace individual SRV records\n"); out:write("\t--reset\tremove and replace all SRV records\n"); + out:write("\t--remove\tremove all SRV records\n"); return opts and opts.help and 0 or 1; end @@ -103,7 +104,7 @@ for _, service in ipairs(services) do local ports = set.new(configured_ports[service]); local records = (async.wait_for(existing_srv[service])); - if opts.reset then + if opts.remove or opts.reset then print(("del _%s._tcp.%s IN SRV"):format(service, ihost)); else for _, rr in ipairs(records) do @@ -117,7 +118,9 @@ end end end - for port in ports do print(("add _%s._tcp.%s IN SRV 1 1 %d %s"):format(service, ihost, port, target)); end + if not opts.remove then + for port in ports do print(("add _%s._tcp.%s IN SRV 1 1 %d %s"):format(service, ihost, port, target)); end + end end print("show");