3 #Arvan_Token="Apikey xxxx"
5 ARVAN_API_URL
="https://napi.arvancloud.com/cdn/4.0/domains"
7 #Report Bugs here: https://github.com/Neilpang/acme.sh
9 ######## Public functions #####################
11 #Usage: dns_arvan_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
17 Arvan_Token
="${Arvan_Token:-$(_readaccountconf_mutable Arvan_Token)}"
19 if [ -z "$Arvan_Token" ]; then
20 _err
"You didn't specify \"Arvan_Token\" token yet."
21 _err
"You can get yours from here https://npanel.arvancloud.com/profile/api-keys"
24 #save the api token to the account conf file.
25 _saveaccountconf_mutable Arvan_Token
"$Arvan_Token"
27 _debug
"First detect the root zone"
28 if ! _get_root
"$fulldomain"; then
33 _debug _domain_id
"$_domain_id"
34 _debug _sub_domain
"$_sub_domain"
35 _debug _domain
"$_domain"
38 if _arvan_rest POST
"$_domain/dns-records" "{\"type\":\"TXT\",\"name\":\"$_sub_domain\",\"value\":{\"text\":\"$txtvalue\"},\"ttl\":120}"; then
39 if _contains
"$response" "$txtvalue"; then
40 _info
"response id is $response"
43 elif _contains
"$response" "Record Data is Duplicated"; then
44 _info
"Already exists, OK"
47 _err
"Add txt record error."
51 _err
"Add txt record error."
55 #Usage: fulldomain txtvalue
56 #Remove the txt record after validation.
61 _debug fulldomain
"$fulldomain"
62 _debug txtvalue
"$txtvalue"
64 Arvan_Token
="${Arvan_Token:-$(_readaccountconf_mutable Arvan_Token)}"
66 _debug
"First detect the root zone"
67 if ! _get_root
"$fulldomain"; then
71 _debug _domain_id
"$_domain_id"
72 _debug _sub_domain
"$_sub_domain"
73 _debug _domain
"$_domain"
75 _debug
"Getting txt records"
76 _arvan_rest GET
"${_domain}/dns-records"
77 if ! printf "%s" "$response" |
grep \"current_page
\":1 >/dev
/null
; then
78 _err
"Error on Arvan Api"
79 _err
"Please create a github issue with debbug log"
83 _record_id
=$
(echo "$response" | _egrep_o
".\"id\":\"[^\"]*\",\"type\":\"txt\",\"name\":\"_acme-challenge\",\"value\":{\"text\":\"$txtvalue\"}" | cut
-d : -f 2 | cut
-d , -f 1 |
tr -d \")
84 if ! _arvan_rest
"DELETE" "${_domain}/dns-records/${_record_id}"; then
85 _err
"Error on Arvan Api"
89 _contains
"$response" 'dns record deleted'
93 #################### Private functions below ##################################
95 #_acme-challenge.www.domain.com
97 # _sub_domain=_acme-challenge.www
99 # _domain_id=sdjkglgdfewsdfg
105 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
112 if ! _arvan_rest GET
"$h"; then
115 if _contains
"$response" "\"domain\":\"$h\""; then
116 _domain_id
=$
(echo "$response" | cut
-d : -f 3 | cut
-d , -f 1 |
tr -d \")
117 if [ "$_domain_id" ]; then
118 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
135 token_trimmed
=$
(echo "$Arvan_Token" |
tr -d '"')
136 export _H1
="Authorization: $token_trimmed"
138 if [ "$mtd" = "DELETE" ]; then
139 #DELETE Request shouldn't have Content-Type
141 response
="$(_post "$data" "$ARVAN_API_URL/$ep" "" "$mtd")"
142 elif [ "$mtd" = "POST" ]; then
143 export _H2
="Content-Type: application/json"
145 response
="$(_post "$data" "$ARVAN_API_URL/$ep" "" "$mtd")"
147 response
="$(_get "$ARVAN_API_URL/$ep$data")"