dns_he_ddns.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env sh
  2. # shellcheck disable=SC2034
  3. dns_he_ddns_info='Hurricane Electric HE.net DDNS
  4. Site: dns.he.net
  5. Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_he_ddns
  6. Options:
  7. HE_DDNS_KEY The DDNS key
  8. Issues: https://github.com/acmesh-official/acme.sh/issues/5238
  9. Author: Markku Leiniö
  10. '
  11. HE_DDNS_URL="https://dyn.dns.he.net/nic/update"
  12. ######## Public functions #####################
  13. #Usage: dns_he_ddns_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
  14. dns_he_ddns_add() {
  15. fulldomain=$1
  16. txtvalue=$2
  17. HE_DDNS_KEY="${HE_DDNS_KEY:-$(_readaccountconf_mutable HE_DDNS_KEY)}"
  18. if [ -z "$HE_DDNS_KEY" ]; then
  19. HE_DDNS_KEY=""
  20. _err "You didn't specify a DDNS key for accessing the TXT record in HE API."
  21. return 1
  22. fi
  23. #Save the DDNS key to the account conf file.
  24. _saveaccountconf_mutable HE_DDNS_KEY "$HE_DDNS_KEY"
  25. _info "Using Hurricane Electric DDNS API"
  26. _debug fulldomain "$fulldomain"
  27. _debug txtvalue "$txtvalue"
  28. response="$(_post "hostname=$fulldomain&password=$HE_DDNS_KEY&txt=$txtvalue" "$HE_DDNS_URL")"
  29. _info "Response: $response"
  30. _contains "$response" "good" && return 0 || return 1
  31. }
  32. # dns_he_ddns_rm() is not doing anything because the API call always updates the
  33. # contents of the existing record (that the API key gives access to).
  34. dns_he_ddns_rm() {
  35. fulldomain=$1
  36. _debug "Delete TXT record called for '${fulldomain}', not doing anything."
  37. return 0
  38. }