Documentation ¶
Index ¶
- func ClientXMLAttributes() []xml.Attr
- func CreateErrorResponse(code ResultCode, reason string) types.Response
- func Encode(data interface{}, xmlAttributes []xml.Attr) ([]byte, error)
- func ReadMessage(conn net.Conn) ([]byte, error)
- func ServerXMLAttributes() []xml.Attr
- func WriteMessage(conn net.Conn, data []byte) error
- type Client
- type GreetFunc
- type HandlerFunc
- type Mux
- type ResultCode
- type Server
- type Session
- type SessionConfig
- type Validator
- type XMLValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientXMLAttributes ¶
ClientXMLAttributes defines the default attributes in the client request.
func CreateErrorResponse ¶
func CreateErrorResponse(code ResultCode, reason string) types.Response
CreateErrorResponse will create a response with a given code, message and value which may be marshalled to XML and pass to WriteMessage to write a proper EPP response to the socket.
func Encode ¶
Encode will take a type that can be marshalled to XML, add the EPP staring tag for all registered namespaces and return the XML as a byte slice.
func ReadMessage ¶
ReadMessage reads one full message from r.
func ServerXMLAttributes ¶
ServerXMLAttributes defines the default attributes from the server response.
Types ¶
type Client ¶
type Client struct { // TLSConfig holds the TLS configuration that will be used when connecting // to an EPP server. TLSConfig *tls.Config // contains filtered or unexported fields }
Client represents an EPP client.
type HandlerFunc ¶
HandlerFunc represents a function for an EPP message.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux can be used to route different EPP messages to different handlers, depending on the message content.
m := Mux{} m.AddNamespaceAlias("urn:ietf:params:xml:ns:domain-1.0", "domain") m.AddHandler("hello", handleHello) m.AddHandler("command/login", handleLogin) m.AddHandler("command/check/urn:ietf:params:xml:ns:contact-1.0", handleCheckContact) m.AddHandler("command/check/domain", handleCheckDomain)
func (*Mux) AddHandler ¶
func (m *Mux) AddHandler(path string, handler HandlerFunc)
AddHandler will add a handler for the specified route. Routes are defined almost like xpath.
func (*Mux) AddNamespaceAlias ¶
AddNamespaceAlias will add an alias for the specified namespace. After the alias is added it can be used in routing. Multiple namespaces can be added to the same alias.
m.AddNamespaceAlias("urn:ietf:params:xml:ns:contact-1.0", "host-and-contact") m.AddNamespaceAlias("urn:ietf:params:xml:ns:host-1.0", "host-and-contact")
type ResultCode ¶
type ResultCode int
ResultCode represents a result code from the EPP server.
const ( EppOk ResultCode = 1000 EppOkPending ResultCode = 1001 EppOkNoMessages ResultCode = 1300 EppOkMessages ResultCode = 1301 EppOkBye ResultCode = 1500 EppUnknownCommand ResultCode = 2000 EppSyntaxError ResultCode = 2001 EppUseError ResultCode = 2002 EppMissingParam ResultCode = 2003 EppParamRangeError ResultCode = 2004 EppParamSyntaxError ResultCode = 2005 EppUnimplementedVersion ResultCode = 2100 EppUnimplementedCommand ResultCode = 2101 EppUnimplementedOption ResultCode = 2102 EppUnimplementedExtension ResultCode = 2103 EppBillingFailure ResultCode = 2104 EppNotRenewable ResultCode = 2105 EppNotTransferrable ResultCode = 2106 EppAuthenticationError ResultCode = 2200 EppAuthorisationError ResultCode = 2201 EppInvalidAuthInfo ResultCode = 2202 EppObjectPendingTransfer ResultCode = 2300 EppObjectNotPendingTransfer ResultCode = 2301 EppObjectExists ResultCode = 2302 EppObjectDoesNotExist ResultCode = 2303 EppStatusProhibitsOp ResultCode = 2304 EppAssocProhibitsOp ResultCode = 2305 EppParamPolicyError ResultCode = 2306 EppUnimplementedObjectService ResultCode = 2307 EppDataMgmtPolicyViolation ResultCode = 2308 EppCommandFailed ResultCode = 2400 EppCommandFailedBye ResultCode = 2500 EppAuthFailedBye ResultCode = 2501 EppSessionLimitExceededBye ResultCode = 2502 )
EPP constant types represents EPP result codes. For reference, see RFC5730 section 3, "Result Codes".
func (ResultCode) Code ¶
func (rs ResultCode) Code() int
Code returns the integer code for the result code.
func (ResultCode) IsBye ¶
func (rs ResultCode) IsBye() bool
IsBye returns true if the result code is a connection management result code which should terminate the connection.
func (ResultCode) Message ¶
func (rs ResultCode) Message() string
Message returns the message to be embedded along the code.
type Server ¶
type Server struct { // Addr is the address to use when listening to incomming TCP connections. // This should be set to ':700' to access incomming traffic on any interface // for the default EPP port 700. Addr string // OnStarteds holds a list of functions that will be executed after the // server has been started. OnStarteds []func() // SessionConfig holds the configuration to use for eachsession created. SessionConfig SessionConfig // TLSConfig is the server TLS config with configuration such as // certificates, client auth etcetera. TLSConfig *tls.Config // Sessions will contain all the currently active sessions. Sessions map[string]*Session // contains filtered or unexported fields }
Server represents the server handling requests.
func (*Server) ListenAndServe ¶
ListenAndServe will start the epp server.
type Session ¶
type Session struct { // ConnectionState holds the state of the TLS connection initiated while // doing the handshake with the server. ConnectionState func() tls.ConnectionState // SessionID is a unique ID to use to identify a specific session. SessionID string // Se configurables details in SessionConfig IdleTimeout time.Duration SessionTimeout time.Duration // contains filtered or unexported fields }
Session is an active connection to the EPP server.
func NewSession ¶
func NewSession(conn *tls.Conn, cfg SessionConfig) *Session
NewSession will create a new Session.
type SessionConfig ¶
type SessionConfig struct { // IdleTimeout is the maximum timeout to idle on the server before being // disconnected. Each time traffic is sent to the server the idle ticker is // reset and a new duration of IdleTimeout is allowed. IdleTimeout time.Duration // SessionTimeout is the max duration allowed for a single session. If a // client has been connected when this limit is reach it will be // disconnedted after the current command being processed has finished. SessionTimeout time.Duration // greeting holds the function that will generate the XML printed while // greeting clients connection to the server. Greeting GreetFunc // handler holds a function that will receive each request to the server. Handler HandlerFunc // validator is a type that implements the validator interface. The // validator interface should be able to validate XML against an XSD schema // (or any other way). If the validator is a non nil value all incomming // *and* outgoing data will be passed through the validator. Type // implementing this interface using libxml2 bindings is available in the // library. Validator Validator // OnCommands is a list of functions that will be executed on each command. // This is the place to put external code to handle after each command. OnCommands []func(sess *Session) }
SessionConfig represent the configuration passed to each new session being created.
type XMLValidator ¶
XMLValidator represents a validator holding the XSD schema to calidate against.
func NewValidator ¶
func NewValidator(rootXSD string) (*XMLValidator, error)
NewValidator creates a new validator.
func (*XMLValidator) Validate ¶
func (v *XMLValidator) Validate(xml []byte) error
Validate will validate XML towards the XSD schema.