router

package
v0.0.0-...-27cef4d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: LGPL-3.0 Imports: 18 Imported by: 9

Documentation

Index

Constants

View Source
const (
	MAGICWORD = 'R'
	HEARTBIT  = 'H'
)

MAGICWORD Start of packet

View Source
const (
	UNCOMPRESSED = uint8(0)
	COMPRESSED   = uint8(1)
)

compression types

Variables

View Source
var (
	ErrNotConnected              = errors.New("not connected")
	ErrMismatchHashSize          = errors.New("mismatch hash size")
	ErrMismatchCoordinate        = errors.New("mismatch coordinate")
	ErrNotFoundLogicalConnection = errors.New("not found logical connection")
	ErrListenFirst               = errors.New("not found listen address")
	ErrDuplicateAccept           = errors.New("cannot accept ")
	ErrNotMatchCompressionType   = errors.New("not matched compression type")
	ErrPacketNotStartedMagicword = errors.New("packet not started magicword")
	ErrInvalidIntegrity          = errors.New("invalid integrity")
	ErrNotFoundListener          = errors.New("not found listener")
	ErrCannotRequestToLocal      = errors.New("cannot request to local")
	ErrNotFoundPort              = errors.New("not found port")
	ErrCanNotConnectToEvilNode   = errors.New("can not connect to evil node")
	ErrWriteTimeout              = errors.New("write timeout")
	ErrNotHandshakeFormate       = errors.New("not handshake formate")
	ErrPeerTimeout               = errors.New("peer timeout")
)

router error list

View Source
var (
	HandshakeType = message.DefineType("handshake")
)

type define

View Source
var IEEETable = crc32.MakeTable(crc32.IEEE)

IEEETable is common table of CRC-32 polynomial.

Functions

This section is empty.

Types

type Config

type Config struct {
	Network        string
	Address        string
	Port           int
	EvilNodeConfig evilnode.Config
}

Config is router config

type Conn

type Conn interface {
	net.Conn
	ID() string
	SendHeartBit()
}

Conn is a generic stream-oriented network connection.

Multiple goroutines may invoke methods on a Conn simultaneously.

type NamedLock

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

func NewNamedLock

func NewNamedLock(title string) *NamedLock

func (*NamedLock) Lock

func (n *NamedLock) Lock(name string)

func (*NamedLock) RLock

func (n *NamedLock) RLock(name string)

func (*NamedLock) RUnlock

func (n *NamedLock) RUnlock()

func (*NamedLock) Unlock

func (n *NamedLock) Unlock()

type Router

type Router interface {
	Listen() error
	Request(addrStr string) error
	Accept() (Conn, time.Duration, error)
	Localhost() string
	EvilNodeManager() *evilnode.Manager
	Conf() *Config
	ConnList() []string
	WaitHandshackConnList() []string
}

Router that converts external connections to logical connections.

func NewRouter

func NewRouter(Config *Config, ChainCoord *common.Coordinate) (Router, error)

NewRouter is creator of router

type RouterConn

type RouterConn struct {
	Address string
	// contains filtered or unexported fields
}

func (*RouterConn) Close

func (pc *RouterConn) Close() (err error)

Close is used to sever all physical connections and logical connections related to physical connections

func (*RouterConn) ID

func (pc *RouterConn) ID() string

func (*RouterConn) LocalAddr

func (pc *RouterConn) LocalAddr() net.Addr

func (*RouterConn) LockFreeClose

func (pc *RouterConn) LockFreeClose() (err error)

LockFreeClose is used to sever all physical connections and logical connections related to physical connections without lock

func (*RouterConn) Read

func (pc *RouterConn) Read(b []byte) (int, error)

func (*RouterConn) ReadConn

func (pc *RouterConn) ReadConn() (body []byte, returnErr error)

func (*RouterConn) RemoteAddr

func (pc *RouterConn) RemoteAddr() net.Addr

func (*RouterConn) SendHeartBit

func (pc *RouterConn) SendHeartBit()

func (*RouterConn) SetDeadline

func (pc *RouterConn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.

A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.

An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.

A zero value for t means I/O operations will not time out.

func (*RouterConn) SetReadDeadline

func (pc *RouterConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.

func (*RouterConn) SetWriteDeadline

func (pc *RouterConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

func (*RouterConn) Write

func (pc *RouterConn) Write(body []byte) (int, error)

type TypeIs

type TypeIs bool
const (
	IsAccept TypeIs = TypeIs(true)
	IsDial   TypeIs = TypeIs(false)
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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