rri

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 18 Imported by: 2

README

Go RRI Package

This package provides types and functionality to send and receive RRI queries. Use this package to easily implement custom applications that interact with RRI.

Client

The RRI client can be used to connect to a RRI server, send queries and interpret the response. It also handles the connection and authentication state and automatically re-connects after a lost connection. See the following, minimal example application for a quick start guide:

package main

import (
    "log"

    "github.com/DENICeG/go-rriclient/pkg/rri"
)

func main() {
    // instantiate new RRI client and connect to server
    rriClient, err := rri.NewClient("rri.denic.de:51131", nil)
    if err != nil {
        log.Fatalln("failed to connect:", err.Error())
    }
    // close connection after you are done
    defer rriClient.Close()
    // send LOGIN query. these credentials are automatically re-used
    // when restoring a lost connection
    if err := rriClient.Login("DENIC-1000001-RRI", "secret"); err != nil {
        log.Fatalln("failed to log in:", err.Error())
    }
    // now you can use the client for any other queries
    log.Println(client.SendQuery(rri.NewInfoDomainQuery("denic.de")))
}

Pass &rri.ClientConfig{Insecure: true} as second parameter to rri.NewClient if you want to test an RRI server with self-signed certificate.

Server

You can also instantiate a RRI server to receive queries and pass them to a custom handler. The RRI server implementation in this package does not implement user authentication, business logic or response codes, it solely offers functionality to handle incoming connections and read queries from them. See the following, minimal example application:

package main

import (
    "log"

    "github.com/DENICeG/go-rriclient/pkg/rri"
)

func main() {
    // generate random server certificate and key for a mocked server.
    // for a real-world application you should use a valid certificate here
    tlsConfig, _ := rri.NewMockTLSConfig()
    // now prepare the tls listener
    rriServer, err := rri.NewServer(":51131", tlsConfig)
    if err != nil {
        log.Fatalln("failed to create server:", err.Error())
    }
    defer rriServer.Close()
    // register the handler that is called for every received query
    rriServer.Handler = func(s *Session, q *Query) (*Response, error) {
        // this method is called for every valid query.
        // malformed queries are ignored by the server
        log.Println("received query:", q)
        // return the response object that is sent to the client.
        // returning an error here will instantly close the connection
        // without sending a response the client
        return rri.NewResponse(ResultSuccess, nil), nil
    }
    // now run the listener loop to handle incoming connections and queries
    if err := rriServer.Run(); err != nil {
        log.Fatalln("failed to serve:", err.Error())
    }
}

You can use the Session parameter in your Handler func to persist information across all queries in the same TLS connection. A common use-case would be to store the username for that connection after a successful LOGIN query has been handled.

Documentation

Index

Constants

