mirror of
https://github.com/Such-Software/adaptive-multi-protocol-gateway.git
synced 2026-12-03 05:13:59 +01:00
fix(dynadot): read an apex MX that Dynadot returns typed "stealth"
Dynadot's records endpoint returns suchshop.lol's apex MX with record_type "stealth", the mail host in record_value1 and the preference in record_value2. Sending that record back, which any preserve-unmanaged write has to do, is rejected by Dynadot with "Please enter a valid stealth forwarding url looks like this: http://subdomain.example.com". The POST replaces the whole zone, so the rejection takes every other record in the batch with it. Six DMARC report authorizations could not be published for exactly this reason, and no amount of correctness in the manifest would have helped. Confirmed rather than inferred. The apex returns three records, stealth/txt/a, and the apex serves three records, MX/TXT/A. Matching them one to one gives stealth = MX 10 mail.suchshop.lol; the txt and a records match their live values exactly, and there is no fourth record and no forwarding configured. Three separate reads across two days returned the same thing. The correction is narrow because the two shapes cannot overlap. A genuine stealth forward stores a URL in value1 and leaves value2 empty, which is the format Dynadot's own error message asks for. A hostname in value1 with an integer preference in value2 is not a valid stealth record in any configuration, so the reader treats that combination, and only that combination, as MX. The end-to-end read test already carried a copy of this zone and asserted the bogus type was preserved verbatim, calling it "an unusual type is still a record". That assertion described the bug. It now requires the apex to read as MX with its preference intact.
This commit is contained in:
@@ -50,6 +50,34 @@ DYNADOT_API_ORIGINS = {
|
||||
}
|
||||
|
||||
|
||||
def _is_mislabelled_apex_mx(record_type: str, value1: str | None, value2: str | None) -> bool:
|
||||
"""Dynadot returns an apex MX record typed "stealth".
|
||||
|
||||
Observed on suchshop.lol across three reads on two days: the zone's three
|
||||
apex records come back as stealth/txt/a, and comparing them one to one with
|
||||
what the apex actually serves gives stealth = MX 10 mail.suchshop.lol. There
|
||||
is no fourth record and no forwarding configured. Writing that record back
|
||||
with the type Dynadot supplied is refused by Dynadot itself, with "Please
|
||||
enter a valid stealth forwarding url", so a zone carrying an apex MX could
|
||||
not be updated at all: the whole POST fails and no record in it is written.
|
||||
|
||||
The two shapes do not overlap, which is what makes this safe to correct
|
||||
rather than guess at. A genuine stealth forward stores a URL in value1 and
|
||||
leaves value2 empty; Dynadot's own error names the format it requires. A
|
||||
hostname in value1 with an integer preference in value2 is not a stealth
|
||||
record in any valid configuration.
|
||||
"""
|
||||
if record_type != "STEALTH" or value1 is None or value2 is None:
|
||||
return False
|
||||
if "://" in value1:
|
||||
return False
|
||||
try:
|
||||
preference = int(value2)
|
||||
except ValueError:
|
||||
return False
|
||||
return 0 <= preference <= 65535
|
||||
|
||||
|
||||
def dynadot_signature(
|
||||
api_key: str,
|
||||
api_secret: str,
|
||||
@@ -282,6 +310,8 @@ class DynadotDNSProvider:
|
||||
value2 = _record_value(item, "record_value2")
|
||||
if value2 is None:
|
||||
value2 = _record_value(item, "value2")
|
||||
if _is_mislabelled_apex_mx(record_type, value1, value2):
|
||||
record_type = "MX"
|
||||
if not name or value1 is None:
|
||||
raise RuntimeError("Dynadot returned an incomplete DNS record")
|
||||
mx_pref = None
|
||||
|
||||
Reference in New Issue
Block a user