tcp

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SOL_IP is not defined on darwin
	SOL_IP = 0x0

	// SOL_IPV6 is not defined on darwin
	SOL_IPV6 = 0x29
)
View Source
const BGPPORT = 179

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn is TCP connection

func Dial

func Dial(laddr, raddr *net.TCPAddr, ttl uint8, md5Secret string, noRoute bool, bindDev string) (*Conn, error)

Dial established a new TCP connection

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection

func (*Conn) LocalAddr

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

LocalAddr gets the local address

func (*Conn) Read

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

Read reads from a TCP connection

func (*Conn) RemoteAddr

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

RemoteAddr gets the remote address

func (*Conn) SetBindToDev added in v0.1.8

func (c *Conn) SetBindToDev(devName string) error

SetBindToDev sets the SO_BINDTODEVICE option

func (*Conn) SetDeadline

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

SetDeadline is here to fulfill net.Conn interface

func (*Conn) SetDontRoute

func (c *Conn) SetDontRoute() error

SetDontRoute sets the SO_DONTROUTE option

func (*Conn) SetNoDelay

func (c *Conn) SetNoDelay() error

SetNoDelay sets the TCP_NODELAY option

func (*Conn) SetReadDeadline

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

SetReadDeadline is here to fulfill net.Conn interface

func (*Conn) SetTTL

func (c *Conn) SetTTL(ttl uint8) error

SetTTL sets the TTL on a TCP connection

func (*Conn) SetWriteDeadline

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

SetWriteDeadline is here to fulfill net.Conn interface

func (*Conn) Write

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

Write writes to a TCP connection

type ConnI added in v0.1.8

type ConnI interface {
	Write(b []byte) (n int, err error)
	Read(b []byte) (n int, err error)
	Close() error
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
	SetTTL(ttl uint8) error
	SetDontRoute() error
	SetNoDelay() error
	SetBindToDev(devName string) error
}

type ConnWithVRF added in v0.1.8

type ConnWithVRF struct {
	Conn net.Conn
	VRF  *vrf.VRF
}

type Listener

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

Listener listens for TCP clients

func (*Listener) AcceptTCP

func (l *Listener) AcceptTCP() (ConnI, error)

AcceptTCP accepts a new TCP connection

func (*Listener) SetTCPMD5

func (l *Listener) SetTCPMD5(peerAddr net.IP, secret string) error

SetTCPMD5 sets a TCP md5 secret for addr

type ListenerFactory added in v0.1.8

type ListenerFactory struct{}

func NewListenerFactory added in v0.1.8

func NewListenerFactory() *ListenerFactory

func (*ListenerFactory) NewListener added in v0.1.8

func (lf *ListenerFactory) NewListener(v *vrf.VRF, laddr *net.TCPAddr, ttl uint8) (ListenerI, error)

NewListener starts a TCPListener

type ListenerFactoryI added in v0.1.8

type ListenerFactoryI interface {
	NewListener(v *vrf.VRF, laddr *net.TCPAddr, ttl uint8) (ListenerI, error)
}

type ListenerI added in v0.1.8

type ListenerI interface {
	SetTCPMD5(peerAddr net.IP, secret string) error
	AcceptTCP() (ConnI, error)
}

type ListenerManager added in v0.1.8

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

func NewListenerManager added in v0.1.8

func NewListenerManager(listenAddrsByVRF map[string][]string) *ListenerManager

func (*ListenerManager) AcceptCh added in v0.1.8

func (lm *ListenerManager) AcceptCh() chan ConnWithVRF

func (*ListenerManager) CreateListenersIfNotExists added in v0.1.8

func (lm *ListenerManager) CreateListenersIfNotExists(v *vrf.VRF) error

func (*ListenerManager) GetListeners added in v0.1.8

func (lm *ListenerManager) GetListeners(v *vrf.VRF) []ListenerI

func (*ListenerManager) ListenAddrsPerVRF added in v0.1.8

func (lm *ListenerManager) ListenAddrsPerVRF(vrf *vrf.VRF) []string

func (*ListenerManager) SetListenerFactory added in v0.1.8

func (lm *ListenerManager) SetListenerFactory(lf ListenerFactoryI)

type ListenerManagerI added in v0.1.8

type ListenerManagerI interface {
	ListenAddrsPerVRF(vrf *vrf.VRF) []string
	GetListeners(v *vrf.VRF) []ListenerI
	CreateListenersIfNotExists(v *vrf.VRF) error
	AcceptCh() chan ConnWithVRF
}

type MockConn added in v0.1.8

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

MockConn is mocked TCP connection

func NewMockConn added in v0.1.8

func NewMockConn(srcIP net.IP, srcPort uint16, dstIP net.IP, dstPort uint16) *MockConn

func (*MockConn) Close added in v0.1.8

func (c *MockConn) Close() error

func (*MockConn) LocalAddr added in v0.1.8

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

func (*MockConn) Read added in v0.1.8

func (c *MockConn) Read(b []byte) (n int, err error)

Read reads from a TCP connection

func (*MockConn) ReadFromOtherEnd added in v0.1.8

func (c *MockConn) ReadFromOtherEnd() []byte

func (*MockConn) RemoteAddr added in v0.1.8

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

func (*MockConn) SetBindToDev added in v0.1.8

func (c *MockConn) SetBindToDev(devName string) error

func (*MockConn) SetDeadline added in v0.1.8

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

SetDeadline is here to fulfill net.Conn interface

func (*MockConn) SetDontRoute added in v0.1.8

func (c *MockConn) SetDontRoute() error

func (*MockConn) SetNoDelay added in v0.1.8

func (c *MockConn) SetNoDelay() error

func (*MockConn) SetReadDeadline added in v0.1.8

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

func (*MockConn) SetTTL added in v0.1.8

func (c *MockConn) SetTTL(ttl uint8) error

func (*MockConn) SetWriteDeadline added in v0.1.8

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

func (*MockConn) Write added in v0.1.8

func (c *MockConn) Write(b []byte) (n int, err error)

Write writes to a TCP connection

func (*MockConn) WriteFromOtherEnd added in v0.1.8

func (c *MockConn) WriteFromOtherEnd(b []byte)

type MockListener added in v0.1.8

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

func (*MockListener) AcceptTCP added in v0.1.8

func (l *MockListener) AcceptTCP() (ConnI, error)

AcceptTCP accepts a new TCP connection

func (*MockListener) Connect added in v0.1.8

func (l *MockListener) Connect(addr net.IP, port uint16) *MockConn

func (*MockListener) SetTCPMD5 added in v0.1.8

func (l *MockListener) SetTCPMD5(peerAddr net.IP, secret string) error

type MockListenerFactory added in v0.1.8

type MockListenerFactory struct{}

func NewMockListenerFactory added in v0.1.8

func NewMockListenerFactory() *MockListenerFactory

func (*MockListenerFactory) NewListener added in v0.1.8

func (lf *MockListenerFactory) NewListener(v *vrf.VRF, laddr *net.TCPAddr, ttl uint8) (ListenerI, error)

Jump to

Keyboard shortcuts

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