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

Can't add SRV records anymore #46

Closed
leshik opened this issue Mar 20, 2019 · 4 comments
Closed

Can't add SRV records anymore #46

leshik opened this issue Mar 20, 2019 · 4 comments

Comments

@leshik
Copy link
Contributor

leshik commented Mar 20, 2019

Hi,

I'm unable to add SRV type records with this tool anymore, e.g. something like this:

cfcli -d example.org -t SRV add _test._tcp.example.org 0 0 1234 server.example.org

I'm sure it was working several months ago as I have built this command into my scripts that were working at a time. Apparently CF changed something that breaks the tool. Tried with priority option too but no luck.

@leshik
Copy link
Contributor Author

leshik commented Mar 20, 2019

I investigated further using curl and CF API documentation & examples. Previously, it was working like this (and that's how the documentation tells us to add DNS records):

curl -X POST "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records" \
     -H "X-Auth-Email: user@example.com" \
     -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
     -H "Content-Type: application/json" \
     --data '{"type":"SRV","name":"_test._tcp.example.org","content":"0 0 1234 server.example.org"}'

This is not the case anymore. The API will return the error:

{
  "success": false,
  "errors": [
    {
      "code": 1004,
      "message": "DNS Validation Error",
      "error_chain": [
        {
          "code": 9101,
          "message": "service is a required data field."
        }
      ]
    }
  ],
  "messages": [],
  "result": null
}

Seems now there should be an additional data field inside the JSON, i.e.:

curl -X POST "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records" \
     -H "X-Auth-Email: user@example.com" \
     -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
     -H "Content-Type: application/json" \
     --data '{"type":"SRV","name":"_test._tcp.example.org","content":"0 0 1234 server.example.org","data":{"priority":0,"weight":0,"port":1234,"target":"server.example.org","service":"_test","proto":"_tcp","name":"example.org"}}'

This works well, though not documented. Seems this should be changed in cfcli tool too.

@leshik
Copy link
Contributor Author

leshik commented Mar 20, 2019

This JSON might look a bit redundant, I tested and it seems we can avoid duplication by removing name and content fields:

{
  "type": "SRV",
  "data": {
    "service": "_test",
    "proto": "_tcp",
    "name": "example.org",
    "priority": 0,
    "weight": 0,
    "port": 1234,
    "target": "server.example.org"
  }
}

It works ok too.

leshik added a commit to leshik/cloudflare-cli that referenced this issue Mar 20, 2019
@leshik
Copy link
Contributor Author

leshik commented Mar 20, 2019

Turned out, priority, weight and port can't be of type String anymore. I've made PR #47 that fixes it.

leshik added a commit to leshik/cloudflare-cli that referenced this issue Mar 20, 2019
@leshik
Copy link
Contributor Author

leshik commented Mar 20, 2019

I've also fixed priority parsing, it should be at index 0. In master it always equals to weight.

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

No branches or pull requests

1 participant