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

Added delay to dns porkbun dns update to prevent errors #911

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

likeaninja5
Copy link
Contributor

When updating multiple domains after an ip change porkbun seems to have an issue with too many requests in a short period of time. I don't have much more info than that, since porkbun is returning a 5XX. Usually ddns-updater will only get 1 or 2 domains updated before erroring out on the rest.

I don't actually know go, so apologizes if something isn't following standards here.

Before change.

2025-01-12T20:28:22Z INFO Updating record [domain: domain.com | owner: owner1 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:23Z INFO Updating record [domain: domain.com | owner: owner2 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:24Z ERROR updating record: for record type A, record owner owner2 and record id record_id_1: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>
2025-01-12T20:28:24Z INFO Updating record [domain: domain.com | owner: owner3 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:24Z ERROR getting record IDs: for record type A and record owner owner3: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>
2025-01-12T20:28:24Z INFO Updating record [domain: domain.com | owner: owner4 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:24Z ERROR getting record IDs: for record type A and record owner owner4: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>
2025-01-12T20:28:24Z INFO Updating record [domain: domain.com | owner: owner5 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:24Z ERROR getting record IDs: for record type A and record owner owner5: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>
2025-01-12T20:28:24Z INFO Updating record [domain: domain.com | owner: owner6 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:24Z ERROR getting record IDs: for record type A and record owner owner6: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>
2025-01-12T20:28:24Z INFO Updating record [domain: domain.com | owner: owner7 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:24Z ERROR getting record IDs: for record type A and record owner owner7: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>
2025-01-12T20:28:24Z INFO Updating record [domain: domain.com | owner: owner8 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:24Z ERROR getting record IDs: for record type A and record owner owner8: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>
2025-01-12T20:28:24Z INFO Updating record [domain: domain.com | owner: owner9 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:24Z ERROR getting record IDs: for record type A and record owner owner9: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>
2025-01-12T20:28:24Z INFO Updating record [domain: domain.com | owner: owner10 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:25Z ERROR updating record: for record type A, record owner owner10 and record id record_id_2: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>
2025-01-12T20:28:25Z INFO Updating record [domain: domain.com | owner: owner11 | provider: porkbun | ip: ipv4] to use 123.123.123.123
2025-01-12T20:28:25Z ERROR getting record IDs: for record type A and record owner owner11: HTTP status is not valid: 503: <html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center><hr><center>openresty</center></body></html>

After change:

2025-01-12T21:34:13Z INFO ipv4 address of owner1.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:14Z INFO ipv4 address of owner2.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:14Z INFO ipv4 address of owner3.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:14Z INFO ipv4 address of owner4.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:15Z INFO ipv4 address of owner5.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:15Z INFO ipv4 address of owner6.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:15Z INFO ipv4 address of owner7.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:15Z INFO ipv4 address of owner8.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:15Z INFO ipv4 address of owner9.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:15Z INFO ipv4 address of owner10.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:15Z INFO ipv4 address of owner11.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:16Z INFO ipv4 address of owner12.domain.com is 123.123.123.123 and your ipv4 address  is 111.111.111.111
2025-01-12T21:34:16Z INFO Updating record [domain: domain.com | owner: owner1 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:18Z INFO Updating record [domain: domain.com | owner: owner2 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:20Z INFO Updating record [domain: domain.com | owner: owner3 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:22Z INFO Updating record [domain: domain.com | owner: owner4 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:25Z INFO Updating record [domain: domain.com | owner: owner5 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:27Z INFO Updating record [domain: domain.com | owner: owner6 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:29Z INFO Updating record [domain: domain.com | owner: owner7 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:32Z INFO Updating record [domain: domain.com | owner: owner8 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:35Z INFO Updating record [domain: domain.com | owner: owner9 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:37Z INFO Updating record [domain: domain.com | owner: owner10 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:40Z INFO Updating record [domain: domain.com | owner: owner11 | provider: porkbun | ip: ipv4] to use 111.111.111.111
2025-01-12T21:34:42Z INFO Updating record [domain: domain.com | owner: owner12 | provider: porkbun | ip: ipv4] to use 111.111.111.111

@@ -141,6 +142,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add

for _, record := range records {
err = p.updateRecord(ctx, client, recordType, p.owner, ipStr, record.ID)
time.Sleep(time.Second)
Copy link
Collaborator

@bentemple bentemple Jan 14, 2025

Choose a reason for hiding this comment

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

I ran into this too.

One thing, is that if we're getting rate-limited, likely adding the same sleep delay here won't solely fix the underlying issue. This fixes it for lots of subdomains under the same hostname, but if you have DDNS-updater setup to do lots of different hostnames, you can also run into rate-limiting (as I have encountered).

@qdm12 any thoughts on how you'd want this fixed? Maybe wrap the HTTP client to have a general http request rate limit, either per host, or globally. Would that make sense to you? In my mind, you'd ideally be able to specify a max requests per period for a given provider or globally, and the http client would automatically handle queuing and staying within that request limit.

Copy link
Collaborator

@bentemple bentemple Jan 14, 2025

Choose a reason for hiding this comment

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

This also might be pretty unique to porkbun and we'd just want to setup a porkbun ratelimiter, though I could see it being an issue for any DNS provider during the update step.

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.

2 participants