Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix namecheap MX record support. #514

Merged
merged 1 commit into from Jun 1, 2020

Conversation

doddo
Copy link
Contributor

@doddo doddo commented May 20, 2020

Creating MX records with namecheap used to crash like this:

lexicon  namecheap create peppe.club MX  --name "@" --content "10 smtp.peppe.club"
Remote: 8
To set: 9
Traceback (most recent call last):
  File "/home/petter/git/lexicon/venv/bin/lexicon", line 11, in <module>
    load_entry_point('dns-lexicon==3.3.22', 'console_scripts', 'lexicon')()
  File "/home/petter/git/lexicon/venv/lib/python3.8/site-packages/dns_lexicon-3.3.22-py3.8.egg/lexicon/cli.py", line 117, in main
    results = client.execute()
  File "/home/petter/git/lexicon/venv/lib/python3.8/site-packages/dns_lexicon-3.3.22-py3.8.egg/lexicon/client.py", line 84, in execute
    return self.provider.create_record(record_type, name, content)
  File "/home/petter/git/lexicon/venv/lib/python3.8/site-packages/dns_lexicon-3.3.22-py3.8.egg/lexicon/providers/base.py", line 80, in create_record
    return self._create_record(rtype, name, content)
  File "/home/petter/git/lexicon/venv/lib/python3.8/site-packages/dns_lexicon-3.3.22-py3.8.egg/lexicon/providers/namecheap.py", line 202, in _create_record
    self.client.domains_dns_addHost(self.domain, record)
  File "/home/petter/git/lexicon/venv/lib/python3.8/site-packages/namecheap.py", line 388, in domains_dns_addHost
    self._call("namecheap.domains.dns.setHosts", extra_payload)
  File "/home/petter/git/lexicon/venv/lib/python3.8/site-packages/namecheap.py", line 144, in _call
    xml = self._fetch_xml(payload, extra_payload)
  File "/home/petter/git/lexicon/venv/lib/python3.8/site-packages/namecheap.py", line 137, in _fetch_xml
    raise ApiError(error.attrib['Number'], error.text)
namecheap.ApiError: 2050900 - INVALID_ADDR : ' 10 smtp.peppe.club' should not be an IP/ URL for MX record.(host name: @)

Furthermore, listing them did not usually produce the priority field.

With this fix, it works:

% PYTHONPATH=. lexicon  namecheap create peppe.club MX  --name "@" --content "10 smtp.peppe.club"
Remote: 8
To set: 9
RESULT
------
True
% PYTHONPATH=. lexicon  namecheap list peppe.club MX
ID     TYPE NAME            CONTENT              TTL 
------ ---- --------------- -------------------- ----
746267 MX   @.peppe.club    10 smtp.peppe.club.  3600

@doddo doddo force-pushed the fix_namecheap_MX_Record_support branch from e50385e to e47e44c Compare May 20, 2020 20:46
namecheap MX records are handled a bit specially compared to
other records; it seems all records has the MXPref field, but only the
MX record uses it.
maybe a new feature or something.

It used to not be able to create MX records, but now it can.
@doddo doddo force-pushed the fix_namecheap_MX_Record_support branch from e47e44c to e1b74b6 Compare May 20, 2020 20:53
Copy link
Collaborator

@adferrand adferrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks a lot.

@adferrand adferrand merged commit 99d2388 into AnalogJ:master Jun 1, 2020
@doddo doddo deleted the fix_namecheap_MX_Record_support branch June 2, 2020 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants