returnfmt.Errorf("unable to find the main domain for: %s",domain)
}
query:=u.Query()
query.Set("domains",mainDomain)
query.Set("token",token)
query.Set("clear",strconv.FormatBool(clear))
query.Set("txt",txt)
u.RawQuery=query.Encode()
response,err:=d.config.HTTPClient.Get(u.String())
iferr!=nil{
returnerr
}
deferresponse.Body.Close()
bodyBytes,err:=ioutil.ReadAll(response.Body)
iferr!=nil{
returnerr
}
body:=string(bodyBytes)
ifbody!="OK"{
returnfmt.Errorf("request to change TXT record for DuckDNS returned the following result (%s) this does not match expectation (OK) used url [%s]",body,u)
}
returnnil
}
// DuckDNS only lets you write to your subdomain
// so it must be in format subdomain.duckdns.org
// not in format subsubdomain.subdomain.duckdns.org
// so strip off everything that is not top 3 levels