Documentation
¶
Overview ¶
Package dsupdate is a library for updating DS records with Punktum.dk's (DK Hostmasters) proprietary DS Update protocol.
DS Update is a proprietary protocol and service developed and offered by Punktum as an interface for updating DNSSEC related DS records associated with a .dk domain name.
The service and protocol is documented at <https://github.com/Punktum-dk/dsu-service-specification>.
This package has functionality to update or delete DS records using the DS Update protocol.
Example (Delete) ¶
This example deletes existing DS records of the eksempel.dk domain. The deletion is made with at timeout of 5 second specified using a context with a timeout.
package main import ( "context" "errors" "fmt" "net/http" "time" "arnested.dk/go/dsupdate" ) func main() { // Create a client with some fake credentials. client := dsupdate.Client{ Domain: "eksempel.dk", // .dk domain name UserID: "ABCD1234-DK", // Punktum.dk user ID Password: "abba4evah", // Punktum.dk password BaseURL: dsupdate.Sandbox, // If left out defaults to dsupdate.Production HTTPClient: &http.Client{}, // If left out defaults to http.DefaultClient } // We'll set a 5 second timeout in the deletion using the // context package. ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() // Delete the DS record(s) to Punktum.dk. resp, err := client.Delete(ctx) // If the update failed and a substatus was returned in the // "X-DSU" header the error be of the `SubStatus` type. var subStatusErr dsupdate.SubStatus if errors.As(err, &subStatusErr) { fmt.Printf("Failed with DSU substatus error (%d): %s", subStatusErr, subStatusErr) return } // All other errors will be unspecified error of the error // interface. if err != nil { fmt.Printf("Failed with some error: %s", err) return } // If there was no error returned the delete succeeded. `resp` // will be the body of whatever was returned from the DS // Update service. fmt.Printf("Succeeded. Punktum.dk responded with the message in the body: %s", resp) }
Output:
Example (Update) ¶
This example updates the DS records of the eksempel.dk domain. The update is made with at timeout of 5 second specified using a http.Client configured with the timeout..
package main import ( "context" "errors" "fmt" "net/http" "time" "arnested.dk/go/dsupdate" ) func main() { // Create a client with some fake credentials. client := dsupdate.Client{ Domain: "eksempel.dk", // .dk domain name UserID: "ABCD1234-DK", // Punktum.dk user ID Password: "abba4evah", // Punktum.dk password BaseURL: dsupdate.Sandbox, // If left out defaults to dsupdate.Production HTTPClient: &http.Client{ Timeout: 5 * time.Second, }, } // Make a slice of DS records. records := []dsupdate.DsRecord{ { KeyTag: 43930, Algorithm: 8, // RSA/SHA-256 DigestType: 2, // SHA-256 Digest: "E174B66853D0DE1A4E391DFAE924695EB6BF12D28E1A68BDBDB44C4F0D325EA1", }, } ctx := context.Background() // Post the new DS record(s) to Punktum.dk. resp, err := client.Update(ctx, records) // If the update failed and a substatus was returned in the // "X-DSU" header the error be of the `SubStatus` type. var subStatusErr dsupdate.SubStatus if errors.As(err, &subStatusErr) { fmt.Printf("Failed with DSU substatus error (%d): %s", subStatusErr, subStatusErr) return } // All other errors will be unspecified error of the error // interface. if err != nil { fmt.Printf("Failed with some error: %s", err) return } // If there was no error returned the update succeeded. `resp` // will be the body of whatever was returned from the DS // Update service ("Request sent to DSU::Version_1_0 okay"). fmt.Printf("Succeeded. Punktum.dk responded with the message in the body: %s", resp) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseURL ¶
type BaseURL string
BaseURL is the endpoint of the DS Update service.
type Client ¶
type Client struct { Domain string // .dk domain name, i.e eksempel.dk UserID string // Punktum.dk user ID, i.e. ABCD1234-DK Password string // Punktum.dk password BaseURL BaseURL // DS Update service base URL. You can use constants dsupdate.Production (default) or dsupdate.Sandbox HTTPClient *http.Client }
Client for doing updates and deletions.
type SubStatus ¶
type SubStatus int16
SubStatus is the error specified by the DS Upload service. See: https://github.com/DK-Hostmaster/dsu-service-specification#http-sub-status-codes
const ( UserIDNotSpecified SubStatus = 480 // user ID not specified PasswordNotSpecified SubStatus = 481 // password not specified MissingAParameter SubStatus = 482 // missing a parameter DomainNameNotSpecified SubStatus = 483 // domain name not specified InvalidDomainName SubStatus = 484 // invalid domain name InvalidUserID SubStatus = 485 // invalid user ID InvalidDigestAndDigestTypeCombination SubStatus = 486 // invalid digest and digest type combination TheContentsOfAtLeastOneParameterIsSyntacticallyWrong SubStatus = 487 // the contents of at least one parameter is syntactically wrong AtLeastOneDSKeyHasAnInvalidAlgorithm SubStatus = 488 // at least one DS key has an invalid algorithm InvalidSequenceOfSets SubStatus = 489 // invalid sequence of sets UnknownParameterGiven SubStatus = 495 // unknown parameter given UnknownUserID SubStatus = 496 // unknown user ID UnknownDomainName SubStatus = 497 // unknown domain name AuthenticationFailed SubStatus = 531 // authentication failed AuthorizationFailed SubStatus = 532 // authorization failed AuthenticatingUsingThisPasswordTypeIsNotSupported SubStatus = 533 // authenticating using this password type is not supported )
DS Upload Sub-status codes. See: https://github.com/DK-Hostmaster/dsu-service-specification#http-sub-status-codes