fakenet

package
v0.0.0-...-168a2c3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrListenerClosed      = errors.New("listener closed")
	ErrAddressAlreadyInUse = errors.New("address already in use")
)

Errors.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	AddressString string
	NetworkString string
}

Addr is a fake network address.

func (Addr) Network

func (a Addr) Network() string

Network returns name of the network (for example, "tcp", "udp").

func (Addr) String

func (a Addr) String() string

String returns a string form of address.

type Conn

type Conn struct {
	LAddress string
	RAddress string
	Reader   *io.PipeReader
	Writer   *io.PipeWriter
}

Conn is a fake connection.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the fake connection.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

Read reads data from the fake connection.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the local network address.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. Not implemented.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. Not implemented.

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Not implemented.

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

Write writes data to the fake connection.

type Listener

type Listener struct {
	Address string
	Input   chan *Conn
	// contains filtered or unexported fields
}

Listener is a fake network listener.

func NewListener

func NewListener(address string) *Listener

NewListener creates a new fake listener.

func (*Listener) Accept

func (l *Listener) Accept() (conn net.Conn, err error)

Accept waits for and returns the next connection to the fake listener.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the listener's fake network address.

func (*Listener) Close

func (l *Listener) Close() error

Close closes the listener.

type Network

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

Network is a fake network.

func NewNetwork

func NewNetwork(listeners ...*Listener) *Network

NewNetwork creates a new fake network.

func (*Network) CreateListener

func (n *Network) CreateListener(
	network, address string) (net.Listener, error)

CreateListener returns fake listener for a specific address.

func (*Network) CreateNetConn

func (n *Network) CreateNetConn(network,
	address string, timeout time.Duration) (net.Conn, error)

CreateNetConn returns a fake connection to a fake node.

func (*Network) RandomAddress

func (n *Network) RandomAddress() string

RandomAddress creates random network address in the format address:port.

Jump to

Keyboard shortcuts

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