mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-05-05 19:27:41 +00:00
complete overhaul (after github actions mess)
This commit is contained in:
parent
233d821471
commit
26edfc2928
@ -15,17 +15,16 @@
|
||||
# Previous update by Marc-Oliver Lange <git@die-lang.es>
|
||||
# KASAPI SOAP guideline by https://github.com/o1oo11oo/kasapi.sh
|
||||
########################################################################
|
||||
# KAS_Api_GET="$(_get "https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl")"
|
||||
# KAS_Api="$(echo "$KAS_Api_GET" | tr -d ' ' | grep -i "<soap:addresslocation=" | sed "s/='/\n/g" | grep -i "http" | sed "s/'\/>//g")"
|
||||
KAS_Api='https://kasapi.kasserver.com/soap/KasApi.php'
|
||||
KAS_Api_GET="$(_get "https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl")"
|
||||
KAS_Api="$(echo "$KAS_Api_GET" | tr -d ' ' | grep -i "<soap:addresslocation=" | sed "s/='/\n/g" | grep -i "http" | sed "s/'\/>//g")"
|
||||
_info "##KAS## Using $KAS_Api"
|
||||
KAS_default_ratelimit=5
|
||||
KAS_default_ratelimit=5 # TODO - Every response delivers a ratelimit (seconds) where KASAPI is blocking a request.
|
||||
######## Public functions #####################
|
||||
dns_kas_add() {
|
||||
_fulldomain=$1
|
||||
_txtvalue=$2
|
||||
_info "##KAS## ##KAS## Using DNS-01 All-inkl/Kasserver hook"
|
||||
_info "##KAS## ##KAS## Adding $_fulldomain DNS TXT entry on All-inkl/Kasserver"
|
||||
_info "##KAS## Using DNS-01 All-inkl/Kasserver hook"
|
||||
_info "##KAS## Adding $_fulldomain DNS TXT entry on All-inkl/Kasserver"
|
||||
_info "##KAS## Check and Save Props"
|
||||
_check_and_save
|
||||
_info "##KAS## Checking Zone and Record_Name"
|
||||
@ -35,41 +34,28 @@ dns_kas_add() {
|
||||
|
||||
_info "##KAS## Creating TXT DNS record"
|
||||
|
||||
export _H1="SOAPAction: \"urn:xmethodsKasApi#KasApi\""
|
||||
|
||||
params_auth="\"kas_login\":\"$KAS_Login\""
|
||||
params_auth="$params_auth,\"kas_auth_type\":\"$KAS_Authtype\""
|
||||
params_auth="$params_auth,\"kas_auth_data\":\"$KAS_Authdata\""
|
||||
|
||||
params_request="\"record_name\":\"$_record_name\""
|
||||
params_request="$params_request,\"record_type\":\"TXT\""
|
||||
params_request="$params_request,\"record_data\":\"$_txtvalue\""
|
||||
params_request="$params_request,\"record_aux\":\"0\""
|
||||
params_request="$params_request,\"zone_host\":\"$_zone\""
|
||||
|
||||
params='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
||||
params="$params$params_auth,\"kas_action\":\"add_dns_settings\""
|
||||
params="$params,\"KasRequestParams\":{$params_request}"
|
||||
params="$params}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
||||
response="$(_post_soap "add_dns_settings" "$params_request")"
|
||||
|
||||
_debug2 "##KAS## ##KAS## Wait for $KAS_default_ratelimit seconds by default before calling KAS API."
|
||||
_sleep $KAS_default_ratelimit
|
||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
||||
_debug2 "##KAS## response" "$response"
|
||||
if [ -z "$response" ]; then
|
||||
_info "##KAS## Response was empty, 2nd attempt"
|
||||
_sleep $KAS_default_ratelimit
|
||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
||||
_debug2 "##KAS## retry response" "$response"
|
||||
fi
|
||||
|
||||
if _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||
if _contains "$response" "record_already_exists"; then
|
||||
_info "##KAS## The record already exists, which must not be a problem. Please check manually."
|
||||
else
|
||||
_err "##KAS## An error occurred, please check manually."
|
||||
return 1
|
||||
fi
|
||||
_info "##KAS## Response was empty, please check manually."
|
||||
return 1
|
||||
elif _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||
faultstring="$(echo "$response" | tr -d '\n\r' | sed "s/<faultstring>/\n=> /g" | sed "s/<\/faultstring>/\n/g" | grep "=>" | sed "s/=> //g")"
|
||||
case "$faultstring" in
|
||||
"record_already_exists")
|
||||
_info "##KAS## The record already exists, which must not be a problem. Please check manually."
|
||||
;;
|
||||
*)
|
||||
_err "##KAS## An error =>$faultstring<= occurred, please check manually."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
elif ! _contains "$response" "<item><key xsi:type=\"xsd:string\">ReturnString</key><value xsi:type=\"xsd:string\">TRUE</value></item>"; then
|
||||
_err "##KAS## An unknown error occurred, please check manually."
|
||||
return 1
|
||||
@ -83,7 +69,6 @@ dns_kas_rm() {
|
||||
_info "##KAS## Using DNS-01 All-inkl/Kasserver hook"
|
||||
_info "##KAS## Cleaning up after All-inkl/Kasserver hook"
|
||||
_info "##KAS## Removing $_fulldomain DNS TXT entry on All-inkl/Kasserver"
|
||||
|
||||
_info "##KAS## Check and Save Props"
|
||||
_check_and_save
|
||||
_info "##KAS## Checking Zone and Record_Name"
|
||||
@ -91,44 +76,34 @@ dns_kas_rm() {
|
||||
_info "##KAS## Getting Record ID"
|
||||
_get_record_id
|
||||
|
||||
# If there is a record_id, delete the entry
|
||||
if [ -n "$_record_id" ]; then
|
||||
export _H1="SOAPAction: \"urn:xmethodsKasApi#KasApi\""
|
||||
|
||||
params_auth="\"kas_login\":\"$KAS_Login\""
|
||||
params_auth="$params_auth,\"kas_auth_type\":\"$KAS_Authtype\""
|
||||
params_auth="$params_auth,\"kas_auth_data\":\"$KAS_Authdata\""
|
||||
|
||||
params_request="\"record_id\":\"RECORDID\""
|
||||
|
||||
params='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
||||
params="$params$params_auth,\"kas_action\":\"delete_dns_settings\""
|
||||
params="$params,\"KasRequestParams\":{$params_request}"
|
||||
params="$params}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
||||
|
||||
for i in $_record_id; do
|
||||
params2="$(echo $params | sed "s/RECORDID/$i/g")"
|
||||
_debug2 "##KAS## Wait for $KAS_default_ratelimit seconds by default before calling KAS API."
|
||||
_sleep $KAS_default_ratelimit
|
||||
response="$(_post "$params2" "$KAS_Api" "" "POST" "text/xml")"
|
||||
_debug2 "##KAS## response" "$response"
|
||||
_info "##KAS## Removing $_record_id"
|
||||
params_request="\"record_id\":\"$_record_id\""
|
||||
|
||||
response="$(_post_soap "delete_dns_settings" "$params_request")"
|
||||
|
||||
if [ -z "$response" ]; then
|
||||
_info "##KAS## Response was empty, 2nd attempt"
|
||||
_sleep $KAS_default_ratelimit
|
||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
||||
_debug2 "##KAS## retry response" "$response"
|
||||
fi
|
||||
if _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||
_err "##KAS## Either the txt record was not found or another error occurred, please check manually."
|
||||
_info "##KAS## Response was empty, please check manually."
|
||||
return 1
|
||||
elif _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||
faultstring="$(echo "$response" | tr -d '\n\r' | sed "s/<faultstring>/\n=> /g" | sed "s/<\/faultstring>/\n/g" | grep "=>" | sed "s/=> //g")"
|
||||
case "$faultstring" in
|
||||
"record_id_not_found")
|
||||
_info "##KAS## The record was not found, which must not be a problem. Please check manually."
|
||||
;;
|
||||
*)
|
||||
_err "##KAS## An error =>$faultstring<= occurred, please check manually."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
elif ! _contains "$response" "<item><key xsi:type=\"xsd:string\">ReturnString</key><value xsi:type=\"xsd:string\">TRUE</value></item>"; then
|
||||
_err "##KAS## Either the txt record was not found or another unknown error occurred, please check manually."
|
||||
_err "##KAS## An unknown error occurred, please check manually."
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
else # Cannot delete or unkown error
|
||||
_info "##KAS## No record_id found that can be automatically deleted. Please check or delete manually."
|
||||
# return 1
|
||||
else
|
||||
_info "##KAS## No records where found, which must not be a problem. Please check manually."
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -157,30 +132,19 @@ _check_and_save() {
|
||||
# Gets back the base domain/zone and record name.
|
||||
# See: https://github.com/acmesh-official/acme.sh/wiki/DNS-API-Dev-Guide
|
||||
_get_zone_and_record_name() {
|
||||
export _H1="SOAPAction: \"urn:xmethodsKasApi#KasApi\""
|
||||
_info "##KAS## Get domain info"
|
||||
|
||||
params_auth="\"kas_login\":\"$KAS_Login\""
|
||||
params_auth="$params_auth,\"kas_auth_type\":\"$KAS_Authtype\""
|
||||
params_auth="$params_auth,\"kas_auth_data\":\"$KAS_Authdata\""
|
||||
response="$(_post_soap "get_domains")"
|
||||
|
||||
params='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
||||
params="$params$params_auth,\"kas_action\":\"get_domains\""
|
||||
params="$params}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
||||
|
||||
_debug2 "##KAS## Wait for $KAS_default_ratelimit seconds by default before calling KAS API."
|
||||
_sleep $KAS_default_ratelimit
|
||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
||||
_debug2 "##KAS## response" "$response"
|
||||
if [ -z "$response" ]; then
|
||||
_info "##KAS## Response was empty, 2nd attempt"
|
||||
_sleep $KAS_default_ratelimit
|
||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
||||
_debug2 "##KAS## retry response" "$response"
|
||||
fi
|
||||
if _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||
_err "##KAS## Either no domains were found or another error occurred, please check manually."
|
||||
_info "##KAS## Response was empty, please check manually."
|
||||
return 1
|
||||
elif _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||
faultstring="$(echo "$response" | tr -d '\n\r' | sed "s/<faultstring>/\n=> /g" | sed "s/<\/faultstring>/\n/g" | grep "=>" | sed "s/=> //g")"
|
||||
_err "##KAS## Either no domains were found or another error =>$faultstring<= occurred, please check manually."
|
||||
return 1
|
||||
fi
|
||||
|
||||
_zonen="$(echo "$response" | tr -d '\n\r' | sed "s/<item xsi:type=\"ns2:Map\">/\n/g" | sed "s/<item><key xsi:type=\"xsd:string\">domain_name<\/key><value xsi:type=\"xsd:string\">/=> /g" | sed "s/<\/value><\/item>/\n/g" | grep "=>"| sed "s/=> //g")"
|
||||
_domain="$1"
|
||||
_temp_domain="$(echo "$1" | sed 's/\.$//')"
|
||||
@ -203,34 +167,48 @@ _get_zone_and_record_name() {
|
||||
|
||||
# Retrieve the DNS record ID
|
||||
_get_record_id() {
|
||||
_info "##KAS## Get domain info"
|
||||
|
||||
params_request="\"zone_host\":\"$_zone\""
|
||||
|
||||
response="$(_post_soap "get_dns_settings" "$params_request")"
|
||||
|
||||
if [ -z "$response" ]; then
|
||||
_info "##KAS## Response was empty, please check manually."
|
||||
return 1
|
||||
elif _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||
faultstring="$(echo "$response" | tr -d '\n\r' | sed "s/<faultstring>/\n=> /g" | sed "s/<\/faultstring>/\n/g" | grep "=>" | sed "s/=> //g")"
|
||||
_err "##KAS## Either no domains were found or another error =>$faultstring<= occurred, please check manually."
|
||||
return 1
|
||||
fi
|
||||
|
||||
_record_id="$(echo "$response" | tr -d '\n\r' | sed "s/<item xsi:type=\"ns2:Map\">/\n/g" | grep -i "$_record_name" | grep -i ">TXT<" | sed "s/<item><key xsi:type=\"xsd:string\">record_id<\/key><value xsi:type=\"xsd:string\">/=>/g" | sed "s/<\/value><\/item>/\n/g" | grep "=>" | sed "s/=>//g")"
|
||||
_debug2 _record_id "$_record_id"
|
||||
return 0
|
||||
}
|
||||
|
||||
_post_soap() {
|
||||
KAS_Action=$1
|
||||
KAS_Params=$2
|
||||
|
||||
export _H1="SOAPAction: \"urn:xmethodsKasApi#KasApi\""
|
||||
|
||||
params_auth="\"kas_login\":\"$KAS_Login\""
|
||||
params_auth="$params_auth,\"kas_auth_type\":\"$KAS_Authtype\""
|
||||
params_auth="$params_auth,\"kas_auth_data\":\"$KAS_Authdata\""
|
||||
|
||||
params_request="\"zone_host\":\"$_zone\""
|
||||
|
||||
params='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
||||
params="$params$params_auth,\"kas_action\":\"get_dns_settings\""
|
||||
params="$params,\"KasRequestParams\":{$params_request}"
|
||||
params="$params}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
||||
data='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
||||
data="$data$params_auth,\"kas_action\":\"$KAS_Action\""
|
||||
if [ -n "$KAS_Params" ]; then
|
||||
data="$data,\"KasRequestParams\":{$KAS_Params}"
|
||||
fi
|
||||
data="$data}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
||||
|
||||
_debug2 "##KAS## Wait for $KAS_default_ratelimit seconds by default before calling KAS API."
|
||||
_sleep $KAS_default_ratelimit
|
||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
||||
|
||||
response="$(_post "$data" "$KAS_Api" "" "POST" "text/xml")"
|
||||
_debug2 "##KAS## response" "$response"
|
||||
if [ -z "$response" ]; then
|
||||
_info "##KAS## Response was empty, 2nd attempt"
|
||||
_sleep $KAS_default_ratelimit
|
||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
||||
_debug2 "##KAS## retry response" "$response"
|
||||
fi
|
||||
if _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||
_err "##KAS## Either no zones were found or another error occurred, please check manually."
|
||||
return 1
|
||||
fi
|
||||
_record_id="$(echo "$response" | tr -d '\n\r' | sed "s/<item xsi:type=\"ns2:Map\">/\n/g" | grep -i "$_record_name" | grep -i ">TXT<" | sed "s/<item><key xsi:type=\"xsd:string\">record_id<\/key><value xsi:type=\"xsd:string\">/=>/g" | sed "s/<\/value><\/item>/\n/g" | grep "=>" | sed "s/=>//g")"
|
||||
_debug2 _record_id "$_record_id"
|
||||
return 0
|
||||
|
||||
echo "$response"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user