Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultHandshake(any) error
- func DefaultOnHandshakeSuccess(p Peer) error
- type Channel
- func (c *Channel) Close() error
- func (c *Channel) ConsumeRequests() chan *Message
- func (c *Channel) Id() uint32
- func (c *Channel) Read(b []byte) (int, error)
- func (c *Channel) RecvResponse() (*Message, error)
- func (c *Channel) SendRequest(req []byte) error
- func (c *Channel) SendResponse(res []byte) error
- func (c *Channel) Write(b []byte) (int, error)
- type Decoder
- type DefaultDecoder
- type GobDecoder
- type HandshakeFunc
- type MConn
- type Message
- type Peer
- type TCPMConn
- func (m *TCPMConn) Close() error
- func (m *TCPMConn) ConsumeMessages() <-chan []byte
- func (m *TCPMConn) GetChannel(id uint32) (*Channel, bool)
- func (m *TCPMConn) IsClosed() bool
- func (m *TCPMConn) OpenChannel() (*Channel, error)
- func (m *TCPMConn) RegisterRequestHandler(f func(*Message) error)
- func (m *TCPMConn) RemoteAddr() net.Addr
- type TCPPeer
- type TCPTransport
- type TCPTransportOpts
- type Transport
Constants ¶
View Source
const ( StartMessage = 0x0 StartStream = 0x1 )
Variables ¶
View Source
var ErrFailedHandshake = errors.New("handshake failed")
ErrFailedHandshake is returned if the handshake between the local and remote node was not successful.
Functions ¶
func DefaultHandshake ¶
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
func (*Channel) ConsumeRequests ¶
func (*Channel) RecvResponse ¶
func (*Channel) SendRequest ¶
func (*Channel) SendResponse ¶
type DefaultDecoder ¶
type DefaultDecoder struct { }
type GobDecoder ¶
type GobDecoder struct { }
type HandshakeFunc ¶
A handshake is used to verify authenticity of the connection.
type Message ¶
type Message struct { // Once we have a handshake defined we could use the // persistent public keys to identify the sender instead // of a net.Addr. From net.Addr // Payload will be some encoded bytes with the custom // message types as defined and used by the server. Payload []byte // Unique Id that determines which channel the message // was sent through. ChannelId uint32 }
A message contains arbitrary data that is sent over a transport between two nodes.
type TCPMConn ¶
type TCPMConn struct {
// contains filtered or unexported fields
}
func (*TCPMConn) ConsumeMessages ¶
func (*TCPMConn) OpenChannel ¶
func (*TCPMConn) RegisterRequestHandler ¶
func (*TCPMConn) RemoteAddr ¶
type TCPPeer ¶
type TCPPeer struct { // Embedding the MConn allows us to call it's methods // directly on the peer. MConn // contains filtered or unexported fields }
tcpPeer represents a remote node over a tcp connection.
func NewTcpPeer ¶
type TCPTransport ¶
type TCPTransport struct { TCPTransportOpts // contains filtered or unexported fields }
func NewTCPTransport ¶
func NewTCPTransport(opts TCPTransportOpts) *TCPTransport
func (*TCPTransport) Close ¶
func (t *TCPTransport) Close() error
func (*TCPTransport) Dial ¶
func (t *TCPTransport) Dial(addr string) error
func (*TCPTransport) LAddr ¶
func (t *TCPTransport) LAddr() string
func (*TCPTransport) ListenAndAccept ¶
func (t *TCPTransport) ListenAndAccept() error
func (*TCPTransport) MsgChan ¶
func (t *TCPTransport) MsgChan() <-chan Message
type TCPTransportOpts ¶
Click to show internal directories.
Click to hide internal directories.