versionhandshake

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package versionhandshake wraps a transport.{Connecter,AuthenticatedListener} to add an exchange of protocol version information on connection establishment.

The protocol version information (banner) is plain text, thus making it easy to diagnose issues with standard tools.

Index

Constants

View Source
const HandshakeMessageMaxLen = 16 * 4096
View Source
const MaxProtocolVersion = 9999

MaxProtocolVersion is the maximum allowed protocol version. This is a protocol constant, changing it may break the wire format.

Variables

This section is empty.

Functions

Types

type HandshakeConnecter

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

func Connecter

func Connecter(connecter transport.Connecter, timeout time.Duration) HandshakeConnecter

func (HandshakeConnecter) Connect

type HandshakeError

type HandshakeError struct {

	// If not nil, the underlying IO error that caused the handshake to fail.
	IOError error
	// contains filtered or unexported fields
}

A HandshakeError describes what went wrong during the handshake. It implements net.Error and is always temporary.

func DoHandshakeCurrentVersion

func DoHandshakeCurrentVersion(conn net.Conn, deadline time.Time) *HandshakeError

func DoHandshakeVersion

func DoHandshakeVersion(conn net.Conn, deadline time.Time, version int) (rErr *HandshakeError)

func (HandshakeError) Error

func (e HandshakeError) Error() string

func (HandshakeError) Temporary

func (e HandshakeError) Temporary() bool

Like with net.OpErr (Go issue 6163), a client failing to handshake should be a temporary Accept error toward the Listener .

func (HandshakeError) Timeout

func (e HandshakeError) Timeout() bool

If the underlying IOError was net.Error.Timeout(), Timeout() returns that value. Otherwise false.

type HandshakeListener

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

wrapper type that performs a a protocol version handshake before returning the connection

func (HandshakeListener) Accept

func (HandshakeListener) Addr

func (l HandshakeListener) Addr() net.Addr

func (HandshakeListener) Close

func (l HandshakeListener) Close() error

type HandshakeMessage

type HandshakeMessage struct {
	ProtocolVersion int
	Extensions      []string
}

func (*HandshakeMessage) DecodeReader

func (m *HandshakeMessage) DecodeReader(r io.Reader, maxLen int) error

func (*HandshakeMessage) Encode

func (m *HandshakeMessage) Encode() ([]byte, error)

Only returns *HandshakeError as error.

Jump to

Keyboard shortcuts

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