View Source
const (
	// LatestVersion denotes the latest RRI version supported by the client.
	LatestVersion Version = "4.0"

	// QueryFieldNameVersion denotes the query field name for version.
	QueryFieldNameVersion QueryFieldName = "version"
	// QueryFieldNameAction denotes the query field name for action.
	QueryFieldNameAction QueryFieldName = "action"
	// QueryFieldNameUser denotes the query field name for login user.
	QueryFieldNameUser QueryFieldName = "user"
	// QueryFieldNamePassword denotes the query field name for login password.
	QueryFieldNamePassword QueryFieldName = "password"
	// QueryFieldNameDomainIDN denotes the query field name for IDN domain name.
	QueryFieldNameDomainIDN QueryFieldName = "domain"
	// QueryFieldNameDomainACE denotes the query field name for ACE domain name.
	QueryFieldNameDomainACE QueryFieldName = "domain-ace"
	// QueryFieldNameHolder denotes the query field name for holder handle.
	QueryFieldNameHolder QueryFieldName = "holder"
	// QueryFieldNameGeneralRequest denotes the query field name for general request handle.
	QueryFieldNameGeneralRequest QueryFieldName = "generalrequest"
	// QueryFieldNameAbuseContact denotes the query field name for abuse contact handle.
	QueryFieldNameAbuseContact QueryFieldName = "abusecontact"
	// QueryFieldNameNameServer denotes the query field name for name servers.
	QueryFieldNameNameServer QueryFieldName = "nserver"
	// QueryFieldNameHandle denotes the query field name for denic handles.
	QueryFieldNameHandle QueryFieldName = "handle"
	// QueryFieldNameDisconnect denotes the query field name for disconnect.
	QueryFieldNameDisconnect QueryFieldName = "disconnect"
	// QueryFieldNameAuthInfoHash denotes the query field name for auth info hash.
	QueryFieldNameAuthInfoHash QueryFieldName = "authinfohash"
	// QueryFieldNameAuthInfoExpire denotes the query field name for auth info expire.
	QueryFieldNameAuthInfoExpire QueryFieldName = "authinfoexpire"
	// QueryFieldNameAuthInfo denotes the query field name for auth info hash.
	QueryFieldNameAuthInfo QueryFieldName = "authinfo"
	// QueryFieldNameType denotes the query field name for type.
	QueryFieldNameType QueryFieldName = "type"
	// QueryFieldNameName denotes the query field name for name.
	QueryFieldNameName QueryFieldName = "name"
	// QueryFieldNameOrganisation denotes the query field name for organisation.
	QueryFieldNameOrganisation QueryFieldName = "organisation"
	// QueryFieldNameAddress denotes the query field name for address.
	QueryFieldNameAddress QueryFieldName = "address"
	// QueryFieldNamePostalCode denotes the query field name for postalcode.
	QueryFieldNamePostalCode QueryFieldName = "postalcode"
	// QueryFieldNameCity denotes the query field name for city.
	QueryFieldNameCity QueryFieldName = "city"
	// QueryFieldNameCountryCode denotes the query field name for countrycode.
	QueryFieldNameCountryCode QueryFieldName = "countrycode"
	// QueryFieldNameEMail denotes the query field name for email.
	QueryFieldNameEMail QueryFieldName = "email"
	// QueryFieldNameMsgID denotes the query field name for a message id.
	QueryFieldNameMsgID QueryFieldName = "msgid"
	// QueryFieldNameMsgType denotes the query field name for a message type.
	QueryFieldNameMsgType QueryFieldName = "msgtype"

	// ActionLogin denotes the action value for login.
	ActionLogin QueryAction = "LOGIN"
	// ActionLogout denotes the action value for logout.
	ActionLogout QueryAction = "LOGOUT"
	// ActionCheck denotes the action value for check.
	ActionCheck QueryAction = "CHECK"
	// ActionInfo denotes the action value for info.
	ActionInfo QueryAction = "INFO"
	// ActionCreate denotes the action value for create.
	ActionCreate QueryAction = "CREATE"
	// ActionUpdate denotes the action value for update.
	ActionUpdate QueryAction = "UPDATE"
	// ActionChangeHolder denotes the action value for change holder.
	ActionChangeHolder QueryAction = "CHHOLDER"
	// ActionDelete deontes the action value for delete.
	ActionDelete QueryAction = "DELETE"
	// ActionRestore deontes the action value for restore.
	ActionRestore QueryAction = "RESTORE"
	// ActionTransit deontes the action value for transit.
	ActionTransit QueryAction = "TRANSIT"
	// ActionCreateAuthInfo1 denotes the action value for create AuthInfo1.
	ActionCreateAuthInfo1 QueryAction = "CREATE-AUTHINFO1"
	// ActionCreateAuthInfo2 denotes the action value for create AuthInfo2.
	ActionCreateAuthInfo2 QueryAction = "CREATE-AUTHINFO2"
	// ActionChangeProvider denotes the action value for change provider.
	ActionChangeProvider QueryAction = "CHPROV"
	// ActionQueueRead denotes the action value to read from the registry message queue.
	ActionQueueRead QueryAction = "QUEUE-READ"
	// ActionQueueDelete denotes the action value to delete from the registry message queue.
	ActionQueueDelete QueryAction = "QUEUE-DELETE"

	// ContactTypePerson denotes a person.
	ContactTypePerson ContactType = "PERSON"
	// ContactTypeOrganisation denotes an organisation.
	ContactTypeOrganisation ContactType = "ORG"
	// ContactTypeRequest denotes a request contact.
	ContactTypeRequest ContactType = "REQUEST"
)
View Source
const (
	// ResultSuccess denotes a successful result.
	ResultSuccess Result = "success"
	// ResultFailure dontes a failed result.
	ResultFailure Result = "failure"

	// ResponseFieldNameResult denotes the response field name for result.
	ResponseFieldNameResult ResponseFieldName = "RESULT"
	// ResponseFieldNameSTID denotes the response field name for STID.
	ResponseFieldNameSTID ResponseFieldName = "STID"
	// ResponseFieldNameInfo denotes the response field name for info message.
	ResponseFieldNameInfo ResponseFieldName = "INFO"
	// ResponseFieldNameError denotes the response field name for error message.
	ResponseFieldNameError ResponseFieldName = "ERROR"
	// ResponseFieldNameWarning denotes the response field name for warning message.
	ResponseFieldNameWarning ResponseFieldName = "WARNING"

	// ResponseEntityNameHolder denotes the entity name of a holder.
	ResponseEntityNameHolder ResponseEntityName = "holder"
)

