epp

package module
v0.0.0-...-140382f Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 11 Imported by: 0

README

EPP for Go

build status pkg.go.dev

EPP (Extensible Provisioning Protocol) client for Go. Extracted from and in production use at Domainr.

Note: This library is currently under development. Its API is subject to breaking changes at any time.

Installation

go get github.com/domainr/epp

Usage

tconn, err := tls.Dial("tcp", "epp.example.com:700", nil)
if err != nil {
	return err
}

conn, err := epp.NewConn(tconn)
if err != nil {
	return err
}

err = conn.Login(user, password, "")
if err != nil {
	return err
}

dcr, err := conn.CheckDomain("google.com")
if err != nil {
	return err
}
for _, r := range dcr.Checks {
	// ...
}

Todo

  • Tests
  • Commands other than Check

Author

© 2021 nb.io LLC

Documentation

Index

Constants

View Source
const (
	ObjDomain     = "urn:ietf:params:xml:ns:domain-1.0"
	ObjHost       = "urn:ietf:params:xml:ns:host-1.0"
	ObjContact    = "urn:ietf:params:xml:ns:contact-1.0"
	ObjFinance    = "http://www.unitedtld.com/epp/finance-1.0"
	ExtSecDNS     = "urn:ietf:params:xml:ns:secDNS-1.1"
	ExtRGP        = "urn:ietf:params:xml:ns:rgp-1.0"
	ExtLaunch     = "urn:ietf:params:xml:ns:launch-1.0"
	ExtIDN        = "urn:ietf:params:xml:ns:idn-1.0"
	ExtCharge     = "http://www.unitedtld.com/epp/charge-1.0"
	ExtFee05      = "urn:ietf:params:xml:ns:fee-0.5"
	ExtFee06      = "urn:ietf:params:xml:ns:fee-0.6"
	ExtFee07      = "urn:ietf:params:xml:ns:fee-0.7"
	ExtFee08      = "urn:ietf:params:xml:ns:fee-0.8"
	ExtFee09      = "urn:ietf:params:xml:ns:fee-0.9"
	ExtFee11      = "urn:ietf:params:xml:ns:fee-0.11"
	ExtFee21      = "urn:ietf:params:xml:ns:fee-0.21"
	ExtFee10      = "urn:ietf:params:xml:ns:epp:fee-1.0"
	ExtPrice      = "urn:ar:params:xml:ns:price-1.1"
	ExtNamestore  = "http://www.verisign-grs.com/epp/namestoreExt-1.1"
	ExtNeulevel   = "urn:ietf:params:xml:ns:neulevel"
	ExtNeulevel10 = "urn:ietf:params:xml:ns:neulevel-1.0"
)

EPP extension URNs

View Source
const (
	// EPP defines the IETF URN for the EPP namespace.
	// https://www.iana.org/assignments/xml-registry/ns/epp-1.0.txt
	EPP = `urn:ietf:params:xml:ns:epp-1.0`

	// EPPCommon defines the IETF URN for the EPP Common namespace.
	// https://www.iana.org/assignments/xml-registry/ns/eppcom-1.0.txt
	EPPCommon = `urn:ietf:params:xml:ns:eppcom-1.0`
)

Variables

View Source
var (
	// True is a Bool of value true.
	True = Bool(true)

	// False is a Bool of value false.
	False = Bool(false)
)
View Source
var DebugLogger io.Writer

DebugLogger is an io.Writer. Set to enable logging of EPP message XML.

View Source
var ExtURNNames = map[string]string{
	"secDNS-1.1":       ExtSecDNS,
	"rgp-1.0":          ExtRGP,
	"launch-1.0":       ExtLaunch,
	"idn-1.0":          ExtIDN,
	"charge-1.0":       ExtCharge,
	"fee-0.5":          ExtFee05,
	"fee-0.6":          ExtFee06,
	"fee-0.7":          ExtFee07,
	"fee-0.8":          ExtFee08,
	"fee-0.9":          ExtFee09,
	"fee-0.11":         ExtFee11,
	"fee-0.21":         ExtFee21,
	"fee-1.0":          ExtFee10,
	"price-1.1":        ExtPrice,
	"namestoreExt-1.1": ExtNamestore,
	"neulevel":         ExtNeulevel,
	"neulevel-1.0":     ExtNeulevel10,
}

ExtURNNames maps short extension names to their full URN.

Functions

func IgnoreEOF

func IgnoreEOF(err error) error

IgnoreEOF returns err unless err == io.EOF, in which case it returns nil.

Types

type Bool

