6 #LA_Key="d1j2fdo4dee3948"
7 DNSLA_API
="https://www.dns.la/api/"
8 ######## Public functions #####################
9 #Usage: dns_la_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
14 LA_Id
="${LA_Id:-$(_readaccountconf_mutable LA_Id)}"
15 LA_Key
="${LA_Key:-$(_readaccountconf_mutable LA_Key)}"
16 if [ -z "$LA_Id" ] ||
[ -z "$LA_Key" ]; then
19 _err
"You don't specify dnsla api id and key yet."
20 _err
"Please create your key and try again."
24 #save the api key and email to the account conf file.
25 _saveaccountconf_mutable LA_Id
"$LA_Id"
26 _saveaccountconf_mutable LA_Key
"$LA_Key"
28 _debug
"detect the root zone"
29 if ! _get_root
"$fulldomain"; then
34 add_record
"$_domain" "$_sub_domain" "$txtvalue"
42 _fullkey
=$
(printf "%s" "$fulldomain" |
awk '{ string=substr($0, 17); print string; }' |
tr '.' '_' )
44 LA_Id
="${LA_Id:-$(_readaccountconf_mutable LA_Id)}"
45 LA_Key
="${LA_Key:-$(_readaccountconf_mutable LA_Key)}"
46 _debug fullkey
"$_fullkey"
47 RM_recordid
="$(_readaccountconf "$_fullkey")"
48 _debug rm_recordid
"$RM_recordid"
49 _debug
"detect the root zone"
50 if ! _get_root
"$fulldomain"; then
55 if ! _rest GET
"record.ashx?cmd=get&apiid=$LA_Id&apipass=$LA_Key&rtype=json&domainid=$_domain_id&domain=$_domain&recordid=$RM_recordid"; then
56 _err
"get record lis error."
60 if ! _contains
"$response" "$RM_recordid"; then
61 _info
"no need to remove record."
65 if ! _rest GET
"record.ashx?cmd=remove&apiid=$LA_Id&apipass=$LA_Key&rtype=json&domainid=$_domain_id&domain=$_domain&recordid=$RM_recordid"; then
66 _err
"record remove error."
70 _clearaccountconf
"$_fullkey"
72 _contains
"$response" "\"code\":300"
76 #usage: root sub txtvalue
81 fulldomain
="$sub.$root"
83 _info
"adding txt record"
85 if ! _rest GET
"record.ashx?cmd=create&apiid=$LA_Id&apipass=$LA_Key&rtype=json&domainid=$_domain_id&host=$_sub_domain&recordtype=TXT&recorddata=$txtvalue&recordline="; then
89 if _contains
"$response" "\"code\":300"; then
90 _record_id
=$
(printf "%s" "$response" |
grep '"resultid"' | cut
-d : -f 2 | cut
-d , -f 1 |
tr -d '\r' |
tr -d '\n' )
91 _fullkey
=$
(printf "%s" "$fulldomain" |
awk '{ string=substr($0, 17); print string; }' |
tr '.' '_' )
92 _debug fullkey
"$_fullkey"
93 _saveaccountconf
"$_fullkey" "$_record_id"
94 _debug _record_id
"$_record_id"
96 _contains
"$response" "\"code\":300"
99 #################### Private functions below ##################################
100 #_acme-challenge.www.domain.com
102 # _sub_domain=_acme-challenge.www
104 # _domain_id=sdjkglgdfewsdfg
110 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
116 if ! _rest GET
"domain.ashx?cmd=get&apiid=$LA_Id&apipass=$LA_Key&rtype=json&domain=$h"; then
120 if _contains
"$response" "\"code\":300"; then
121 _domain_id
=$
(printf "%s" "$response" |
grep '"domainid"' | cut
-d : -f 2 | cut
-d , -f 1 |
tr -d '\r' |
tr -d '\n' )
122 _debug _domain_id
"$_domain_id"
123 if [ "$_domain_id" ]; then
124 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
125 _debug _sub_domain
"$_sub_domain"
127 _debug _domain
"$_domain"
138 #Usage: method URI data
148 if [ "$m" = "GET" ]; then
149 response
="$(_get "$url" | tr -d ' ' | tr "}" ",")"
152 response
="$(_post "$data" "$url" | tr -d ' ' | tr "}" ",")"
155 if [ "$?" != "0" ]; then
159 _debug2 response
"$response"