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

Linode DNS Pagination Bug "Domain does not exist" #4956

Open
sabey opened this issue Jan 22, 2024 · 6 comments
Open

Linode DNS Pagination Bug "Domain does not exist" #4956

sabey opened this issue Jan 22, 2024 · 6 comments

Comments

@sabey
Copy link

sabey commented Jan 22, 2024

Linode DNS will return Domain does not exist. if the domain does not exist in the first page of results.

My domain is contained on page 2 of 3 and only the first page is checked.
curl -H "Authorization: Bearer TOKEN" https://api.linode.com/v4/domains

{
    "data": [],
    "page": 1,
    "pages": 3,
    "results": 245
}

Changing the GET URL to https://api.linode.com/v4/domains?page_size=500 resolves my issue but does not resolve the pagination issue.

dnsapi/dns_linode_v4.sh

_get_root() {
  domain=$1
  i=2
  p=1

  if _rest GET "?page_size=500"; then
Copy link

Please upgrade to the latest code and try again first. Maybe it's already fixed. acme.sh --upgrade If it's still not working, please provide the log with --debug 2, otherwise, nobody can help you.

@vmmello
Copy link

vmmello commented Jan 22, 2024

Another option would be to make the API query return only the desired domain (instead of listing all domains and going through the results):

_get_root() {
  domain="$1"
  #...
  # line 135 below:
  if _H4="X-Filter: {\"domain:\":\"$domain\"}" _rest GET; then

I think this way it fixes the pagination issue.

Can you test?

@sabey
Copy link
Author

sabey commented Jan 23, 2024

Another option would be to make the API query return only the desired domain (instead of listing all domains and going through the results):

_get_root() {
  domain="$1"
  #...
  # line 135 below:
  if _H4="X-Filter: {\"domain:\":\"$domain\"}" _rest GET; then

I think this way it fixes the pagination issue.

Can you test?

didn't work unfortunately

response='{"errors": [{"reason": "Cannot filter on domain:", "field": "X-Filter"}]}'

@vmmello
Copy link

vmmello commented Jan 23, 2024

Ops, sorry. There's a typo in the line I wrote. There's an invalid extra ':' character in the filter.

The correct one is:

if _H4="X-Filter: {\"domain\":\"$domain\"}" _rest GET; then

The reasoning of the above is, whenever you run on command line:

curl -s -H 'X-Filter: {"domain":"a-domain-on-linode.com"}' -H "Authorization: Bearer $linode_token" https://api.linode.com/v4/domains

it will return just the desired domain.

Can you please try again?

@sabey
Copy link
Author

sabey commented Jan 23, 2024

Ops, sorry. There's a typo in the line I wrote. There's an invalid extra ':' character in the filter.

The correct one is:

if _H4="X-Filter: {\"domain\":\"$domain\"}" _rest GET; then

The reasoning of the above is, whenever you run on command line:

curl -s -H 'X-Filter: {"domain":"a-domain-on-linode.com"}' -H "Authorization: Bearer $linode_token" https://api.linode.com/v4/domains

it will return just the desired domain.

Can you please try again?

good catch, although $domain does not seem to work as it includes acme _acme-challenge.domain.tld

although I hardcoded it to domain.tld and it worked

_get_root() {
  domain=$1
  i=2
  p=1

  _debug domain $domain

  domainfix=$(printf "%s" "$domain" | cut -d . -f $i-100)
  _debug domainfix $domainfix

  if _H4="X-Filter: {\"domain\":\"$domainfix\"}" _rest GET; then

@vmmello
Copy link

vmmello commented Jan 23, 2024

Ok.

Though reading the code again, this would work only for third level records. For higher level records, e.g. 4th.3rd.domain.tld it'd wrongly filter for 3rd.domain.tld as the hosted domain, what would return an empty response and the while loop after it would never match a domain.

For it to work in all cases the _rest GET part needs to be moved within the while loop, and a few other adjustments to the logic. It's not difficult to implement, though it requires a bit of attention.

vmmello added a commit to vmmello/acme.sh that referenced this issue Jun 11, 2024
fixes issue acmesh-official#4956

previous code only worked for the first 10 domains on the account (as Linode
API returned a paginated response, with only 10 records).

This change makes an exact search query for each subdomain, completely removing any
need for walking through paginated responses. What makes it work for large
accounts with any number of domains.
vmmello added a commit to vmmello/acme.sh that referenced this issue Jun 11, 2024
fixes issue acmesh-official#4956

previous code only worked for the first 10 domains on the account (as Linode
API returned a paginated response, with only 10 records).

This change makes an exact search query for each subdomain, completely removing any
need for walking through paginated responses. What makes it work for large
accounts with any number of domains.
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

2 participants