Variables

View Source
var (
	// ErrCloseConnection can be returned by QueryHandler to gracefully close the connection to the client.
	ErrCloseConnection = fmt.Errorf("gracefully shutdown connection to client")
)

Functions

func CensorRawMessage added in v0.9.9

func CensorRawMessage(msg string) string

CensorRawMessage replaces passwords in a raw query with '******'.

func IsXML added in v0.9.9

func IsXML(msg string) bool

IsXML returns whether the message seems to contain a XML encoded query or response.

func NewMockTLSConfig

func NewMockTLSConfig() (*tls.Config, error)

NewMockTLSConfig returns a new, random TLS key and certificate pair for mock services.

DO NOT USE IN PRODUCTION!

func WithMockServer added in v0.9.1

func WithMockServer(port int, f func(server *MockServer) error) error

WithMockServer initializes and starts a mock server for the execution of f.

DO NOT USE IN PRODUCTION!

Types

type BusinessMessage added in v0.9.9

type BusinessMessage struct {
	// contains filtered or unexported fields
}

BusinessMessage represents a response message with id as returned in INFO and ERROR.

func NewBusinessMessage added in v0.9.9

func NewBusinessMessage(id int64, msg string) BusinessMessage

NewBusinessMessage creates a new BusinessMessage with id and message.

func ParseBusinessMessageKV added in v0.9.9

func ParseBusinessMessageKV(str string) (BusinessMessage, error)

ParseBusinessMessageKV parses a BusinessMessage from a single KV entry.

func (BusinessMessage) ID added in v0.9.9

func (bm BusinessMessage) ID() int64

ID returns the message id.

func (BusinessMessage) Message added in v0.9.9

func (bm BusinessMessage) Message() string

Message returns the message string.

func (BusinessMessage) String added in v0.9.9

func (bm BusinessMessage) String() string

String returns both ID and Message.

type Client

type Client struct {

	// RawQueryPrinter is called for the raw messages sent and received by the client.
	RawQueryPrinter RawQueryPrinter
	// InnerErrorPrinter is called to print uncritical errors that occur internally.
	InnerErrorPrinter ErrorPrinter
	// XMLMode controls whether the queries are sent in KeyValue or XML encoding.
	XMLMode bool
	// NoAutoRetry can be used to disable automatic retry and login after connection errors.
	NoAutoRetry bool
	// contains filtered or unexported fields
}

