AnalogJ / lexicon

Manipulate DNS records on various DNS providers in a standardized way.
MIT License
1.47k stars 303 forks source link

Cannot make SRV on CloudFlare #1861

Open ProfessorManhattan opened 8 months ago

ProfessorManhattan commented 8 months ago

I used ChatGPT to get the appropriate command necessary to create a SRV record on CloudFlare. I'm able to make other record types, however SRV is tricky because it requires multiple data keys in the --content field. I tried:

lexicon cloudflare create example.com SRV --name "_sip._tcp" --content "1 5 5060 sip.example.com"

Which resulted in the following error:

Traceback (most recent call last):
  File "/opt/homebrew/bin/lexicon", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/lexicon/_private/cli.py", line 135, in main
    results = client.execute()
  File "/opt/homebrew/lib/python3.10/site-packages/lexicon/client.py", line 216, in execute
    return executor.create_record(rtype, name, content)
  File "/opt/homebrew/lib/python3.10/site-packages/lexicon/client.py", line 35, in create_record
    return self.provider.create_record(rtype, name, content)
  File "/opt/homebrew/lib/python3.10/site-packages/lexicon/_private/providers/cloudflare.py", line 89, in create_record
    payload = self._post(f"/zones/{self.domain_id}/dns_records", data)
  File "/opt/homebrew/lib/python3.10/site-packages/lexicon/interfaces.py", line 170, in _post
    return self._request("POST", url, data=data, query_params=query_params)
  File "/opt/homebrew/lib/python3.10/site-packages/lexicon/_private/providers/cloudflare.py", line 213, in _request
    response.raise_for_status()
  File "/opt/homebrew/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.cloudflare.com/client/v4/zones

When I look at pre-existing SRV records, they appear to have --content like this:

0\t2380\tmercury.example.com
adferrand commented 4 months ago

Yes SRV records are not officially supported by Lexicon. The tools is mainly here to manipulate A, CNAME and TXT records for the sake of DNS-01 challenges with Let'sEncrypt.