Documentation ¶
Index ¶
- Constants
- Variables
- func NewConnection(protocolRole ProtocolRole, conversation []ConversationEntry) net.Conn
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) LocalAddr() net.Addr
- func (c *Connection) Read(b []byte) (n int, err error)
- func (c *Connection) RemoteAddr() net.Addr
- func (c *Connection) SetDeadline(t time.Time) error
- func (c *Connection) SetReadDeadline(t time.Time) error
- func (c *Connection) SetWriteDeadline(t time.Time) error
- func (c *Connection) Write(b []byte) (n int, err error)
- type ConversationEntry
- type EntryType
- type ProtocolRole
Constants ¶
const ( MockNetworkMagic uint32 = 999999 MockProtocolVersionNtC uint16 = (14 + protocol.ProtocolVersionNtCOffset) MockProtocolVersionNtN uint16 = 13 MockKeepAliveCookie uint16 = 999 )
Variables ¶
var ConversationEntryHandshakeNtCResponse = ConversationEntry{ Type: EntryTypeOutput, ProtocolId: handshake.ProtocolId, IsResponse: true, OutputMessages: []protocol.Message{ handshake.NewMsgAcceptVersion( MockProtocolVersionNtC, protocol.VersionDataNtC9to14(MockNetworkMagic), ), }, }
ConversationEntryHandshakeNtCResponse is a pre-defined conversation entry for a server NtC handshake response
var ConversationEntryHandshakeNtNResponse = ConversationEntry{ Type: EntryTypeOutput, ProtocolId: handshake.ProtocolId, IsResponse: true, OutputMessages: []protocol.Message{ handshake.NewMsgAcceptVersion( MockProtocolVersionNtN, protocol.VersionDataNtN13andUp{ VersionDataNtN11to12: protocol.VersionDataNtN11to12{ CborNetworkMagic: MockNetworkMagic, CborInitiatorAndResponderDiffusionMode: protocol.DiffusionModeInitiatorOnly, CborPeerSharing: protocol.PeerSharingModeNoPeerSharing, CborQuery: protocol.QueryModeDisabled, }, }, ), }, }
ConversationEntryHandshakeNtNResponse is a pre-defined conversation entry for a server NtN handshake response
var ConversationEntryHandshakeRequestGeneric = ConversationEntry{ Type: EntryTypeInput, ProtocolId: handshake.ProtocolId, InputMessageType: handshake.MessageTypeProposeVersions, }
ConversationEntryHandshakeRequestGeneric is a pre-defined conversation event that matches a generic handshake request from a client
var ConversationEntryKeepAliveRequest = ConversationEntry{ Type: EntryTypeInput, ProtocolId: keepalive.ProtocolId, InputMessage: keepalive.NewMsgKeepAlive(MockKeepAliveCookie), MsgFromCborFunc: keepalive.NewMsgFromCbor, }
ConversationEntryKeepAliveRequest is a pre-defined conversation entry for a keep-alive request
var ConversationEntryKeepAliveResponse = ConversationEntry{ Type: EntryTypeOutput, ProtocolId: keepalive.ProtocolId, IsResponse: true, OutputMessages: []protocol.Message{ keepalive.NewMsgKeepAliveResponse(MockKeepAliveCookie), }, }
ConversationEntryKeepAliveResponse is a pre-defined conversation entry for a keep-alive response
var ConversationKeepAlive = []ConversationEntry{ ConversationEntryHandshakeRequestGeneric, ConversationEntryHandshakeNtNResponse, ConversationEntryKeepAliveRequest, ConversationEntryKeepAliveResponse, ConversationEntryKeepAliveRequest, ConversationEntryKeepAliveResponse, ConversationEntryKeepAliveRequest, ConversationEntryKeepAliveResponse, ConversationEntryKeepAliveRequest, ConversationEntryKeepAliveResponse, }
ConversationKeepAlive is a pre-defined conversation with a NtN handshake and repeated keep-alive requests and responses
var ConversationKeepAliveClose = []ConversationEntry{ ConversationEntryHandshakeRequestGeneric, ConversationEntryHandshakeNtNResponse, ConversationEntryKeepAliveRequest, ConversationEntry{ Type: EntryTypeClose, }, }
ConversationKeepAliveClose is a pre-defined conversation with a NtN handshake that will close the connection after receiving a keep-alive request
Functions ¶
func NewConnection ¶
func NewConnection( protocolRole ProtocolRole, conversation []ConversationEntry, ) net.Conn
NewConnection returns a new Connection with the provided conversation entries
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection mocks an Ouroboros connection
func (*Connection) Close ¶
func (c *Connection) Close() error
Close closes both sides of the connection. This is needed to satisfy the net.Conn interface
func (*Connection) LocalAddr ¶
func (c *Connection) LocalAddr() net.Addr
LocalAddr provides a proxy to the client-side connection's LocalAddr function. This is needed to satisfy the net.Conn interface
func (*Connection) Read ¶
func (c *Connection) Read(b []byte) (n int, err error)
Read provides a proxy to the client-side connection's Read function. This is needed to satisfy the net.Conn interface
func (*Connection) RemoteAddr ¶
func (c *Connection) RemoteAddr() net.Addr
RemoteAddr provides a proxy to the client-side connection's RemoteAddr function. This is needed to satisfy the net.Conn interface
func (*Connection) SetDeadline ¶
func (c *Connection) SetDeadline(t time.Time) error
SetDeadline provides a proxy to the client-side connection's SetDeadline function. This is needed to satisfy the net.Conn interface
func (*Connection) SetReadDeadline ¶
func (c *Connection) SetReadDeadline(t time.Time) error
SetReadDeadline provides a proxy to the client-side connection's SetReadDeadline function. This is needed to satisfy the net.Conn interface
func (*Connection) SetWriteDeadline ¶
func (c *Connection) SetWriteDeadline(t time.Time) error
SetWriteDeadline provides a proxy to the client-side connection's SetWriteDeadline function. This is needed to satisfy the net.Conn interface
type ConversationEntry ¶
type ProtocolRole ¶ added in v0.42.0
type ProtocolRole uint
ProtocolRole is an enum of the protocol roles
const ( ProtocolRoleNone ProtocolRole = 0 // Default (invalid) protocol role ProtocolRoleClient ProtocolRole = 1 // Client protocol role ProtocolRoleServer ProtocolRole = 2 // Server protocol role )
Protocol roles