Client represents a stateful connection to a specific RRI Server.

func NewClient

func NewClient(address string, conf *ClientConfig) (*Client, error)

NewClient returns a new Client object for the given RRI Server.

func (*Client) Close

func (client *Client) Close() error

Close closes the underlying connection.

func (*Client) CurrentRegAccID added in v0.9.3

func (client *Client) CurrentRegAccID() (int, error)

CurrentRegAccID tries to parse the RegAccID from CurrentUser.

func (*Client) CurrentUser

func (client *Client) CurrentUser() string

CurrentUser returns the currently logged in user.

func (*Client) IsLoggedIn

func (client *Client) IsLoggedIn() bool

IsLoggedIn returns whether the client is currently logged in.

func (*Client) Login

func (client *Client) Login(username, password string) error

Login sends a login request to the server and checks for a success result.

func (*Client) Logout

func (client *Client) Logout() error

Logout sends a logout request to the server.

func (*Client) RemoteAddress

func (client *Client) RemoteAddress() string

RemoteAddress returns the RRI server address and port.

func (*Client) SendQuery

func (client *Client) SendQuery(query *Query) (*Response, error)

SendQuery sends a query to the server and returns the response.

Only technical errors are returned. You need to check Response.Result to check for RRI error responses.

func (*Client) SendRaw

func (client *Client) SendRaw(msg string) (string, error)

SendRaw sends a raw message to RRI and reads the returns the raw response.

This method should be used with caution as it does not update the client login state.

type ClientConfig added in v0.9.3

type ClientConfig struct {
	// TLSDialHandler denotes the TLS dialer to use for the instanced RRI Client. Maps tls.Dial by default.
	TLSDialHandler TLSDialer
	// Insecure allows to accept self-signed SSL certificates.
	Insecure bool
	// MinTLSVersion denotes the minimum accepted TLS version.
	MinTLSVersion uint16
}

ClientConfig can be used to further configure the RRI client.

type ContactData added in v1.11.0

type ContactData struct {
	Type         ContactType
	Name         string
	Organisation string
	Address      string
	PostalCode   string
	City         string
	CountryCode  string
	EMail        []string
}

ContactData holds information of a contact handle.

type ContactType added in v1.11.0

type ContactType string

ContactType represents the type of a contact handle.

func ParseContactType added in v1.11.0

func ParseContactType(str string) (ContactType, error)

ParseContactType parses a contact type from string.

func (ContactType) Normalize added in v1.11.0

func (t ContactType) Normalize() ContactType

Normalize returns the normalized representation of the given ContactType.

type DenicHandle added in v1.11.0

type DenicHandle struct {
	RegAccID    int
	ContactCode string
}

DenicHandle represents a handle like DENIC-1000006-SOME-CODE

func EmptyDenicHandle added in v1.11.0

func EmptyDenicHandle() DenicHandle

EmptyDenicHandle returns an empty denic handle.

func NewDenicHandle added in v1.11.0

func NewDenicHandle(regAccID int, contactCode string) DenicHandle

NewDenicHandle assembles a new denic handle.

func ParseDenicHandle added in v1.11.0

func ParseDenicHandle(str string) (DenicHandle, error)

ParseDenicHandle tries to parse a handle like DENIC-1000006-SOME-CODE. Returns an empty denic handle if str is empty.

func (DenicHandle) IsEmpty added in v1.11.0

func (h DenicHandle) IsEmpty() bool

IsEmpty returns true when the given denic handle is unset.

func (DenicHandle) String added in v1.11.0

func (h DenicHandle) String() string

type DomainData added in v0.9.9

type DomainData struct {
	HolderHandles         []DenicHandle
	GeneralRequestHandles []DenicHandle
	AbuseContactHandles   []DenicHandle
	NameServers           []string
}

DomainData holds domain information.

type ErrorPrinter added in v0.9.7

type ErrorPrinter func(err error)

ErrorPrinter is called to print uncritical errors.

type MockQueryHandler added in v0.9.1

type MockQueryHandler func(user string, session *Session, query *Query) (*Response, error)

MockQueryHandler is called for every query, except LOGIN and LOGOUT.

type MockServer added in v0.9.1

type MockServer struct {
	Handler MockQueryHandler
	// contains filtered or unexported fields
}

MockServer represents a mock RRI server with mocked user authentication.

func NewMockServer added in v0.9.1

func NewMockServer(port int) (*MockServer, error)

NewMockServer returns a mock server with user authentication for testing.

DO NOT USE IN PRODUCTION!

func (*MockServer) AddUser added in v0.9.1

func (server *MockServer) AddUser(user, pass string)

AddUser adds a new user with given password or overwrites an existing one.

func (*MockServer) Address added in v0.9.1

func (server *MockServer) Address() string

Address returns the local address to use for an RRI client.

func (*MockServer) Close added in v0.9.1

func (server *MockServer) Close() error

Close closes the underlying RRI server.

func (*MockServer) RemoveUser added in v0.9.1

func (server *MockServer) RemoveUser(user string)

RemoveUser removes a user from the authentication list.

func (*MockServer) Run added in v0.9.1

func (server *MockServer) Run() error

Run starts the underlying RRI server.

type Query

type Query struct {
	// contains filtered or unexported fields
}

Query represents a RRI request.

func NewChangeHolderQuery added in v1.10.0

func NewChangeHolderQuery(domain string, domainData DomainData) *Query

NewChangeHolderQuery returns a query to update a domain.

func NewChangeProviderQuery

func NewChangeProviderQuery(domain, authInfo string, domainData DomainData) *Query

NewChangeProviderQuery returns a query to create a domain.

func NewCheckDomainQuery

func NewCheckDomainQuery(domain string) *Query

NewCheckDomainQuery returns a check query.

func NewCheckHandleQuery

func NewCheckHandleQuery(handle DenicHandle) *Query

NewCheckHandleQuery returns a check query for a contact or request contact handle.

func NewCreateAuthInfo1Query

func NewCreateAuthInfo1Query(domain, authInfo string, expireDay time.Time) *Query

NewCreateAuthInfo1Query returns a create AuthInfo1 query.

func NewCreateAuthInfo2Query

func NewCreateAuthInfo2Query(domain string) *Query

NewCreateAuthInfo2Query returns a create AuthInfo2 query.

func NewCreateContactQuery added in v1.11.0

func NewCreateContactQuery(handle DenicHandle, contactData ContactData) *Query

NewCreateContactQuery returns a check query.

func NewCreateDomainQuery

func NewCreateDomainQuery(domain string, domainData DomainData) *Query

NewCreateDomainQuery returns a query to create a domain.

func NewDeleteDomainQuery

func NewDeleteDomainQuery(domain string) *Query

NewDeleteDomainQuery returns a delete query.

func NewInfoDomainQuery

func NewInfoDomainQuery(domain string) *Query

NewInfoDomainQuery returns an info query.

func NewInfoHandleQuery added in v0.9.3

func NewInfoHandleQuery(handle DenicHandle) *Query

NewInfoHandleQuery returns an info query for a contact or request contact handle.

func NewLoginQuery

func NewLoginQuery(username, password string) *Query

NewLoginQuery returns a login query for the given credentials.

func NewLogoutQuery

func NewLogoutQuery() *Query

NewLogoutQuery returns a logout query.

func NewQuery

func NewQuery(version Version, action QueryAction, fields QueryFieldList) *Query

NewQuery returns a query with the given parameters.

func NewQueueDeleteQuery added in v1.17.0

func NewQueueDeleteQuery(msgID, msgType string) *Query

NewQueueReadQuery returns a query to read from the registry message queue. Use msgType to delete only specific message types or use an empty string to process all message types. This is required if you want to delete the oldest message of a specific type that is not the oldest in your full queue.

func NewQueueReadQuery added in v1.17.0

func NewQueueReadQuery(msgType string) *Query

NewQueueReadQuery returns a query to read from the registry message queue. Use msgType to filter for specific message types or use an empty string to process all message types.

func NewRestoreDomainQuery

func NewRestoreDomainQuery(domain string) *Query

NewRestoreDomainQuery returns a restore query.

func NewTransitDomainQuery added in v0.9.7

func NewTransitDomainQuery(domain string, disconnect bool) *Query

NewTransitDomainQuery returns a restore query.

func NewUpdateDomainQuery

func NewUpdateDomainQuery(domain string, domainData DomainData) *Query

NewUpdateDomainQuery returns a query to update a domain.

func ParseQuery

func ParseQuery(str string) (*Query, error)

ParseQuery tries to detect the query format (KV or XML) and returns the parsed query.

func ParseQueryKV

func ParseQueryKV(str string) (*Query, error)

ParseQueryKV parses a single key-value encoded query.

func (*Query) Action

func (q *Query) Action() QueryAction

Action returns the query action.

func (*Query) EncodeKV

func (q *Query) EncodeKV() string

EncodeKV returns the Key-Value representation as used for RRI communication.

func (*Query) Field

func (q *Query) Field(fieldName QueryFieldName) []string

Field returns all values defined for a field name.

func (*Query) Fields

func (q *Query) Fields() QueryFieldList

Fields returns all additional response fields.

func (*Query) FirstField

func (q *Query) FirstField(fieldName QueryFieldName) string

FirstField returns the first field value or an empty string for a field name.

func (*Query) String

func (q *Query) String() string

String returns a human readable representation of the query.

func (*Query) Version

func (q *Query) Version() Version

Version returns the query version.

type QueryAction

type QueryAction string

QueryAction represents the action of a RRI query.

func (QueryAction) Normalize added in v0.9.1

func (q QueryAction) Normalize() QueryAction

Normalize returns the normalized representation of the given QueryAction.

type QueryField added in v0.9.1

type QueryField struct {
	Name  QueryFieldName
	Value string
}

QueryField represents a single key-value pair of a query.

type QueryFieldList added in v0.9.1

type QueryFieldList []QueryField

QueryFieldList contains an ordered list of query fields.

func NewQueryFieldList added in v0.9.9

func NewQueryFieldList() QueryFieldList

NewQueryFieldList returns an empty query field list.

func (*QueryFieldList) Add added in v0.9.1

func (l *QueryFieldList) Add(fieldName QueryFieldName, values ...string)

Add adds a sequence of values for the given field name.

func (QueryFieldList) CopyTo added in v0.9.9

func (l QueryFieldList) CopyTo(dstList *QueryFieldList)

CopyTo appends all values of this list to dstList.

func (QueryFieldList) FirstValue added in v0.9.1

func (l QueryFieldList) FirstValue(fieldName QueryFieldName) string

FirstValue returns the first field value or an empty string for a field name.

func (*QueryFieldList) RemoveAll added in v0.9.1

func (l *QueryFieldList) RemoveAll(fieldName QueryFieldName)

RemoveAll removes all values for a given field name

func (QueryFieldList) Size added in v0.9.9

func (l QueryFieldList) Size() int

Size returns the number of values stored in this list.

func (QueryFieldList) Values added in v0.9.1

func (l QueryFieldList) Values(fieldName QueryFieldName) []string

Values returns all values defined for a field name.

type QueryFieldName

type QueryFieldName string

QueryFieldName represents a single data field of a query.

func (QueryFieldName) Normalize added in v0.9.1

func (q QueryFieldName) Normalize() QueryFieldName

Normalize returns the normalized representation of the given QueryFieldName.

type QueryHandler

type QueryHandler func(*Session, *Query) (*Response, error)

