3 #This is the Internet.BS api wrapper for acme.sh
5 #Author: <alexey@nelexa.ru> Ne-Lexa
6 #Report Bugs here: https://github.com/Ne-Lexa/acme.sh
8 #INTERNETBS_API_KEY="sdfsdfsdfljlbjkljlkjsdfoiwje"
9 #INTERNETBS_API_PASSWORD="sdfsdfsdfljlbjkljlkjsdfoiwje"
11 INTERNETBS_API_URL
="https://api.internet.bs"
13 ######## Public functions #####################
15 #Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
16 dns_internetbs_add
() {
20 INTERNETBS_API_KEY
="${INTERNETBS_API_KEY:-$(_readaccountconf_mutable INTERNETBS_API_KEY)}"
21 INTERNETBS_API_PASSWORD
="${INTERNETBS_API_PASSWORD:-$(_readaccountconf_mutable INTERNETBS_API_PASSWORD)}"
23 if [ -z "$INTERNETBS_API_KEY" ] ||
[ -z "$INTERNETBS_API_PASSWORD" ]; then
25 INTERNETBS_API_PASSWORD
=""
26 _err
"You didn't specify the INTERNET.BS api key and password yet."
27 _err
"Please create you key and try again."
31 _saveaccountconf_mutable INTERNETBS_API_KEY
"$INTERNETBS_API_KEY"
32 _saveaccountconf_mutable INTERNETBS_API_PASSWORD
"$INTERNETBS_API_PASSWORD"
34 _debug
"First detect the root zone"
35 if ! _get_root
"$fulldomain"; then
40 _debug _sub_domain
"$_sub_domain"
41 _debug _domain
"$_domain"
43 # https://testapi.internet.bs/Domain/DnsRecord/Add?ApiKey=testapi&Password=testpass&FullRecordName=w3.test-api-domain7.net&Type=CNAME&Value=www.internet.bs%&ResponseFormat=json
44 if _internetbs_rest POST
"Domain/DnsRecord/Add" "FullRecordName=${_sub_domain}.${_domain}&Type=TXT&Value=${txtvalue}&ResponseFormat=json"; then
45 if ! _contains
"$response" "\"status\":\"SUCCESS\""; then
46 _err
"ERROR add TXT record"
51 _info
"txt record add success."
58 #Usage: fulldomain txtvalue
59 #Remove the txt record after validation.
64 INTERNETBS_API_KEY
="${INTERNETBS_API_KEY:-$(_readaccountconf_mutable INTERNETBS_API_KEY)}"
65 INTERNETBS_API_PASSWORD
="${INTERNETBS_API_PASSWORD:-$(_readaccountconf_mutable INTERNETBS_API_PASSWORD)}"
67 if [ -z "$INTERNETBS_API_KEY" ] ||
[ -z "$INTERNETBS_API_PASSWORD" ]; then
69 INTERNETBS_API_PASSWORD
=""
70 _err
"You didn't specify the INTERNET.BS api key and password yet."
71 _err
"Please create you key and try again."
75 _debug
"First detect the root zone"
76 if ! _get_root
"$fulldomain"; then
81 _debug _sub_domain
"$_sub_domain"
82 _debug _domain
"$_domain"
84 _debug
"Getting txt records"
85 # https://testapi.internet.bs/Domain/DnsRecord/List?ApiKey=testapi&Password=testpass&Domain=test-api-domain7.net&FilterType=CNAME&ResponseFormat=json
86 _internetbs_rest POST
"Domain/DnsRecord/List" "Domain=$_domain&FilterType=TXT&ResponseFormat=json"
88 if ! _contains
"$response" "\"status\":\"SUCCESS\""; then
89 _err
"ERROR list dns records"
94 if _contains
"$response" "\name\":\"${_sub_domain}.${_domain}\""; then
95 _info
"txt record find."
97 # https://testapi.internet.bs/Domain/DnsRecord/Remove?ApiKey=testapi&Password=testpass&FullRecordName=www.test-api-domain7.net&Type=cname&ResponseFormat=json
98 _internetbs_rest POST
"Domain/DnsRecord/Remove" "FullRecordName=${_sub_domain}.${_domain}&Type=TXT&ResponseFormat=json"
100 if ! _contains
"$response" "\"status\":\"SUCCESS\""; then
101 _err
"ERROR remove dns record"
106 _info
"txt record deleted success."
113 #################### Private functions below ##################################
114 #_acme-challenge.www.domain.com
116 # _sub_domain=_acme-challenge.www
124 # https://testapi.internet.bs/Domain/List?ApiKey=testapi&Password=testpass&CompactList=yes&ResponseFormat=json
125 if _internetbs_rest POST
"Domain/List" "CompactList=yes&ResponseFormat=json"; then
127 if ! _contains
"$response" "\"status\":\"SUCCESS\""; then
128 _err
"ERROR fetch domain list"
134 h
=$
(printf "%s" "$domain" | cut
-d .
-f ${i}-100)
141 if _contains
"$response" "\"$h\""; then
142 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-${p})
154 #Usage: method URI data
159 url
="${INTERNETBS_API_URL}/${ep}"
163 apiKey
="$(printf "%s
" "${INTERNETBS_API_KEY}" | _url_encode)"
164 password
="$(printf "%s
" "${INTERNETBS_API_PASSWORD}" | _url_encode)"
166 if [ "$m" = "GET" ]; then
167 response
="$(_get "${url}?ApiKey=${apiKey}&Password=${password}&${data}" | tr -d '\r')"
170 response
="$(_post "$data" "${url}?ApiKey=${apiKey}&Password=${password}" | tr -d '\r')"
173 if [ "$?" != "0" ]; then
178 _debug2 response
"$response"