Skip to content

Commit 5d6f1bd

Browse files
authored
Merge pull request #6110 from acmesh-official/dev
sync
2 parents 75b4bb3 + 48ccaa8 commit 5d6f1bd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

dnsapi/dns_fornex.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Issues: github.com/acmesh-official/acme.sh/issues/3998
99
Author: Timur Umarov <[email protected]>
1010
'
1111

12-
FORNEX_API_URL="https://fornex.com/api/dns/v0.1"
12+
FORNEX_API_URL="https://fornex.com/api"
1313

1414
######## Public functions #####################
1515

@@ -30,12 +30,10 @@ dns_fornex_add() {
3030
fi
3131

3232
_info "Adding record"
33-
if _rest POST "$_domain/entry_set/add/" "host=$fulldomain&type=TXT&value=$txtvalue&apikey=$FORNEX_API_KEY"; then
33+
if _rest POST "dns/domain/$_domain/entry_set/" "{\"host\" : \"${fulldomain}\" , \"type\" : \"TXT\" , \"value\" : \"${txtvalue}\" , \"ttl\" : null}"; then
3434
_debug _response "$response"
35-
if _contains "$response" '"ok": true' || _contains "$response" 'Такая запись уже существует.'; then
36-
_info "Added, OK"
37-
return 0
38-
fi
35+
_info "Added, OK"
36+
return 0
3937
fi
4038
_err "Add txt record error."
4139
return 1
@@ -58,21 +56,21 @@ dns_fornex_rm() {
5856
fi
5957

6058
_debug "Getting txt records"
61-
_rest GET "$_domain/entry_set.json?apikey=$FORNEX_API_KEY"
59+
_rest GET "dns/domain/$_domain/entry_set?type=TXT&q=$fulldomain"
6260

6361
if ! _contains "$response" "$txtvalue"; then
6462
_err "Txt record not found"
6563
return 1
6664
fi
6765

68-
_record_id="$(echo "$response" | _egrep_o "{[^{]*\"value\"*:*\"$txtvalue\"[^}]*}" | sed -n -e 's#.*"id": \([0-9]*\).*#\1#p')"
66+
_record_id="$(echo "$response" | _egrep_o "\{[^\{]*\"value\"*:*\"$txtvalue\"[^\}]*\}" | sed -n -e 's#.*"id":\([0-9]*\).*#\1#p')"
6967
_debug "_record_id" "$_record_id"
7068
if [ -z "$_record_id" ]; then
7169
_err "can not find _record_id"
7270
return 1
7371
fi
7472

75-
if ! _rest POST "$_domain/entry_set/$_record_id/delete/" "apikey=$FORNEX_API_KEY"; then
73+
if ! _rest DELETE "dns/domain/$_domain/entry_set/$_record_id/"; then
7674
_err "Delete record error."
7775
return 1
7876
fi
@@ -90,18 +88,18 @@ _get_root() {
9088

9189
i=1
9290
while true; do
93-
h=$(printf "%s" "$domain" | cut -d . -f "$i"-100)
91+
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
9492
_debug h "$h"
9593
if [ -z "$h" ]; then
9694
#not valid
9795
return 1
9896
fi
9997

100-
if ! _rest GET "domain_list.json?q=$h&apikey=$FORNEX_API_KEY"; then
98+
if ! _rest GET "dns/domain/"; then
10199
return 1
102100
fi
103101

104-
if _contains "$response" "\"$h\"" >/dev/null; then
102+
if _contains "$response" "\"name\":\"$h\"" >/dev/null; then
105103
_domain=$h
106104
return 0
107105
else
@@ -134,7 +132,9 @@ _rest() {
134132
data="$3"
135133
_debug "$ep"
136134

137-
export _H1="Accept: application/json"
135+
export _H1="Authorization: Api-Key $FORNEX_API_KEY"
136+
export _H2="Content-Type: application/json"
137+
export _H3="Accept: application/json"
138138

139139
if [ "$m" != "GET" ]; then
140140
_debug data "$data"

0 commit comments

Comments
 (0)