Skip to content

Commit

Permalink
Merge pull request #6184 from JazzMalar/master
Browse files Browse the repository at this point in the history
Update dns_cyon plugin
  • Loading branch information
Neilpang authored Jan 4, 2025
2 parents fd3f668 + 1b12305 commit 65239c7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions dnsapi/dns_cyon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,8 @@ _cyon_change_domain_env() {

if ! _cyon_check_if_2fa_missed "${domain_env_response}"; then return 1; fi

domain_env_success="$(printf "%s" "${domain_env_response}" | _egrep_o '"authenticated":\w*' | cut -d : -f 2)"

# Bail if domain environment change fails.
if [ "${domain_env_success}" != "true" ]; then
if [ "$(printf "%s" "${domain_env_response}" | _cyon_get_environment_change_status)" != "true" ]; then
_err " $(printf "%s" "${domain_env_response}" | _cyon_get_response_message)"
_err ""
return 1
Expand All @@ -232,7 +230,7 @@ _cyon_add_txt() {
_info " - Adding DNS TXT entry..."

add_txt_url="https://my.cyon.ch/domain/dnseditor/add-record-async"
add_txt_data="zone=${fulldomain_idn}.&ttl=900&type=TXT&value=${txtvalue}"
add_txt_data="name=${fulldomain_idn}.&ttl=900&type=TXT&dnscontent=${txtvalue}"

add_txt_response="$(_post "$add_txt_data" "$add_txt_url")"
_debug add_txt_response "${add_txt_response}"
Expand All @@ -241,9 +239,10 @@ _cyon_add_txt() {

add_txt_message="$(printf "%s" "${add_txt_response}" | _cyon_get_response_message)"
add_txt_status="$(printf "%s" "${add_txt_response}" | _cyon_get_response_status)"
add_txt_validation="$(printf "%s" "${add_txt_response}" | _cyon_get_validation_status)"

# Bail if adding TXT entry fails.
if [ "${add_txt_status}" != "true" ]; then
if [ "${add_txt_status}" != "true" ] || [ "${add_txt_validation}" != "true" ]; then
_err " ${add_txt_message}"
_err ""
return 1
Expand Down Expand Up @@ -305,13 +304,21 @@ _cyon_get_response_message() {
}

_cyon_get_response_status() {
_egrep_o '"status":\w*' | cut -d : -f 2
_egrep_o '"status":[a-zA-z0-9]*' | cut -d : -f 2
}

_cyon_get_validation_status() {
_egrep_o '"valid":[a-zA-z0-9]*' | cut -d : -f 2
}

_cyon_get_response_success() {
_egrep_o '"onSuccess":"[^"]*"' | cut -d : -f 2 | tr -d '"'
}

_cyon_get_environment_change_status() {
_egrep_o '"authenticated":[a-zA-z0-9]*' | cut -d : -f 2
}

_cyon_check_if_2fa_missed() {
# Did we miss the 2FA?
if test "${1#*multi_factor_form}" != "${1}"; then
Expand Down

0 comments on commit 65239c7

Please sign in to comment.