QueryHandler is called for incoming RRI queryies by the server and expects a result as return value. If an error is returned instead, it is written to log and the connection is closed immmediately.

type QueryProcessor

type QueryProcessor func(*Query) *Query

QueryProcessor is used to process a query directly before sending. The returned query is sent to RRI server. Return nil to abort processing.

type RawQueryPrinter

type RawQueryPrinter func(msg string, isOutgoing bool)

RawQueryPrinter is called to print a raw outgoing or incoming query string.

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response represents an RRI response.

func NewResponse added in v0.9.9

func NewResponse(result Result, fields ResponseFieldList) *Response

NewResponse returns a new Response with the given result code.

func NewResponseWithError added in v0.9.9

func NewResponseWithError(result Result, fields ResponseFieldList, errors ...BusinessMessage) *Response

NewResponseWithError returns a new Response with the given result code and attached error messages.

func NewResponseWithInfo added in v0.9.9

func NewResponseWithInfo(result Result, fields ResponseFieldList, infos ...BusinessMessage) *Response

NewResponseWithInfo returns a new Response with the given result code and attached info messages.

func ParseResponse added in v0.9.3

func ParseResponse(str string) (*Response, error)

ParseResponse tries to detect the response format (KV or XML) and returns the parsed response.

func ParseResponseKV

func ParseResponseKV(msg string) (*Response, error)

ParseResponseKV parses a response object from the given key-value response string.

func (*Response) EncodeKV

func (r *Response) EncodeKV() string

EncodeKV returns the Key-Value representation as used for RRI communication.

func (*Response) Entities added in v1.12.0

func (r *Response) Entities() []ResponseEntity

Entities returns a list of entities contained in this response.

func (*Response) ErrorMessages added in v0.9.9

func (r *Response) ErrorMessages() []BusinessMessage

ErrorMessages returns all error messages.

func (*Response) Field

func (r *Response) Field(fieldName ResponseFieldName) []string

Field returns all values defined for a field name.

func (*Response) Fields

func (r *Response) Fields() ResponseFieldList

Fields returns all additional response fields.

func (*Response) FirstField

func (r *Response) FirstField(fieldName ResponseFieldName) string

FirstField returns the first field value or an empty string for a field name.

func (*Response) InfoMessages added in v0.9.9

func (r *Response) InfoMessages() []BusinessMessage

InfoMessages returns all info messages.

func (*Response) IsSuccessful

func (r *Response) IsSuccessful() bool

IsSuccessful returns whether the response is successfull.

func (*Response) Result

func (r *Response) Result() Result

Result returns the returned result.

func (*Response) STID added in v0.9.9

func (r *Response) STID() string

STID return the server transaction id.

func (*Response) String added in v0.9.3

func (r *Response) String() string

String returns a human readable representation of the response.

func (*Response) WarningMessages added in v1.17.0

func (r *Response) WarningMessages() []BusinessMessage

WarningMessages returns all warning messages.

type ResponseEntity added in v1.12.0

type ResponseEntity struct {
	// contains filtered or unexported fields
}

ResponseEntity is used to encapsulate further information.

func (*ResponseEntity) Field added in v1.12.0

func (e *ResponseEntity) Field(fieldName ResponseFieldName) []string

Field returns all values defined for a field name.

func (*ResponseEntity) Fields added in v1.12.0

func (e *ResponseEntity) Fields() ResponseFieldList

Fields returns all additional response entity fields.

func (*ResponseEntity) FirstField added in v1.12.0

func (e *ResponseEntity) FirstField(fieldName ResponseFieldName) string

FirstField returns the first field value or an empty string for a field name.

func (*ResponseEntity) Name added in v1.12.0

Name return the name of this response entity.

type ResponseEntityName added in v0.9.1

type ResponseEntityName string

ResponseEntityName represents a response entity name.

func (ResponseEntityName) Normalize added in v0.9.1

func (r ResponseEntityName) Normalize() ResponseEntityName

