-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add Gname.com dnsapi support #6808
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: dev
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,276 @@ | ||||||||||
| #!/usr/bin/env sh | ||||||||||
| # shellcheck disable=SC2034 | ||||||||||
| dns_gname_info='GNAME | ||||||||||
| Site: gname.com | ||||||||||
| Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi#dns_gname | ||||||||||
| Options: | ||||||||||
| GNAME_APPID Your APPID | ||||||||||
| GNAME_APPKEY Your APPKEY | ||||||||||
| OptionsAlt: | ||||||||||
| ' | ||||||||||
|
|
||||||||||
| GNAME_TLD_Api="https://gname.com/request/tlds?lx=all" | ||||||||||
| GNAME_Api="https://api.gname.com" | ||||||||||
| GNAME_TLDS_CACHE="" | ||||||||||
|
|
||||||||||
| ######## Public functions ##################### | ||||||||||
|
|
||||||||||
| #Usage: add _acme-challenge.www.domain.com "T1rxqRBosdIK90xWCG3KLZNf6q_0HG9i01zxXp5CAS3" | ||||||||||
| dns_gname_add() { | ||||||||||
| fulldomain=$1 | ||||||||||
| txtvalue=$(printf "%s" "$2" | _url_encode) | ||||||||||
|
|
||||||||||
| GNAME_APPID="${GNAME_APPID:-$(_readaccountconf_mutable GNAME_APPID)}" | ||||||||||
| GNAME_APPKEY="${GNAME_APPKEY:-$(_readaccountconf_mutable GNAME_APPKEY)}" | ||||||||||
|
|
||||||||||
| if [ -z "$GNAME_APPID" ] || [ -z "$GNAME_APPKEY" ]; then | ||||||||||
| GNAME_APPID="" | ||||||||||
| GNAME_APPKEY="" | ||||||||||
| _err "You have not configured the APPID and APPKEY for the GNAME API." | ||||||||||
| _err "You can get yours from here http://gname.com/domain/api." | ||||||||||
| return 1 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| _saveaccountconf_mutable GNAME_APPID "$GNAME_APPID" | ||||||||||
| _saveaccountconf_mutable GNAME_APPKEY "$GNAME_APPKEY" | ||||||||||
|
|
||||||||||
| if ! _extract_domain "$fulldomain"; then | ||||||||||
| _err "Failed to extract domain. Please check your network or API response." | ||||||||||
| return 1 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| gntime=$(date +%s) | ||||||||||
|
|
||||||||||
| #If the hostname is empty, you need to replace it with @. | ||||||||||
| final_hostname=$(printf "%s" "${ext_hostname:-@}" | _url_encode) | ||||||||||
|
|
||||||||||
| # Parameters need to be sorted by key | ||||||||||
| body="appid=$GNAME_APPID&gntime=$gntime&jlz=$txtvalue&lang=us&lx=TXT&mx=0&ttl=600&xl=0&ym=$ext_domain&zj=$final_hostname" | ||||||||||
|
|
||||||||||
| _info "Adding TXT record for $ext_domain, host: $final_hostname" | ||||||||||
|
|
||||||||||
| if _post_to_api "/api/resolution/add" "$body"; then | ||||||||||
| _info "Successfully added DNS record." | ||||||||||
| return 0 | ||||||||||
| else | ||||||||||
| if _contains "$post_response" "the same host records and record values"; then | ||||||||||
| _info "Successfully DNS record already exists." | ||||||||||
| return 0 | ||||||||||
| fi | ||||||||||
| _err "Failed to add DNS record via Gname API." | ||||||||||
| return 1 | ||||||||||
|
Comment on lines
+56
to
+61
|
||||||||||
| fi | ||||||||||
| } | ||||||||||
|
|
||||||||||
| #Usage: remove _acme-challenge.www.domain.com "T1rxqRBosdIK90xWCG3KLZNf6q_0HG9i01zxXp5CASc" | ||||||||||
| dns_gname_rm() { | ||||||||||
| fulldomain=$1 | ||||||||||
| txtvalue=$2 | ||||||||||
|
|
||||||||||
| GNAME_APPID="${GNAME_APPID:-$(_readaccountconf_mutable GNAME_APPID)}" | ||||||||||
| GNAME_APPKEY="${GNAME_APPKEY:-$(_readaccountconf_mutable GNAME_APPKEY)}" | ||||||||||
|
|
||||||||||
| if [ -z "$GNAME_APPID" ] || [ -z "$GNAME_APPKEY" ]; then | ||||||||||
| GNAME_APPID="" | ||||||||||
| GNAME_APPKEY="" | ||||||||||
| _err "You have not configured the APPID and APPKEY for the GNAME API." | ||||||||||
| _err "You can get yours from here http://gname.com/domain/api." | ||||||||||
|
||||||||||
| _err "You can get yours from here http://gname.com/domain/api." | |
| _err "You can get yours from here https://gname.com/domain/api." |
Copilot
AI
Mar 2, 2026
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.
dns_gname_rm returns an error when no matching record is found. DNS-API rm handlers are typically expected to be idempotent (i.e., treat “already removed” as success) to avoid failing renewals/cleanup flows. Consider changing this branch to log an informational message (e.g., “Don't need to remove”) and return 0.
| _err "No DNS record found" | |
| return 1 | |
| _info "No DNS record found, nothing to remove" | |
| return 0 |
Copilot
AI
Mar 2, 2026
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.
_get_record_id uses grep with a basic-regex pattern that interpolates target_zjt directly. Hostnames like _acme-challenge.www contain dots, which will be treated as regex wildcards and can match unintended rows, potentially deleting the wrong record. Use fixed-string matching (e.g., grep -F) or escape the hostname/value before searching.
| matched_row=$(echo "$records" | grep -i "\"zjt\":\"$target_zjt\"" | grep "\"jxz\":\"$jxz_feature") | |
| matched_row=$(echo "$records" | grep -Fi "\"zjt\":\"$target_zjt\"" | grep -F "\"jxz\":\"$jxz_feature") |
Copilot
AI
Mar 2, 2026
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.
_extract_domain does not handle inputs with no dots (e.g., an invalid/trimmed fulldomain). In that case none of the branches set ext_domain, but the function still falls through and returns success, which can lead to API calls with an empty ym. Add an explicit validation/else branch that errors and returns 1 when dot_count is 0 (or when ext_domain ends up empty).
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 credential-help URL in the error message uses
http://. Since the API documentation is available over HTTPS (and the PR description references HTTPS), prefer anhttps://link to avoid encouraging insecure browsing.