namecheap

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2020 License: GPL-3.0 Imports: 10 Imported by: 1

README

libdns-namecheap

Namecheap provider implementation for libdns

NOTE This module is being implemented for my personal usage. It should be sufficient to integrate with Caddy2 to use Let's Encrypt DNS challenge on Namecheap.

Namecheap's API is very crude and dangerous. Please don't use this in production for any critical systems.

Testing

Create an account in https://www.sandbox.namecheap.com/ and enable the API (https://www.namecheap.com/support/api/intro/ under Enabling API Access).

Export 2 environment variables: NAMECHEAP_API_KEY and NAMECHEAP_API_USER with the data from the previous step.

In that account, reserve the following domains:

  • gethosts-0.com
  • sethosts.com

Finally, run the test make task:

$ make test

Documentation

Index

Constants

View Source
const APIHostTypeA = "A"
View Source
const APIHostTypeAAAA = "AAAA"
View Source
const APIHostTypeALIAS = "ALIAS"
View Source
const APIHostTypeCAA = "CAA"
View Source
const APIHostTypeCNAME = "CNAME"
View Source
const APIHostTypeFRAME = "FRAME"
View Source
const APIHostTypeMX = "MX"
View Source
const APIHostTypeMXE = "MXE"
View Source
const APIHostTypeNS = "NS"
View Source
const APIHostTypeTXT = "TXT"
View Source
const APIHostTypeURL = "URL"
View Source
const APIHostTypeURL301 = "URL301"

Variables

This section is empty.

Functions

This section is empty.

Types

type APICommandResponse

type APICommandResponse struct {
	XMLName        xml.Name          `xml:"CommandResponse"`
	Type           string            `xml:"Type,attr"`
	GetHostsResult APIGetHostsResult `xml:"DomainDNSGetHostsResult"`
	SetHostsResult APISetHostsResult `xml:"DomainDNSSetHostsResult"`
}

type APIError

type APIError struct {
	Number  int    `xml:"number,attr"`
	Message string `xml:",chardata"`
}

type APIGetHostsRequest

type APIGetHostsRequest struct {
	SLD string
	TLD string
}

type APIGetHostsResult

type APIGetHostsResult struct {
	XMLName       xml.Name   `xml:"DomainDNSGetHostsResult"`
	Domain        string     `xml:"Domain,attr"`
	IsUsingOurDNS bool       `xml:"IsUsingOurDNS,attr"`
	Hosts         []*APIHost `xml:"host"`
}

type APIHost

type APIHost struct {
	XMLName xml.Name `xml:"host"`
	Name    string   `xml:"Name,attr"`
	Type    string   `xml:"Type,attr"`
	Address string   `xml:"Address,attr"`
	TTL     int      `xml:"TTL,attr"`
}

func (*APIHost) MatchRecord

func (h *APIHost) MatchRecord(other libdns.Record) error

MatchRecord compares the APIHost with a libdns.Record. It returns an error if the records don't match.

type APIResponse

type APIResponse struct {
	XMLName          xml.Name           `xml:"ApiResponse"`
	Status           string             `xml:"Status,attr"`
	Errors           []APIError         `xml:"Errors>Error"`
	RequestedCommand string             `xml:"RequestedCommand"`
	CommandResponse  APICommandResponse `xml:"CommandResponse"`
}

type APISetHostsRequest

type APISetHostsRequest struct {
	SLD   string
	TLD   string
	Hosts []*APIHost
}

type APISetHostsResult

type APISetHostsResult struct {
	XMLName   xml.Name `xml:"DomainDNSSetHostsResult"`
	Domain    string   `xml:"Domain,attr"`
	IsSuccess bool     `xml:"IsSuccess,attr"`
}

type Provider

type Provider struct {
	Sandbox bool

	APIUser string
	APIKey  string

	http.Client
}

Provider implements the libdns interfaces for Namecheap

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

AppendRecords adds records to the zone. It returns the records that were added.

func (*Provider) DeleteRecords

func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

DeleteRecords deletes the records from the zone. It returns the records that were deleted.

func (*Provider) GetRecords

func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)

GetRecords lists all the records in the zone.

func (*Provider) SetRecords

func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the updated records. NOTE: Not implemented

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL