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 KAPPERNETDNS_Key
="${KAPPERNETDNS_Key:-$(_readaccountconf_mutable KAPPERNETDNS_Key)}"
21 KAPPERNETDNS_Secret
="${KAPPERNETDNS_Secret:-$(_readaccountconf_mutable KAPPERNETDNS_Secret)}"
23 if [ -z "$KAPPERNETDNS_Key" ] ||
[ -z "$KAPPERNETDNS_Secret" ]; then
25 KAPPERNETDNS_Secret
=""
26 _err
"Please specify your kapper.net api key and secret."
27 _err
"If you have not received yours - send your mail to"
28 _err
"support@kapper.net to get your key and secret."
32 #store the api key and email to the account conf file.
33 _saveaccountconf_mutable KAPPERNETDNS_Key
"$KAPPERNETDNS_Key"
34 _saveaccountconf_mutable KAPPERNETDNS_Secret
"$KAPPERNETDNS_Secret"
35 _debug
"Checking Domain ..."
36 if ! _get_root
"$fullhostname"; then
40 _debug _sub_domain
"SUBDOMAIN: $_sub_domain"
41 _debug _domain
"DOMAIN: $_domain"
43 _info
"Trying to add TXT DNS Record"
44 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"
45 if _kappernet_api GET
"action=new&subject=$_domain&data=$data"; then
47 if _contains
"$response" "{\"OK\":true"; then
48 _info
"Waiting 1 second for DNS to spread the new record"
52 _err
"Error creating a TXT DNS Record: $fullhostname TXT $txtvalue"
53 _err
"Error Message: $response"
57 _err
"Failed creating TXT Record"
60 ###############################################################################
62 # fullhostname: something.example.com
67 KAPPERNETDNS_Key
="${KAPPERNETDNS_Key:-$(_readaccountconf_mutable KAPPERNETDNS_Key)}"
68 KAPPERNETDNS_Secret
="${KAPPERNETDNS_Secret:-$(_readaccountconf_mutable KAPPERNETDNS_Secret)}"
70 if [ -z "$KAPPERNETDNS_Key" ] ||
[ -z "$KAPPERNETDNS_Secret" ]; then
72 KAPPERNETDNS_Secret
=""
73 _err
"Please specify your kapper.net api key and secret."
74 _err
"If you have not received yours - send your mail to"
75 _err
"support@kapper.net to get your key and secret."
79 #store the api key and email to the account conf file.
80 _saveaccountconf_mutable KAPPERNETDNS_Key
"$KAPPERNETDNS_Key"
81 _saveaccountconf_mutable KAPPERNETDNS_Secret
"$KAPPERNETDNS_Secret"
83 _info
"Trying to remove the TXT Record: $fullhostname containing $txtvalue"
84 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"
85 if _kappernet_api GET
"action=del&subject=$fullhostname&data=$data"; then
86 if _contains
"$response" "{\"OK\":true"; then
89 _err
"Error deleting DNS Record: $fullhostname containing $txtvalue"
90 _err
"Problem: $response"
94 _err
"Problem deleting TXT DNS record"
97 #################### Private functions below ##################################
98 # called with hostname
99 # e.g._acme-challenge.www.domain.com returns
100 # _sub_domain=_acme-challenge.www
107 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
112 if ! _kappernet_api GET
"action=list&subject=$h"; then
115 if _contains
"$response" '"OK":false'; then
116 _debug
"$h not found"
118 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
128 ################################################################################
129 # calls the kapper.net DNS Panel API
137 _debug param
"PARAMETER=$param"
138 url
="$KAPPERNETDNS_Api&$param"
139 _debug url
"URL=$url"
141 if [ "$method" = "GET" ]; then
142 response
="$(_get "$url")"
144 _err
"Unsupported method"
148 _debug2 response
"$response"