_err "You don't specify dnsla api id and key yet."
_err "Please create your key and try again."
_err "You didn't specify a dnsla api id and key yet."
return1
return1
fi
fi
@ -25,13 +26,30 @@ dns_la_add() {
_saveaccountconf_mutable LA_Id "$LA_Id"
_saveaccountconf_mutable LA_Id "$LA_Id"
_saveaccountconf_mutable LA_Key "$LA_Key"
_saveaccountconf_mutable LA_Key "$LA_Key"
_debug "detect the root zone"
_debug "First detect the root zone"
if ! _get_root "$fulldomain";then
if ! _get_root "$fulldomain";then
_err "invalid domain"
_err "invalid domain"
return1
return1
fi
fi
add_record "$_domain""$_sub_domain""$txtvalue"
_debug _domain_id "$_domain_id"
_debug _sub_domain "$_sub_domain"
_debug _domain "$_domain"
_info "Adding record"
if _la_rest "record.ashx?cmd=create&apiid=$LA_Id&apipass=$LA_Key&rtype=json&domainid=$_domain_id&host=$_sub_domain&recordtype=TXT&recorddata=$txtvalue&recordline=";then
if _contains "$response"'"resultid":';then
_info "Added, OK"
return0
elif _contains "$response"'"code":532';then
_info "Already exists, OK"
return0
else
_err "Add txt record error."
return1
fi
fi
_err "Add txt record error."
return1
}
}
@ -48,45 +66,33 @@ dns_la_rm() {
_err "invalid domain"
_err "invalid domain"
return1
return1
fi
fi
_debug _domain_id "$_domain_id"
_debug _sub_domain "$_sub_domain"
_debug _domain "$_domain"
if ! _rest GET "record.ashx?cmd=listn&apiid=$LA_Id&apipass=$LA_Key&rtype=json&domainid=$_domain_id&domain=$_domain&host=$_sub_domain&recordtype=TXT&recorddata=$txtvalue";then
_err "get record list error."
_debug "Getting txt records"
if ! _la_rest "record.ashx?cmd=listn&apiid=$LA_Id&apipass=$LA_Key&rtype=json&domainid=$_domain_id&domain=$_domain&host=$_sub_domain&recordtype=TXT&recorddata=$txtvalue";then
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
if ! _la_rest "record.ashx?cmd=remove&apiid=$LA_Id&apipass=$LA_Key&rtype=json&domainid=$_domain_id&domain=$_domain&recordid=$record_id";then
_err "Delete record error."
return1
return1
fi
fi
_contains "$response"'"code":300'
if _contains "$response""resultid"|| _contains "$response""\"code\":532";then