|
@ -9,7 +9,7 @@ Issues: github.com/acmesh-official/acme.sh/issues/3998 |
|
|
Author: Timur Umarov <inbox@tumarov.com> |
|
|
Author: Timur Umarov <inbox@tumarov.com> |
|
|
' |
|
|
' |
|
|
|
|
|
|
|
|
FORNEX_API_URL="https://fornex.com/api/dns/v0.1" |
|
|
|
|
|
|
|
|
FORNEX_API_URL="https://fornex.com/api" |
|
|
|
|
|
|
|
|
######## Public functions ##################### |
|
|
######## Public functions ##################### |
|
|
|
|
|
|
|
@ -30,12 +30,10 @@ dns_fornex_add() { |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
_info "Adding record" |
|
|
_info "Adding record" |
|
|
if _rest POST "$_domain/entry_set/add/" "host=$fulldomain&type=TXT&value=$txtvalue&apikey=$FORNEX_API_KEY"; then |
|
|
|
|
|
|
|
|
if _rest POST "dns/domain/$_domain/entry_set/" "{\"host\" : \"${fulldomain}\" , \"type\" : \"TXT\" , \"value\" : \"${txtvalue}\" , \"ttl\" : null}"; then |
|
|
_debug _response "$response" |
|
|
_debug _response "$response" |
|
|
if _contains "$response" '"ok": true' || _contains "$response" 'Такая запись уже существует.'; then |
|
|
|
|
|
_info "Added, OK" |
|
|
|
|
|
return 0 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
_info "Added, OK" |
|
|
|
|
|
return 0 |
|
|
fi |
|
|
fi |
|
|
_err "Add txt record error." |
|
|
_err "Add txt record error." |
|
|
return 1 |
|
|
return 1 |
|
@ -58,21 +56,21 @@ dns_fornex_rm() { |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
_debug "Getting txt records" |
|
|
_debug "Getting txt records" |
|
|
_rest GET "$_domain/entry_set.json?apikey=$FORNEX_API_KEY" |
|
|
|
|
|
|
|
|
_rest GET "dns/domain/$_domain/entry_set?type=TXT&q=$fulldomain" |
|
|
|
|
|
|
|
|
if ! _contains "$response" "$txtvalue"; then |
|
|
if ! _contains "$response" "$txtvalue"; then |
|
|
_err "Txt record not found" |
|
|
_err "Txt record not found" |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
_record_id="$(echo "$response" | _egrep_o "{[^{]*\"value\"*:*\"$txtvalue\"[^}]*}" | sed -n -e 's#.*"id": \([0-9]*\).*#\1#p')" |
|
|
|
|
|
|
|
|
_record_id="$(echo "$response" | _egrep_o "\{[^\{]*\"value\"*:*\"$txtvalue\"[^\}]*\}" | sed -n -e 's#.*"id":\([0-9]*\).*#\1#p')" |
|
|
_debug "_record_id" "$_record_id" |
|
|
_debug "_record_id" "$_record_id" |
|
|
if [ -z "$_record_id" ]; then |
|
|
if [ -z "$_record_id" ]; then |
|
|
_err "can not find _record_id" |
|
|
_err "can not find _record_id" |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if ! _rest POST "$_domain/entry_set/$_record_id/delete/" "apikey=$FORNEX_API_KEY"; then |
|
|
|
|
|
|
|
|
if ! _rest DELETE "dns/domain/$_domain/entry_set/$_record_id/"; then |
|
|
_err "Delete record error." |
|
|
_err "Delete record error." |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
@ -90,18 +88,18 @@ _get_root() { |
|
|
|
|
|
|
|
|
i=1 |
|
|
i=1 |
|
|
while true; do |
|
|
while true; do |
|
|
h=$(printf "%s" "$domain" | cut -d . -f "$i"-100) |
|
|
|
|
|
|
|
|
h=$(printf "%s" "$domain" | cut -d . -f $i-100) |
|
|
_debug h "$h" |
|
|
_debug h "$h" |
|
|
if [ -z "$h" ]; then |
|
|
if [ -z "$h" ]; then |
|
|
#not valid |
|
|
#not valid |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if ! _rest GET "domain_list.json?q=$h&apikey=$FORNEX_API_KEY"; then |
|
|
|
|
|
|
|
|
if ! _rest GET "dns/domain/"; then |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if _contains "$response" "\"$h\"" >/dev/null; then |
|
|
|
|
|
|
|
|
if _contains "$response" "\"name\":\"$h\"" >/dev/null; then |
|
|
_domain=$h |
|
|
_domain=$h |
|
|
return 0 |
|
|
return 0 |
|
|
else |
|
|
else |
|
@ -134,7 +132,9 @@ _rest() { |
|
|
data="$3" |
|
|
data="$3" |
|
|
_debug "$ep" |
|
|
_debug "$ep" |
|
|
|
|
|
|
|
|
export _H1="Accept: application/json" |
|
|
|
|
|
|
|
|
export _H1="Authorization: Api-Key $FORNEX_API_KEY" |
|
|
|
|
|
export _H2="Content-Type: application/json" |
|
|
|
|
|
export _H3="Accept: application/json" |
|
|
|
|
|
|
|
|
if [ "$m" != "GET" ]; then |
|
|
if [ "$m" != "GET" ]; then |
|
|
_debug data "$data" |
|
|
_debug data "$data" |
|
|