Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

tiramiseb/go-gandi-livedns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gandi LiveDNS Go library

GoDoc License

As of january 2020, this library will no longer be maintained, it is superseded by https://github.com/tiramiseb/go-gandi. Don't hesitate to make PRs bugfixes or security fixes though...

This library interacts with Gandi's LiveDNS API, to manage domains hosted on Gandi. This API returns some data as HTTP headers, please note those are ignored by this library.

A simple CLI is also shipped with this library. It returns responses to the requests in JSON.

Example

This example mimics the steps of the official LiveDNS documentation example.

First (step 1), get your API key from the "Security" section in new Account admin panel to be able to make authenticated requests to the API. Note: sharing_id is optional. It is used e.g. when the API key is registered to a user, where the domain you want to manage is not registered with that user (but the user does have rights on that zone/organization).

import "github.com/tiramiseb/go-gandi-livedns"
apikey := "<the API key>"
sharing_id := "<the sharing_id for that domain, may be nil>"
g := gandi.New(apikey, sharing_id)
// Step 2: create the zone
zone := g.CreateZone("example.com Zone")
// Step 3: create DNS records
g.CreateZoneRecord(zone.UUID, "www", "A", 3600, []string{"192.168.0.1"})
// Step 4: associate the domain
g.AttachDomainToZone(zone.UUID, "example.com")
// Step 5: change nameservers
nameservers := g.getDomainNS("example.com")
// Step 6: setup automatic DNSSEC signing
g.SignDomain("example.com")
// Getting the key href
g.GetDomainKeys("example.com")
// Deleting the key
g.DeleteDomainKey("example.com", "bb004a38-566b-4200-bd6e-830b48ea50cf")
// Recovering the key
g.UpdateDomainKey("example.com", "bb004a38-566b-4200-bd6e-830b48ea50cf", false)
// Step 7: adding extra security with a slave server
// Creating a TSIG key
tsig, _ := g.CreateTsig()
// Adding the TSIG key for AXFRs
g.AddTsigToDomain("example.com", tsig.UUID)
// Adding two slaves servers to the domain
for _, host := range []string{"198.51.100.1", "2001:DB8::1"} {
    g.AddSlaveToDomain("example.com", host)
}
// Getting slave BIND sample configurations
g.GetTsigBIND("85e7b6e3-4553-479b-b968-cd0c77143802")

Compiling the CLI

cd cmd
go build -o gandi

About

A Go library for the Gandi LiveDNS API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages