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"
10 INTERNETBS_API_URL
="https://api.internet.bs"
12 ######## Public functions #####################
14 #Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
15 dns_internetbs_add
() {
19 if [ -z "$INTERNETBS_API_KEY" ] ||
[ -z "$INTERNETBS_API_PASSWORD" ]; then
21 INTERNETBS_API_PASSWORD
=""
22 _err
"You didn't specify the INTERNET.BS api key and password yet."
23 _err
"Please create you key and try again."
27 _saveaccountconf INTERNETBS_API_KEY
"$INTERNETBS_API_KEY"
28 _saveaccountconf INTERNETBS_API_PASSWORD
"$INTERNETBS_API_PASSWORD"
30 _debug
"First detect the root zone"
31 if ! _get_root
"$fulldomain"; then
36 _debug _sub_domain
"$_sub_domain"
37 _debug _domain
"$_domain"
39 # 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
40 if _internetbs_rest POST
"Domain/DnsRecord/Add" "FullRecordName=${_sub_domain}.${_domain}&Type=TXT&Value=${txtvalue}&ResponseFormat=json"; then
41 if ! _contains
"$response" "\"status\":\"SUCCESS\""; then
42 _err
"ERROR add TXT record"
47 _info
"txt record add success."
54 #Usage: fulldomain txtvalue
55 #Remove the txt record after validation.
60 _debug
"First detect the root zone"
61 if ! _get_root
"$fulldomain"; then
66 _debug _sub_domain
"$_sub_domain"
67 _debug _domain
"$_domain"
69 _debug
"Getting txt records"
70 # https://testapi.internet.bs/Domain/DnsRecord/List?ApiKey=testapi&Password=testpass&Domain=test-api-domain7.net&FilterType=CNAME&ResponseFormat=json
71 _internetbs_rest POST
"Domain/DnsRecord/List" "Domain=$_domain&FilterType=TXT&ResponseFormat=json"
73 if ! _contains
"$response" "\"status\":\"SUCCESS\""; then
74 _err
"ERROR list dns records"
79 if _contains
"$response" "\name\":\"${_sub_domain}.${_domain}\""; then
80 _info
"txt record find."
82 # https://testapi.internet.bs/Domain/DnsRecord/Remove?ApiKey=testapi&Password=testpass&FullRecordName=www.test-api-domain7.net&Type=cname&ResponseFormat=json
83 _internetbs_rest POST
"Domain/DnsRecord/Remove" "FullRecordName=${_sub_domain}.${_domain}&Type=TXT&ResponseFormat=json"
85 if ! _contains
"$response" "\"status\":\"SUCCESS\""; then
86 _err
"ERROR remove dns record"
91 _info
"txt record deleted success."
98 #################### Private functions below ##################################
99 #_acme-challenge.www.domain.com
101 # _sub_domain=_acme-challenge.www
109 # https://testapi.internet.bs/Domain/List?ApiKey=testapi&Password=testpass&CompactList=yes&ResponseFormat=json
110 if _internetbs_rest POST
"Domain/List" "CompactList=yes&ResponseFormat=json"; then
112 if ! _contains
"$response" "\"status\":\"SUCCESS\""; then
113 _err
"ERROR fetch domain list"
119 h
=$
(printf "%s" "$domain" | cut
-d .
-f ${i}-100)
126 if _contains
"$response" "\"$h\""; then
127 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-${p})
139 #Usage: method URI data
144 url
="${INTERNETBS_API_URL}/${ep}"
148 apiKey
="$(printf "%s
" "${INTERNETBS_API_KEY}" | _url_encode)"
149 password
="$(printf "%s
" "${INTERNETBS_API_PASSWORD}" | _url_encode)"
151 if [ "$m" = "GET" ]; then
152 response
="$(_get "${url}?ApiKey=${apiKey}&Password=${password}&${data}" | tr -d '\r')"
155 response
="$(_post "$data" "${url}?ApiKey=${apiKey}&Password=${password}" | tr -d '\r')"
158 if [ "$?" != "0" ]; then
163 _debug2 response
"$response"