Documentation ¶
Index ¶
- Constants
- func Listen(address string) (net.Listener, error)
- func NewClientMessage(clientMessageType ClientMessageType, laddr, raddr *Addr) ([]byte, error)
- func NewServiceMessage(serviceMessageType ServiceMessageType, laddr, raddr *Addr, ...) ([]byte, error)
- type Addr
- type ClientMessage
- type ClientMessageType
- type Conn
- func (c Conn) Close() error
- func (c Conn) LocalAddr() net.Addr
- func (c Conn) Read(b []byte) (n int, err error)
- func (c Conn) RemoteAddr() net.Addr
- func (c Conn) SetDeadline(t time.Time) error
- func (c Conn) SetReadDeadline(t time.Time) error
- func (c Conn) SetWriteDeadline(t time.Time) error
- func (c Conn) Write(b []byte) (n int, err error)
- type Listener
- type ServiceErrorType
- type ServiceMessage
- type ServiceMessageType
Constants ¶
const ( // ClientMessageTypeAccept is the message type sent from clients // to rdtp-service to acknowledge a notification and receive a full duplex // communication channel between the dialing caller and the rdtp port // being listened on by a client // Note: RemoteAddress **must** be defined ClientMessageTypeAccept = ClientMessageType("ACCEPT") // ClientMessageTypeDial is the message type sent from clients // to rdtp-service to "dial" a remote rdtp address // Note: RemoteAddr **must** be defined ClientMessageTypeDial = ClientMessageType("DIAL") // ClientMessageTypeListen is the message type sent from clients // to rdtp-service to "listen" for inbound connections on a local rdtp port // Note: LocalAddr **must** be defined ClientMessageTypeListen = ClientMessageType("LISTEN") // ServiceMessageTypeOK is the message type sent from rdtp-service to clients // to acknowledge their request and indicate that it was served successfully ServiceMessageTypeOK = ServiceMessageType("OK") // ServiceMessageTypeNotify is the message type sent from rdtp-service to // clients to notify them that there is a new remote client for // the client's listener ServiceMessageTypeNotify = ServiceMessageType("NOTIFY") // ServiceMessageTypeError is the message type sent from rdtp-service to // clients to acklowledge their request and indicate that there was an error ServiceMessageTypeError = ServiceMessageType("ERROR") // ServiceErrorTypeConnClosedByClient is the error type for errors caused by // the rdtp client closing the client -> rdtp-service connection ServiceErrorTypeConnClosedByClient = ServiceErrorType("CONN_CLOSED_BY_CLIENT") // ServiceErrorTypeMalformedMessage is the error type for errors // caused by the rdtp client sending a bad/malformed request ServiceErrorTypeMalformedMessage = ServiceErrorType("MALFORMED_MESSAGE") // ServiceErrorTypeInvalidMessageType is the error type for errors // caused by the rdtp client sending a message with an invalid type ServiceErrorTypeInvalidMessageType = ServiceErrorType("INVALID_MESSAGE_TYPE") // ServiceErrorTypeFailedToCreateSocket is the error type for errors caused // by the rdtp service failing to create a new socket ServiceErrorTypeFailedToCreateSocket = ServiceErrorType("CREATE_SOCKET_FAIL") // ServiceErrorTypeFailedToAttachSocket is the error type for errors caused // by the rdtp service failing to attach a created socket to the socket mgr ServiceErrorTypeFailedToAttachSocket = ServiceErrorType("ATTACH_SOCKET_FAIL") // ServiceErrorTypeFailedToAttachListener is the error type for errors caused // by the rdtp service failing to attach a created listener to the socket mgr ServiceErrorTypeFailedToAttachListener = ServiceErrorType("ATTACH_LISTENER_FAIL") // ServiceErrorTypeFailedHandshake is the error type for errors caused // by the rdtp service failing the rdtp handshake with a remote address ServiceErrorTypeFailedHandshake = ServiceErrorType("HANDSHAKE_FAILED") // ServiceErrorTypeFailedCommunication is the error type for errors caused // by the rdtp service failing to communicate with the rdtp client ServiceErrorTypeFailedCommunication = ServiceErrorType("COMMUNICATION_FAILED") )
const ( // IPProtoRDTP is the protocol number for RDTP packets over IP // The value 157 (0x9D) is unassigned as per: // https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers IPProtoRDTP = 0x9D // DiscoveryPort is the port that receives new RDTP connections DiscoveryPort = uint16(0) // MaxPort is the highest possible RDTP port number MaxPort = uint16(65535) // DefaultRDTPServiceAddr is the default rdtp service socket DefaultRDTPServiceAddr = "/var/run/rdtp.sock" )
const Network = "rdtp"
Network is the name of the RDTP network
Variables ¶
This section is empty.
Functions ¶
func NewClientMessage ¶
func NewClientMessage(clientMessageType ClientMessageType, laddr, raddr *Addr) ([]byte, error)
NewClientMessage returns a serialized client message
func NewServiceMessage ¶
func NewServiceMessage(serviceMessageType ServiceMessageType, laddr, raddr *Addr, errorType *ServiceErrorType) ([]byte, error)
NewServiceMessage returns a serialized service message
Types ¶
type Addr ¶
Addr implements the net.Addr interface https://golang.org/pkg/net/#Addr
type ClientMessage ¶
type ClientMessage struct { Type ClientMessageType `json:"type"` LocalAddr Addr `json:"local_addr"` RemoteAddr Addr `json:"remote_addr"` }
ClientMessage is the json model of a request for the rdtp service
type ClientMessageType ¶
type ClientMessageType string
ClientMessageType is the go type for client -> rdtp-service messages (requests)
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a logical communication channel between the local and remote hosts. Implements the net.Conn interface (https://golang.org/pkg/net/#Conn)
func Dial ¶
Dial returns a connection to a remote address where the remote address has a format: ${host}:${port}
func (Conn) Close ¶
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (Conn) RemoteAddr ¶
RemoteAddr returns the remote address for this conn
func (Conn) SetDeadline ¶
SetDeadline sets the deadline on the connection
func (Conn) SetReadDeadline ¶
SetReadDeadline sets the read deadline on the connection
func (Conn) SetWriteDeadline ¶
SetWriteDeadline sets the write deadline on the connection
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener listens for new inbound rdtp connections on a local rdtp port Implements the net.Listener interface https://golang.org/pkg/net/#Listener
type ServiceErrorType ¶
type ServiceErrorType string
ServiceErrorType is the go type included within a ServiceMessageType to provide more detail on failures
type ServiceMessage ¶
type ServiceMessage struct { Type ServiceMessageType `json:"type"` LocalAddr Addr `json:"local_addr"` RemoteAddr Addr `json:"remote_addr"` Error ServiceErrorType `json:"error,omitempty"` }
ServiceMessage is the json model of a message/response from the rdtp service
type ServiceMessageType ¶
type ServiceMessageType string
ServiceMessageType is the go type for rdtp-service -> client messages (responses/notifications)