Documentation
¶
Overview ¶
Package czds provides a Go client for interacting with the ICANN Centralized Zone Data Service (CZDS). It simplifies the process of querying CZDS to obtain zone files and lists the Top-Level Domains (TLDs). The client supports JWT authentication with an in-memory store by default and implements a refetching mechanism for the token if it doesn't exist, is invalid, or has expired. Users can provide a custom JWT token store by implementing the TokenStore interface. The client facilitates querying CZDS for zone file data, mapping the data by domain name and the associated DNS records. Additionally, it allows for listing TLDs available on the account and their status, providing a comprehensive tool for interacting with CZDS.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a client for interacting with the ICANN Centralized Zone Data Service (CZDS).
func NewClient ¶
func NewClient(email, password string, opts ...ClientOption) *Client
NewClient initialises and returns a new Client instance for interacting with the ICANN Centralized Zone Data Service (CZDS). It accepts email and password for authentication, enabling the client to obtain domain information from TLD zone files, list TLDs to allow to check their approval status for the account. If no TokenStore is provided, a new in-memory token store will be used by default, allowing for automatic management of JWT tokens.
func (*Client) GetZoneFile ¶
GetZoneFile fetches and parses a zone file for a given TLD from the ICANN CZDS API. It requires a context for operation cancellation, a JWT for authorization, and the TLD name. The function returns a map of domain names to their records. An error is returned if the operation fails at any stage, including request creation, HTTP communication, decompression, or file parsing. It handles gzip-compressed zone files and expects authorized access to the requested zone file.
type ClientOption ¶
type ClientOption func(*Options)
func CZDSAPIBaseURL ¶
func CZDSAPIBaseURL(baseURL string) ClientOption
func ICANNAccountsAPIBaseURL ¶
func ICANNAccountsAPIBaseURL(baseURL string) ClientOption
func TokenStoreOpt ¶
func TokenStoreOpt(store TokenStore) ClientOption
type InMemoryTokenStore ¶
type InMemoryTokenStore struct {
// contains filtered or unexported fields
}
InMemoryTokenStore implements TokenStore to provide an in-memory storage mechanism for JWT tokens.
func (*InMemoryTokenStore) Get ¶
func (ts *InMemoryTokenStore) Get() string
Get retrieves the stored JWT token from the in-memory store.
func (*InMemoryTokenStore) Save ¶
func (ts *InMemoryTokenStore) Save(token string) error
Save stores the given JWT token in the in-memory store.
type TokenStore ¶
TokenStore defines an interface for JWT storage solutions. It allows clients to implement their own mechanism for storing JWT tokens, facilitating a flexible approach to token management. The Save method is designed to be called by the client when the provided JWT token has expired or does not exist in the storage. This design abstracts the complexities of token persistence away from the client, allowing the client to focus solely on how and where to store the JWT. Through this interface, clients can tailor their storage strategy to fit their application's needs, whether that involves in-memory caching, database storage, or any other persistent storage solution. The goal is to minimise token refetching by efficiently managing token expiration and renewal, streamlining the authentication process.