Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type Conn
- type NamedLock
- type Router
- type RouterConn
- func (pc *RouterConn) Close() (err error)
- func (pc *RouterConn) ID() string
- func (pc *RouterConn) LocalAddr() net.Addr
- func (pc *RouterConn) LockFreeClose() (err error)
- func (pc *RouterConn) Read(b []byte) (int, error)
- func (pc *RouterConn) ReadConn() (body []byte, returnErr error)
- func (pc *RouterConn) RemoteAddr() net.Addr
- func (pc *RouterConn) SendHeartBit()
- func (pc *RouterConn) SetDeadline(t time.Time) error
- func (pc *RouterConn) SetReadDeadline(t time.Time) error
- func (pc *RouterConn) SetWriteDeadline(t time.Time) error
- func (pc *RouterConn) Write(body []byte) (int, error)
- type TypeIs
Constants ¶
const ( MAGICWORD = 'R' HEARTBIT = 'H' )
MAGICWORD Start of packet
const ( UNCOMPRESSED = uint8(0) COMPRESSED = uint8(1) )
compression types
Variables ¶
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
var (
HandshakeType = message.DefineType("handshake")
)
type define
var IEEETable = crc32.MakeTable(crc32.IEEE)
IEEETable is common table of CRC-32 polynomial.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
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 ¶
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.
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) 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.