Exemplo n.º 1
0
func removeDNS(domain, token string, record dnsimple.Record) (err error) {
	cli := &dnsimple.Client{dnsimple.NewDomainAuth(domain, token)}
	pre, post := getDomainParts(domain)

	err = cli.DeleteRecord(post, pre, record)
	if err != nil {
		return
	}

	return
}
Exemplo n.º 2
0
func registerDNS(domain, token string) (err error) {
	cli := &dnsimple.Client{dnsimple.NewDomainAuth(domain, token)}
	// cli.GetRecords("gofiddler.com")
	// Simple way to get my IP
	resp, err := http.Get("http://icanhazip.com/")
	if err != nil {
		log.Fatal("Error getting ip:", err)
	}

	ipBytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatal("Unable to parse response:", err)
	}
	ip := string(ipBytes)
	log.Println("My ip:", ip)

	pre, post := getDomainParts(domain)
	_, err = cli.CreateRecord(post, pre, dnsimple.A_RECORD, ip, 10, 60) // Okay, this is a good way to register into round-robin

	return
}
Exemplo n.º 3
0
func getRecords(domain, token string) (records []dnsimple.RecordObj, err error) {
	cli := &dnsimple.Client{dnsimple.NewDomainAuth(domain, token)}

	pre, post := getDomainParts(domain)
	return cli.GetRecords(post, pre)
}