type Bool bool

Bool represents a bool that can be serialized to XML. True: <tag> False: (no tag)

func (Bool) MarshalXML

func (b Bool) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML impements the xml.Marshaler interface. Any tag present with this type = true.

func (Bool) MarshalXMLAttr

func (b Bool) MarshalXMLAttr(name xml.Name) (attr xml.Attr, err error)

MarshalXMLAttr implements the xml.MarshalerAttr interface. Attributes will be serialized with a value of "0" or "1".

func (*Bool) UnmarshalXML

func (b *Bool) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML impements the xml.Unmarshaler interface. Any tag present with this type = true.

func (*Bool) UnmarshalXMLAttr

func (b *Bool) UnmarshalXMLAttr(attr *xml.Attr) error

UnmarshalXMLAttr impements the xml.MarshalerAttr interface. An empty value, 0, or starting with a f or F is considered false. Any other value is considered true.

type Conn

type Conn struct {
	// Conn is the underlying net.Conn (usually a TLS connection).
	net.Conn

	// Timeout defines the timeout for network operations.
	// It must be set at initialization. Changing it after
	// a connection is already opened will have no effect.
	Timeout time.Duration

	// Greeting holds the last received greeting message from the server,
	// indicating server name, status, data policy and capabilities.
	//
	// Deprecated: This field is written to upon opening a new EPP connection and should not be modified.
	Greeting

	// LoginResult holds the last received login response message's Result
	// from the server, in which some servers might include diagnostics such
	// as connection count limits.
	//
	// Deprecated: this field is written to by the Login method but otherwise is not used by this package.
	LoginResult Result
	// contains filtered or unexported fields
}

Conn represents a single connection to an EPP server. Reads and writes are serialized, so it is safe for concurrent use.

func NewConn

func NewConn(conn net.Conn) (*Conn, error)

NewConn initializes an epp.Conn from a net.Conn and performs the EPP handshake. It reads and stores the initial EPP <greeting> message. https://tools.ietf.org/html/rfc5730#section-2.4

func NewTimeoutConn

func NewTimeoutConn(conn net.Conn, timeout time.Duration) (*Conn, error)

NewTimeoutConn initializes an epp.Conn like NewConn, limiting the duration of network operations on conn using Set(Read|Write)Deadline.

func (*Conn) CheckDomain

func (c *Conn) CheckDomain(domains ...string) (*DomainCheckResponse, error)

CheckDomain queries the EPP server for the availability status of one or more domains.

func (*Conn) CheckDomainExtensions

func (c *Conn) CheckDomainExtensions(domains []string, extData map[string]string) (*DomainCheckResponse, error)

CheckDomainExtensions allows specifying extension data for the following:

  • "neulevel:unspec": a string of the Key=Value data for the unspec tag
  • "launch:phase": a string of the launch phase

func (*Conn) Close

func (c *Conn) Close() error

Close sends an EPP <logout> command and closes the connection c.

func (*Conn) DomainInfo

func (c *Conn) DomainInfo(domain string, extData map[string]string) (*DomainInfoResponse, error)

DomainInfo retrieves info for a domain. https://tools.ietf.org/html/rfc5731#section-3.1.2

func (*Conn) Hello

func (c *Conn) Hello() error

Hello sends a <hello> command to request a <greeting> from the EPP server.

func (*Conn) Login

func (c *Conn) Login(user, password, newPassword string) error

Login initializes an authenticated EPP session. https://tools.ietf.org/html/rfc5730#section-2.9.1.1

func (*Conn) Logout

func (c *Conn) Logout() error

Logout sends a <logout> command to terminate an EPP session. https://tools.ietf.org/html/rfc5730#section-2.9.1.2

func (*Conn) ReadRawResponse

func (c *Conn) ReadRawResponse() ([]byte, error)

readRawResponse dequeues and returns a raw EPP response frame from Conn

func (*Conn) SendFrame

func (c *Conn) SendFrame(frame []byte) error

This function lets you send a raw XML frame to the server

type DomainCharge

type DomainCharge struct {
	Domain       string
	Category     string
	CategoryName string
}

DomainCharge represents various EPP charge and fee extension data. FIXME: unpack into multiple types for different extensions.

type DomainCheck

type DomainCheck struct {
	Domain    string
	Reason    string
	Available bool
}

DomainCheck represents an EPP <chkData> and associated extension data.

type DomainCheckResponse

type DomainCheckResponse struct {
	Domain  string
	Checks  []DomainCheck
	Charges []DomainCharge
}

