3 # kapper.net domain api
4 # for further questions please contact: support@kapper.net
5 # please report issues here: https://github.com/acmesh-official/acme.sh/issues/2977
7 #KAPPERNETDNS_Key="yourKAPPERNETapikey"
8 #KAPPERNETDNS_Secret="yourKAPPERNETapisecret"
10 KAPPERNETDNS_Api
="https://dnspanel.kapper.net/API/1.2?APIKey=$KAPPERNETDNS_Key&APISecret=$KAPPERNETDNS_Secret"
12 ###############################################################################
14 # fullhostname: something.example.com
15 # txtvalue: someacmegenerated string
20 if [ -z "$KAPPERNETDNS_Key" ] ||
[ -z "$KAPPERNETDNS_Secret" ]; then
22 KAPPERNETDNS_Secret
=""
23 _err
"You haven't defined kapper.net api key and secret yet."
24 _err
"Please send us mail to support@kapper.net get your key and secret."
28 #store the api key and email to the account conf file.
29 _saveaccountconf_mutable KAPPERNETDNS_Key
"$KAPPERNETDNS_Key"
30 _saveaccountconf_mutable KAPPERNETDNS_Secret
"$KAPPERNETDNS_Secret"
31 _debug
"Checking Domain ..."
32 if ! _get_root
"$fullhostname"; then
36 _debug _sub_domain
"SUBDOMAIN: $_sub_domain"
37 _debug _domain
"DOMAIN: $_domain"
39 _info
"Trying to add TXT DNS Record"
40 data
="%7B%22name%22%3A%22$fullhostname%22%2C%22type%22%3A%22TXT%22%2C%22content%22%3A%22$txtvalue%22%2C%22ttl%22%3A%223600%22%2C%22prio%22%3A%22%22%7D"
41 if _kappernet_api GET
"action=new&subject=$_domain&data=$data"; then
43 if _contains
"$response" "{\"OK\":true"; then
44 _info
"Waiting 120 seconds for DNS to spread the new record"
48 _err
"Error creating a TXT DNS Record: $fullhostname TXT $txtvalue"
49 _err
"Error Message: $response"
53 _err
"Failed creating TXT Record"
56 ###############################################################################
58 # fullhostname: something.example.com
63 if [ -z "$KAPPERNETDNS_Key" ] ||
[ -z "$KAPPERNETDNS_Secret" ]; then
65 KAPPERNETDNS_Secret
=""
66 _err
"You haven't defined kapper.net api key and secret yet."
67 _err
"Please send us mail to get your key and secret."
71 #store the api key and email to the account conf file.
72 _saveaccountconf_mutable KAPPERNETDNS_Key
"$KAPPERNETDNS_Key"
73 _saveaccountconf_mutable KAPPERNETDNS_Secret
"$KAPPERNETDNS_Secret"
75 _info
"Trying to remove the TXT Record: $fullhostname"
76 data
="%7B%22name%22%3A%22$fullhostname%22%2C%22type%22%3A%22TXT%22%2C%22content%22%3A%22$txtvalue%22%2C%22ttl%22%3A%223600%22%2C%22prio%22%3A%22%22%7D"
77 if _kappernet_api GET
"action=del&subject=$fullhostname&data=$data"; then
78 if _contains
"$response" "{\"OK\":true"; then
81 _err
"Error deleting DNS Record: $fullhostname"
82 _err
"Problem: $response"
86 _err
"Problem creating TXT DNS record"
89 #################### Private functions below ##################################
90 # called with hostname
91 # e.g._acme-challenge.www.domain.com returns
92 # _sub_domain=_acme-challenge.www
99 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
104 if ! _kappernet_api GET
"action=list&subject=$h"; then
107 if _contains
"$response" '"OK":false'; then
108 _debug
"$h not found"
110 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
120 ################################################################################
121 # calls the kapper.net DNS Panel API
129 _debug param
"PARAMETER=$param"
130 url
="$KAPPERNETDNS_Api&$param"
131 _debug url
"URL=$url"
133 if [ "$method" = "GET" ]; then
134 response
="$(_get "$url")"
136 _err
"Unsupported method"
140 _debug2 response
"$response"