Normalize returns the normalized representation of the given ResponseEntityName.

type ResponseField added in v0.9.1

type ResponseField struct {
	Name  ResponseFieldName
	Value string
}

ResponseField represents a single key-value pair of a query.

type ResponseFieldList added in v0.9.1

type ResponseFieldList []ResponseField

ResponseFieldList contains an ordered list of query fields.

func NewResponseFieldList added in v0.9.9

func NewResponseFieldList() ResponseFieldList

NewResponseFieldList returns an empty response field list.

func (*ResponseFieldList) Add added in v0.9.1

func (l *ResponseFieldList) Add(fieldName ResponseFieldName, values ...string)

Add adds a sequence of values for the given field name.

func (ResponseFieldList) CopyTo added in v0.9.9

func (l ResponseFieldList) CopyTo(dstList *ResponseFieldList)

CopyTo appends all values of this list to dstList.

func (ResponseFieldList) FirstValue added in v0.9.1

func (l ResponseFieldList) FirstValue(fieldName ResponseFieldName) string

FirstValue returns the first field value or an empty string for a field name.

func (*ResponseFieldList) RemoveAll added in v0.9.1

func (l *ResponseFieldList) RemoveAll(fieldName ResponseFieldName)

RemoveAll removes all values for a given field name

func (ResponseFieldList) Size added in v0.9.9

func (l ResponseFieldList) Size() int

Size returns the number of values stored in this list.

func (ResponseFieldList) Values added in v0.9.1

func (l ResponseFieldList) Values(fieldName ResponseFieldName) []string

Values returns all values defined for a field name.

type ResponseFieldName

type ResponseFieldName string

ResponseFieldName represents the field name of a query response.

func (ResponseFieldName) Normalize added in v0.9.1

func (r ResponseFieldName) Normalize() ResponseFieldName

Normalize returns the normalized representation of the given ResponseFieldName.

type Result

type Result string

Result represents the result of a query response.

func (Result) Normalize added in v0.9.1

func (r Result) Normalize() Result

Normalize returns the normalized representation of the given Result.

type Server

type Server struct {
	Handler QueryHandler
	// contains filtered or unexported fields
}

Server represents a basic RRI client to receive RRI queries and send responses.

func NewServer

func NewServer(listenAddress string, tlsConfig *tls.Config) (*Server, error)

NewServer returns a new RRI server for the given TLS config listening on the given port.

func (*Server) Close

func (srv *Server) Close() error

Close gracefully shuts down the server.

func (*Server) Run

func (srv *Server) Run() error

Run starts accepting client connections to pass to the configured query handler and blocks until the server is stopped.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is used to keep the state of an RRI connection.

func (*Session) Get

func (s *Session) Get(key string) (interface{}, bool)

Get returns a value previously set for the current session.

func (*Session) GetBool

func (s *Session) GetBool(key string) (bool, bool)

GetBool returns a boolean value previously set for the current session.

func (*Session) GetInt

func (s *Session) GetInt(key string) (int, bool)

GetInt returns an integer value previously set for the current session.

func (*Session) GetString

func (s *Session) GetString(key string) (string, bool)

GetString returns a string value previously set for the current session.

func (*Session) Set

func (s *Session) Set(key string, value interface{})

Set sets a value for the current session across multiple queries.

type TLSConnection added in v0.9.9

type TLSConnection interface {
	io.ReadWriteCloser
}

TLSConnection wraps a TLS connection as denoted by *tls.Conn.

type TLSDialer added in v0.9.9

type TLSDialer func(network, addr string, config *tls.Config) (TLSConnection, error)

TLSDialer is the callback function to open a new TLS connection. Maps tls.Dial by default.

type Version

type Version string

Version represents the RRI protocol version.

func (Version) Normalize added in v0.9.1

func (v Version) Normalize() Version

Normalize returns the normalized representation of the given Version.

Jump to

Keyboard shortcuts

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