ClouDNS for libdns
This package implements the libdns interfaces for ClouDNS, allowing you to manage DNS records.
To install this package, use go get
:
go get github.com/libdns/cloudns
Here is an example of how to use this package to manage DNS records:
package main
import (
"context"
"fmt"
"github.com/libdns/cloudns"
"github.com/libdns/libdns"
"time"
)
func main() {
provider := &cloudns.Provider{
AuthId: "your_auth_id",
SubAuthId: "your_sub_auth_id",
AuthPassword: "your_auth_password",
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
// Get records
records, err := provider.GetRecords(ctx, "example.com")
if err != nil {
fmt.Printf("Failed to get records: %s\n", err)
return
}
fmt.Printf("Records: %+v\n", records)
// Append a record
newRecord := libdns.Record{
Type: "TXT",
Name: "test",
Value: "test-value",
TTL: 300 * time.Second,
}
addedRecords, err := provider.AppendRecords(ctx, "example.com", []libdns.Record{newRecord})
if err != nil {
fmt.Printf("Failed to append record: %s\n", err)
return
}
fmt.Printf("Added Records: %+v\n", addedRecords)
}
The Provider
struct has the following fields:
AuthId
(string): Your ClouDNS authentication ID.SubAuthId
(string, optional): Your ClouDNS sub-authentication ID.AuthPassword
(string): Your ClouDNS authentication password.
To run the tests, you need to set up your ClouDNS credentials and zone in the test file provider_test.go
. The tests
require a live ClouDNS account.
var (
TAuthId = "your_auth_id"
TSubAuthId = "your_sub_auth_id"
TAuthPassword = "your_auth_password"
TZone = "example.com"
)
Run the tests using the following command:
go test ./...
This project is licensed under the MIT License. See the LICENSE file for details.