Added support for DNS SRV records

This commit is contained in:
Sebastien Couture 2015-11-18 18:15:59 -05:00 committed by Matt Clay
parent be5dd09237
commit b50980d912

View file

@ -210,10 +210,12 @@ class DME2:
if result['name'] == record_name and result['type'] == record_type: if result['name'] == record_name and result['type'] == record_type:
return result return result
return False return False
elif record_type in ["MX", "NS", "TXT"]: elif record_type in ["MX", "NS", "TXT", "SRV"]:
for result in self.all_records: for result in self.all_records:
if record_type == "MX": if record_type == "MX":
value = record_value.split(" ")[1] value = record_value.split(" ")[1]
elif record_type == "SRV":
value = record_value.split(" ")[3]
else: else:
value = record_value value = record_value
if result['name'] == record_name and result['type'] == record_type and result['value'] == value: if result['name'] == record_name and result['type'] == record_type and result['value'] == value:
@ -309,6 +311,13 @@ def main():
new_record["mxLevel"] = new_record["value"].split(" ")[0] new_record["mxLevel"] = new_record["value"].split(" ")[0]
new_record["value"] = new_record["value"].split(" ")[1] new_record["value"] = new_record["value"].split(" ")[1]
# Special handling for SRV records
if new_record["type"] == "SRV":
new_record["priority"] = new_record["value"].split(" ")[0]
new_record["weight"] = new_record["value"].split(" ")[1]
new_record["port"] = new_record["value"].split(" ")[2]
new_record["value"] = new_record["value"].split(" ")[3]
# Compare new record against existing one # Compare new record against existing one
changed = False changed = False
if current_record: if current_record: