6 _DD_BASE
="https://durabledns.com/services/dns"
8 ######## Public functions #####################
10 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
11 dns_durabledns_add
() {
15 DD_API_User
="${DD_API_User:-$(_readaccountconf_mutable DD_API_User)}"
16 DD_API_Key
="${DD_API_Key:-$(_readaccountconf_mutable DD_API_Key)}"
17 if [ -z "$DD_API_User" ] ||
[ -z "$DD_API_Key" ]; then
20 _err
"You didn't specify a durabledns api user or key yet."
21 _err
"You can get yours from here https://durabledns.com/dashboard/index.php"
25 #save the api key and email to the account conf file.
26 _saveaccountconf_mutable DD_API_User
"$DD_API_User"
27 _saveaccountconf_mutable DD_API_Key
"$DD_API_Key"
29 _debug
"First detect the root zone"
30 if ! _get_root
"$fulldomain"; then
35 _debug _sub_domain
"$_sub_domain"
36 _debug _domain
"$_domain"
38 _dd_soap createRecord string zonename
"$_domain." string name
"$_sub_domain" string
type "TXT" string data
"$txtvalue" int aux
0 int ttl
10 string ddns_enabled N
39 _contains
"$response" "createRecordResponse"
46 DD_API_User
="${DD_API_User:-$(_readaccountconf_mutable DD_API_User)}"
47 DD_API_Key
="${DD_API_Key:-$(_readaccountconf_mutable DD_API_Key)}"
48 if [ -z "$DD_API_User" ] ||
[ -z "$DD_API_Key" ]; then
51 _err
"You didn't specify a durabledns api user or key yet."
52 _err
"You can get yours from here https://durabledns.com/dashboard/index.php"
56 _debug
"First detect the root zone"
57 if ! _get_root
"$fulldomain"; then
61 _debug _sub_domain
"$_sub_domain"
62 _debug _domain
"$_domain"
64 _debug
"Find record id"
65 if ! _dd_soap listRecords string zonename
"$_domain."; then
66 _err
"can not listRecords"
70 subtxt
="$(echo "$txtvalue" | cut -c 1-30)"
71 record
="$(echo "$response" | sed 's/<item\>/#<item>/g' | tr '#' '\n' | grep ">$subtxt")"
72 _debug record
"$record"
73 if [ -z "$record" ]; then
74 _err
"can not find record for txtvalue" "$txtvalue"
79 recordid
="$(echo "$record" | _egrep_o '<id xsi:type="xsd
:int
">[0-9]*</id>' | cut -d '>' -f 2 | cut -d '<' -f 1)"
80 _debug recordid
"$recordid"
81 if [ -z "$recordid" ]; then
82 _err
"can not find record id"
86 if ! _dd_soap deleteRecord string zonename
"$_domain." int id
"$recordid"; then
91 _contains
"$response" "Success"
94 #_acme-challenge.www.domain.com
96 # _sub_domain=_acme-challenge.www
100 if ! _dd_soap
"listZones"; then
107 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
114 if _contains
"$response" ">$h.</origin>"; then
115 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
130 _urn
="${_method}wsdl"
131 # put the parameters to xml
133 <apiuser xsi:type=\"xsd:string\">$DD_API_User</apiuser>
134 <apikey xsi:type=\"xsd:string\">$DD_API_Key</apikey>
143 body
="$body<$_k xsi:type=\"xsd:$_t\">$_v</$_k>"
145 body
="$body</tns:$_method>"
146 _debug2
"SOAP request ${body}"
149 _xml
='<?xml version="1.0" encoding="utf-8"?>
150 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
151 xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
152 xmlns:tns="urn:'$_urn'"
153 xmlns:types="urn:'$_urn'/encodedTypes"
154 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
155 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
156 <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'"$body"'</soap:Body>
161 _action
="SOAPAction: \"urn:$_urn#$_method\""
162 _debug2
"_action" "$_action"
163 export _H1
="$_action"
164 export _H2
="Content-Type: text/xml; charset=utf-8"
166 _url
="$_DD_BASE/$_method.php"
167 _debug
"_url" "$_url"
168 if ! response
="$(_post "${_xml}" "${_url}")"; then
172 _debug2
"response" "$response"
173 response
="$(echo "$response" | tr -d "\r\n" | _egrep_o ":${_method}Response .
*:${_method}Response
><")"
174 _debug2
"response" "$response"