DomainCheckResponse represents an EPP <response> for a domain check.

type DomainInfoResponse

type DomainInfoResponse struct {
	Domain string    // <domain:name>
	ID     string    // <domain:roid>
	ClID   string    // <domain:clID>
	UpID   string    // <domain:upID>
	CrDate time.Time // <domain:crDate>
	ExDate time.Time // <domain:exDate>
	UpDate time.Time // <domain:upDate>
	TrDate time.Time // <domain:trDate>
	Status []string  // <domain:status>
}

DomainInfoResponse represents an EPP response for a domain info request. https://tools.ietf.org/html/rfc5731#section-3.1.2

type Greeting

type Greeting struct {
	ServerName string   `xml:"svID"`
	Versions   []string `xml:"svcMenu>version"`
	Languages  []string `xml:"svcMenu>lang"`
	Objects    []string `xml:"svcMenu>objURI"`
	Extensions []string `xml:"svcMenu>svcExtension>extURI,omitempty"`
}

Greeting is an EPP response that represents server status and capabilities. https://tools.ietf.org/html/rfc5730#section-2.4

func (*Greeting) SupportsExtension

func (g *Greeting) SupportsExtension(uri string) bool

SupportsExtension returns true if the EPP server supports the extension specified by uri.

func (*Greeting) SupportsObject

func (g *Greeting) SupportsObject(uri string) bool

SupportsObject returns true if the EPP server supports the object specified by uri.

type Response

Response represents an EPP response.

type Result

type Result struct {
	Code    int    `xml:"code,attr"`
	Message string `xml:"msg"`
	Reason  string `xml:"extValue>reason,omitempty"`
}

Result represents an EPP <result> element.

func (*Result) Error

func (r *Result) Error() string

Error implements the error interface.

func (*Result) IsError

func (r *Result) IsError() bool

IsError determines whether an EPP status code is an error. https://tools.ietf.org/html/rfc5730#section-3

func (*Result) IsFatal

func (r *Result) IsFatal() bool

IsFatal determines whether an EPP status code is a fatal response, and the connection should be closed. https://tools.ietf.org/html/rfc5730#section-3

type Status

type Status uint32

Status represents EPP status codes as a bitfield. https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en https://tools.ietf.org/html/std69 https://tools.ietf.org/html/rfc3915

const (
	StatusUnknown Status = iota

	// Server status codes set by a domain registry
	StatusOK Status = 1 << (iota - 1) // Standard status for a domain, meaning it has no pending operations or prohibitions.
	StatusLinked
	StatusAddPeriod // This grace period is provided after the initial registration of a domain name. If the registrar deletes the domain name during this period, the registry may provide credit to the registrar for the cost of the registration.
	StatusAutoRenewPeriod
	StatusInactive
	StatusPendingCreate
	StatusPendingDelete
	StatusPendingRenew
	StatusPendingRestore
	StatusPendingTransfer
	StatusPendingUpdate
	StatusRedemptionPeriod
	StatusRenewPeriod
	StatusServerDeleteProhibited
	StatusServerHold
	StatusServerRenewProhibited
	StatusServerTransferProhibited
	StatusServerUpdateProhibited
	StatusTransferPeriod
	StatusClientDeleteProhibited
	StatusClientHold
	StatusClientRenewProhibited
	StatusClientTransferProhibited
	StatusClientUpdateProhibited

	// RDAP status codes map roughly, but not exactly to EPP status codes.
	// https://tools.ietf.org/html/rfc8056#section-2
	StatusActive     = StatusOK
	StatusAssociated = StatusLinked

	// StatusClient are status codes set by a domain registrar.
	StatusClient = StatusClientDeleteProhibited | StatusClientHold | StatusClientRenewProhibited | StatusClientTransferProhibited | StatusClientUpdateProhibited
)

Status types, in order of priority, low to high. Status are stored in a single integer as a bit field.

func ParseStatus

func ParseStatus(in ...string) Status

ParseStatus returns a Status from one or more strings. It does not attempt to validate the input or resolve conflicting status bits.

type Time

type Time struct {
	time.Time
}

Time represents EPP date-time values, serialized to XML in RFC-3339 format. Because the default encoding.TextMarshaler implementation in time.Time uses RFC-3339, we don’t need to create a custom marshaler for this type.

func (*Time) UnmarshalXML

func (t *Time) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements a custom XML unmarshaler that ignores time parsing errors. http://stackoverflow.com/a/25015260

Directories

Path Synopsis
cmd
epp

Jump to

Keyboard shortcuts

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