-
Notifications
You must be signed in to change notification settings - Fork 3.8k
ddns-scripts: add beget.com api support #28102
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/sh | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # following script was referenced: https://github.com/openwrt/packages/blob/master/net/ddns-scripts/files/usr/lib/ddns/update_gandi_net.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| . /usr/share/libubox/jshn.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Beget API description: https://beget.com/en/kb/api/dns-administration-functions#changerecords | ||||||||||||||||||||||||||||||||||||||||||||||||||
| local __CHANGE_ENDPOINT_API="https://api.beget.com/api/dns/changeRecords" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| local __RRTYPE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| local __STATUS | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+10
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| local __CHANGE_ENDPOINT_API="https://api.beget.com/api/dns/changeRecords" | |
| local __RRTYPE | |
| local __STATUS | |
| __CHANGE_ENDPOINT_API="https://api.beget.com/api/dns/changeRecords" | |
| __RRTYPE | |
| __STATUS |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variables __RRTYPE and __STATUS are declared as local at the script's top level, which is outside any function. In shell scripts, local is only meaningful inside functions. These should be declared without the local keyword, similar to how other DDNS update scripts handle their variables at the top level.
| local __CHANGE_ENDPOINT_API="https://api.beget.com/api/dns/changeRecords" | |
| local __RRTYPE | |
| local __STATUS | |
| __CHANGE_ENDPOINT_API="https://api.beget.com/api/dns/changeRecords" | |
| __RRTYPE= | |
| __STATUS= |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The priority field is hardcoded to 10. According to DNS standards, priority is typically only relevant for MX (mail exchange) and SRV (service) records, not for A or AAAA records which are being set here. This field may be unnecessary or could cause API errors. Verify if the Beget API requires or accepts a priority field for A/AAAA records, and if not, this field should be removed.
| json_add_int "priority" 10 |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is trailing whitespace at the end of this line. This should be removed to maintain code cleanliness and consistency with the rest of the codebase.
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script does not check the curl exit code or HTTP status code returned from the API. Unlike other DDNS update scripts (e.g., update_gandi_net.sh, update_digitalocean_com_v2.sh), there's no validation that the API call succeeded. The script should check if curl failed and validate that the HTTP status code indicates success before returning 0. Without this validation, DNS update failures may go undetected.
| -w "%{http_code}\n" \ | |
| -o $DATFILE 2>$ERRFILE) | |
| write_log 7 "Beget API curl response: $(cat $DATFILE)" | |
| -w "%{http_code}" \ | |
| -o "$DATFILE" 2>"$ERRFILE") | |
| __CURL_RC=$? | |
| write_log 7 "Beget API curl response: $(cat $DATFILE)" | |
| if [ "$__CURL_RC" -ne 0 ]; then | |
| write_log 3 "Beget API curl request failed with exit code $__CURL_RC" | |
| return 1 | |
| fi | |
| case "$__STATUS" in | |
| 2??) | |
| # HTTP 2xx, consider this a success | |
| ;; | |
| *) | |
| write_log 3 "Beget API returned HTTP error code $__STATUS" | |
| return 1 | |
| ;; | |
| esac |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "beget.com", | ||
| "ipv4": { | ||
| "url": "update_beget_com.sh" | ||
| }, | ||
| "ipv6": { | ||
| "url": "update_beget_com.sh" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line contains inconsistent indentation - it uses spaces instead of tabs. The rest of the Makefile uses tabs for indentation. This line should use a tab character at the beginning to match the surrounding code style.