network

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlreadyListenedError = errors.CodeNetwork + iota
	AlreadyClosedError
	AlreadyDialingError
	AlreadyRegisteredReactorError
	AlreadyRegisteredProtocolError
	NotRegisteredReactorError
	NotRegisteredProtocolError
	NotRegisteredRoleError
	NotAuthorizedError
	NotAvailableError
	NotStartedError
	QueueOverflowError
	DuplicatedPacketError
	DuplicatedPeerError
	InvalidMessageSequenceError
	InvalidSignatureError
)
View Source
const (
	DefaultTransportNet         = "tcp4"
	DefaultDialTimeout          = 5 * time.Second
	DefaultReceiveQueueSize     = 4096
	DefaultPacketBufferSize     = 4096 //bufio.defaultBufSize=4096
	DefaultPacketPayloadMax     = 1024 * 1024
	DefaultPacketPoolNumBucket  = 20
	DefaultPacketPoolBucketLen  = 500
	DefaultDiscoveryPeriod      = 2 * time.Second
	DefaultSeedPeriod           = 3 * time.Second
	DefaultAlternateSendPeriod  = 1 * time.Second
	DefaultSendTimeout          = 5 * time.Second
	DefaultSendQueueMaxPriority = 7
	DefaultSendQueueSize        = 1000
	DefaultEventQueueSize       = 100
	DefaultPeerSendQueueSize    = 1000
	DefaultPeerPoolExpireSecond = 5
	DefaultParentsLimit         = 1
	DefaultUnclesLimit          = 1
	DefaultChildrenLimit        = 10
	DefaultNephewsLimit         = 10
	DefaultOthersLimit          = 10
	DefaultPacketRewriteLimit   = 10
	DefaultPacketRewriteDelay   = 100 * time.Millisecond
	DefaultRttAccuracy          = 10 * time.Millisecond
	DefaultRttLogTimeout        = 1 * time.Second
	DefaultRttLogThreshold      = 1 * time.Second
	DefaultFailureNodeMin       = 2
	DefaultSelectiveFloodingAdd = 1
	DefaultSimplePeerIDSize     = 4
	DefaultDuplicatedPeerTime   = 1 * time.Second
	DefaultMaxRetryClose        = 10
	AttrP2PConnectionRequest    = "P2PConnectionRequest"
	AttrP2PLegacy               = "P2PLegacy"
	AttrSupportDefaultProtocols = "SupportDefaultProtocols"
	DefaultQueryElementLength   = 200
)
View Source
const (
	SecureSuiteUnknown = iota
	SecureSuiteNone
	SecureSuiteTls
	SecureSuiteEcdhe
)
View Source
const (
	SecureAeadSuiteNone = iota
	SecureAeadSuiteChaCha20Poly1305
	SecureAeadSuiteAes128Gcm
	SecureAeadSuiteAes256Gcm
)
View Source
const (
	SecureErrorNone    = ""
	SecureErrorInvalid = "invalid"
)
View Source
const (
	AttrWaitSubProtocolInfo = "waitSubProtocolInfo"
)
View Source
const (
	LoggerFieldKeySubModule = "sub"
)

Variables

View Source
var (
	DefaultSecureEllipticCurve = elliptic.P256()
	DefaultSecureSuites        = []SecureSuite{
		SecureSuiteNone,
		SecureSuiteTls,
		SecureSuiteEcdhe,
	}
	DefaultSecureAeadSuites = []SecureAeadSuite{
		SecureAeadSuiteChaCha20Poly1305,
		SecureAeadSuiteAes128Gcm,
		SecureAeadSuiteAes256Gcm,
	}
	DefaultSecureKeyLogWriter io.Writer
)
View Source
var (
	ErrAlreadyListened           = errors.NewBase(AlreadyListenedError, "AlreadyListened")
	ErrAlreadyClosed             = errors.NewBase(AlreadyClosedError, "AlreadyClosed")
	ErrAlreadyDialing            = errors.NewBase(AlreadyDialingError, "AlreadyDialing")
	ErrAlreadyRegisteredReactor  = errors.NewBase(AlreadyRegisteredReactorError, "AlreadyRegisteredReactor")
	ErrAlreadyRegisteredProtocol = errors.NewBase(AlreadyRegisteredProtocolError, "AlreadyRegisteredProtocol")
	ErrNotRegisteredReactor      = errors.NewBase(NotRegisteredReactorError, "NotRegisteredReactor")
	ErrNotRegisteredProtocol     = errors.NewBase(NotRegisteredProtocolError, "NotRegisteredProtocol")
	ErrNotRegisteredRole         = errors.NewBase(NotRegisteredRoleError, "NotRegisteredRole")
	ErrNotAuthorized             = errors.NewBase(NotAuthorizedError, "NotAuthorized")
	ErrNotAvailable              = errors.NewBase(NotAvailableError, "NotAvailable")
	ErrNotStarted                = errors.NewBase(NotStartedError, "NotStarted")
	ErrQueueOverflow             = errors.NewBase(QueueOverflowError, "QueueOverflow")
	ErrDuplicatedPacket          = errors.NewBase(DuplicatedPacketError, "DuplicatedPacket")
	ErrDuplicatedPeer            = errors.NewBase(DuplicatedPeerError, "DuplicatedPeer")
	ErrInvalidMessageSequence    = errors.NewBase(InvalidMessageSequenceError, "InvalidMessageSequence")
	ErrInvalidSignature          = errors.NewBase(InvalidSignatureError, "InvalidSignatureError")
	ErrIllegalArgument           = errors.ErrIllegalArgument
)
View Source
var ErrInProgress = errors.NewBase(errors.UnknownError, "InProgressError")

Functions

func ChannelOfNetID

func ChannelOfNetID(id int) string

func Inspect

func Inspect(c module.Chain, informal bool) map[string]interface{}

func NewManager

func NewManager(c module.Chain, nt module.NetworkTransport, trustSeeds string, roles ...module.Role) module.NetworkManager

func NewPeerID

func NewPeerID(b []byte) module.PeerID

func NewPeerIDFromAddress

func NewPeerIDFromAddress(a module.Address) module.PeerID

func NewPeerIDFromPublicKey

func NewPeerIDFromPublicKey(k *crypto.PublicKey) module.PeerID

func NewTransport

func NewTransport(address string, w module.Wallet, l log.Logger) module.NetworkTransport

Types

type Authenticator

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

func (*Authenticator) GetSecureAeads

func (a *Authenticator) GetSecureAeads(channel string) []SecureAeadSuite

func (*Authenticator) GetSecureSuites

func (a *Authenticator) GetSecureSuites(channel string) []SecureSuite

func (*Authenticator) SetSecureAeads

func (a *Authenticator) SetSecureAeads(channel string, sas []SecureAeadSuite) error

func (*Authenticator) SetSecureSuites

func (a *Authenticator) SetSecureSuites(channel string, ss []SecureSuite) error

func (*Authenticator) Signature

func (a *Authenticator) Signature(content []byte) []byte

func (*Authenticator) VerifySignature

func (a *Authenticator) VerifySignature(publicKey []byte, signature []byte, content []byte) (module.PeerID, error)

type BytesSet

type BytesSet struct {
	*Set
	// contains filtered or unexported fields
}

func NewBytesSet

func NewBytesSet(size int) *BytesSet

func NewBytesSetFromBytes

func NewBytesSetFromBytes(b []byte, size int) (*BytesSet, []byte)

func (*BytesSet) Add

func (s *BytesSet) Add(b []byte) (r bool)

func (*BytesSet) Bytes

func (s *BytesSet) Bytes() []byte

func (*BytesSet) Contains

func (s *BytesSet) Contains(b []byte) bool

func (*BytesSet) Remove

func (s *BytesSet) Remove(b []byte) (r bool)

type ChannelNegotiator

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

func (*ChannelNegotiator) ProtocolInfos added in v1.2.9

func (cn *ChannelNegotiator) ProtocolInfos(channel string) *ProtocolInfos

type ChannelQueue

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

func (*ChannelQueue) Pop

func (q *ChannelQueue) Pop() context.Context

func (*ChannelQueue) Push

func (q *ChannelQueue) Push(c context.Context) bool

func (*ChannelQueue) Wait

func (q *ChannelQueue) Wait() <-chan context.Context

type Counter

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

func (*Counter) Close

func (c *Counter) Close() int

func (*Counter) String

func (c *Counter) String() string

type Dialer

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

func (*Dialer) Dial

func (d *Dialer) Dial(addr string) error

type Error

type Error struct {
	IsTemporary       bool
	Operation         string
	OperationArgument interface{}
	// contains filtered or unexported fields
}

func (*Error) Temporary

func (e *Error) Temporary() bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

type JoinRequest

type JoinRequest struct {
	Channel   string
	Addr      NetAddress
	Protocols []module.ProtocolInfo
}

type JoinResponse

type JoinResponse struct {
	Channel   string
	Addr      NetAddress
	Protocols []module.ProtocolInfo
}

type Listener

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

func (*Listener) Address

func (l *Listener) Address() string

func (*Listener) Close

func (l *Listener) Close() error

func (*Listener) Listen

func (l *Listener) Listen() error

func (*Listener) SetAddress

func (l *Listener) SetAddress(address string) error

type NetAddress

type NetAddress string

func (NetAddress) Validate added in v0.9.1

func (na NetAddress) Validate() error

type NetAddressSet

type NetAddressSet struct {
	*Set
	// contains filtered or unexported fields
}

func NewNetAddressSet

func NewNetAddressSet() *NetAddressSet

func (*NetAddressSet) Add

func (s *NetAddressSet) Add(a NetAddress) bool

func (*NetAddressSet) Array

func (s *NetAddressSet) Array() []NetAddress

func (*NetAddressSet) Clear

func (s *NetAddressSet) Clear()

func (*NetAddressSet) ClearAndAdd

func (s *NetAddressSet) ClearAndAdd(args ...NetAddress)

func (*NetAddressSet) Contains

func (s *NetAddressSet) Contains(a NetAddress) bool

func (*NetAddressSet) ContainsWithData added in v1.0.0

func (s *NetAddressSet) ContainsWithData(a NetAddress, d string) bool

func (*NetAddressSet) Data added in v1.0.10

func (s *NetAddressSet) Data(a NetAddress) (string, bool)

func (*NetAddressSet) Map

func (s *NetAddressSet) Map() map[NetAddress]string

func (*NetAddressSet) Merge

func (s *NetAddressSet) Merge(args ...NetAddress)

func (*NetAddressSet) RemoveData added in v1.0.0

func (s *NetAddressSet) RemoveData(a NetAddress) string

func (*NetAddressSet) SetAndRemoveByData added in v1.0.0

func (s *NetAddressSet) SetAndRemoveByData(a NetAddress, d string) (old string, removed NetAddress)

type P2PConnectionRequest

type P2PConnectionRequest struct {
	ConnType PeerConnectionType
}

type P2PConnectionResponse

type P2PConnectionResponse struct {
	ReqConnType PeerConnectionType
	ConnType    PeerConnectionType
}

type Packet

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

srcPeerId, castType, destInfo, TTL(0:unlimited)

func NewPacket

func NewPacket(pi module.ProtocolInfo, spi module.ProtocolInfo, payload []byte) *Packet

func (*Packet) Len

func (p *Packet) Len() int64

func (*Packet) ReadFrom

func (p *Packet) ReadFrom(r io.Reader) (n int64, err error)

func (*Packet) String

func (p *Packet) String() string

func (*Packet) WriteTo

func (p *Packet) WriteTo(w io.Writer) (n int64, err error)

type PacketPool

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

func NewPacketPool

func NewPacketPool(numOfBucket uint8, lenOfBucket uint16) *PacketPool

func (*PacketPool) Clear

func (p *PacketPool) Clear()

func (*PacketPool) Contains

func (p *PacketPool) Contains(pkt *Packet) bool

func (*PacketPool) Put

func (p *PacketPool) Put(pkt *Packet) bool

type PacketReader

type PacketReader struct {
	*bufio.Reader
	// contains filtered or unexported fields
}

func NewPacketReader

func NewPacketReader(rd io.Reader) *PacketReader

NewPacketReader returns a new PacketReader whose buffer has the default size.

func (*PacketReader) ReadPacket

func (pr *PacketReader) ReadPacket() (pkt *Packet, e error)

func (*PacketReader) Reset

func (pr *PacketReader) Reset(rd io.Reader)

type PacketWriter

type PacketWriter struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

func NewPacketWriter

func NewPacketWriter(w io.Writer) *PacketWriter

func (*PacketWriter) Flush

func (pw *PacketWriter) Flush() error

func (*PacketWriter) Reset

func (pw *PacketWriter) Reset(wr io.Writer)

func (*PacketWriter) Write

func (pw *PacketWriter) Write(b []byte) (int, error)

func (*PacketWriter) WritePacket

func (pw *PacketWriter) WritePacket(pkt *Packet) error

type Peer

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

func (*Peer) Channel added in v1.0.10

func (p *Peer) Channel() string

func (*Peer) Close

func (p *Peer) Close(reason string) error

func (*Peer) CloseByError

func (p *Peer) CloseByError(err error) error

func (*Peer) CloseInfo

func (p *Peer) CloseInfo() string

func (*Peer) ConnString

func (p *Peer) ConnString() string

func (*Peer) ConnType added in v1.0.10

func (p *Peer) ConnType() PeerConnectionType

func (*Peer) DialNetAddress added in v1.0.0

func (p *Peer) DialNetAddress() NetAddress

func (*Peer) EqualsAttr added in v1.0.9

func (p *Peer) EqualsAttr(k string, v interface{}) bool

func (*Peer) EqualsRole added in v1.0.10

func (p *Peer) EqualsRole(r PeerRoleFlag) bool

func (*Peer) GetAndHandleAttr added in v1.3.4

func (p *Peer) GetAndHandleAttr(k string, h func(v interface{}, exists bool) bool) (interface{}, bool)

func (*Peer) GetAttr added in v1.0.9

func (p *Peer) GetAttr(k string) (interface{}, bool)

func (*Peer) HasCloseError added in v1.0.9

func (p *Peer) HasCloseError(err error) bool

func (*Peer) HasRecvRole added in v1.0.10

func (p *Peer) HasRecvRole(r PeerRoleFlag) bool

func (*Peer) HasRole added in v1.0.10

func (p *Peer) HasRole(r PeerRoleFlag) bool

func (*Peer) ID

func (p *Peer) ID() module.PeerID

func (*Peer) In added in v1.0.10

func (p *Peer) In() bool

func (*Peer) IsClosed added in v0.9.2

func (p *Peer) IsClosed() bool

func (*Peer) NetAddress

func (p *Peer) NetAddress() NetAddress

func (*Peer) ProtocolInfos added in v1.2.9

func (p *Peer) ProtocolInfos() *ProtocolInfos

func (*Peer) PutAttr added in v1.0.9

func (p *Peer) PutAttr(k string, v interface{})

func (*Peer) RecvConnType added in v1.0.10

func (p *Peer) RecvConnType() PeerConnectionType

func (*Peer) RecvRole added in v1.0.10

func (p *Peer) RecvRole() PeerRoleFlag

func (*Peer) RemoveAttr added in v1.0.9

func (p *Peer) RemoveAttr(k string)

func (*Peer) ResetConn

func (p *Peer) ResetConn(conn net.Conn)

func (*Peer) Role added in v1.0.10

func (p *Peer) Role() PeerRoleFlag

func (*Peer) String

func (p *Peer) String() string

func (*Peer) WaitClose added in v1.0.10

func (p *Peer) WaitClose()

type PeerConnectionType

type PeerConnectionType byte

type PeerDispatcher

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

type PeerHandler

type PeerHandler interface {
	// contains filtered or unexported methods
}

type PeerIDSet

type PeerIDSet struct {
	*Set
	// contains filtered or unexported fields
}

func NewPeerIDSet

func NewPeerIDSet() *PeerIDSet

func NewPeerIDSetFromBytes

func NewPeerIDSetFromBytes(b []byte) (*PeerIDSet, []byte)

func (*PeerIDSet) Add

func (s *PeerIDSet) Add(id module.PeerID) (r bool)

func (*PeerIDSet) Array

func (s *PeerIDSet) Array() []module.PeerID

func (*PeerIDSet) Bytes

func (s *PeerIDSet) Bytes() []byte

func (*PeerIDSet) ClearAndAdd

func (s *PeerIDSet) ClearAndAdd(args ...module.PeerID)

func (*PeerIDSet) Contains

func (s *PeerIDSet) Contains(id module.PeerID) bool

func (*PeerIDSet) Merge

func (s *PeerIDSet) Merge(args ...module.PeerID)

func (*PeerIDSet) Remove

func (s *PeerIDSet) Remove(id module.PeerID) (r bool)

func (*PeerIDSet) Removes

func (s *PeerIDSet) Removes(args ...module.PeerID)

type PeerPredicate added in v0.9.2

type PeerPredicate func(*Peer) bool

type PeerRTT

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

func NewPeerRTT

func NewPeerRTT() *PeerRTT

func (*PeerRTT) Avg

func (r *PeerRTT) Avg(d time.Duration) float64

func (*PeerRTT) Last

func (r *PeerRTT) Last(d time.Duration) float64

func (*PeerRTT) Start

func (r *PeerRTT) Start()

func (*PeerRTT) StartWithAfterFunc added in v1.0.9

func (r *PeerRTT) StartWithAfterFunc(to time.Duration, f func())

func (*PeerRTT) Stop

func (r *PeerRTT) Stop() time.Duration

func (*PeerRTT) String

func (r *PeerRTT) String() string

func (*PeerRTT) Value added in v1.3.2

func (r *PeerRTT) Value() (time.Duration, time.Duration)

type PeerRoleFlag

type PeerRoleFlag byte

PeerRoleFlag as BitFlag MSB[_,_,_,_,_,_,Root,Seed]LSB

func NewPeerRoleFlag added in v1.3.4

func NewPeerRoleFlag(roles ...module.Role) PeerRoleFlag

func (PeerRoleFlag) Has

func (pr PeerRoleFlag) Has(o PeerRoleFlag) bool

func (*PeerRoleFlag) SetFlag

func (pr *PeerRoleFlag) SetFlag(o PeerRoleFlag)

func (*PeerRoleFlag) ToRoles

func (pr *PeerRoleFlag) ToRoles() []module.Role

func (*PeerRoleFlag) UnSetFlag

func (pr *PeerRoleFlag) UnSetFlag(o PeerRoleFlag)

type PeerSet

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

func NewPeerSet

func NewPeerSet() *PeerSet

func (*PeerSet) Add

func (s *PeerSet) Add(p *Peer) bool

func (*PeerSet) AddWithPredicate added in v0.9.2

func (s *PeerSet) AddWithPredicate(p *Peer, f PeerPredicate) bool

func (*PeerSet) Array

func (s *PeerSet) Array() []*Peer

func (*PeerSet) Clear

func (s *PeerSet) Clear()

func (*PeerSet) Contains

func (s *PeerSet) Contains(p *Peer) bool

func (*PeerSet) Find

func (s *PeerSet) Find(f func(p *Peer) bool) []*Peer

func (*PeerSet) FindOne added in v1.3.4

func (s *PeerSet) FindOne(f PeerPredicate) *Peer

func (*PeerSet) GetBy

func (s *PeerSet) GetBy(role PeerRoleFlag, has bool, in bool) []*Peer

func (*PeerSet) GetByID

func (s *PeerSet) GetByID(id module.PeerID) *Peer

func (*PeerSet) GetByProtocol added in v1.2.11

func (s *PeerSet) GetByProtocol(pi module.ProtocolInfo) []*Peer

func (*PeerSet) GetByRole

func (s *PeerSet) GetByRole(r PeerRoleFlag, has bool) []*Peer

func (*PeerSet) HasNetAddress added in v1.0.0

func (s *PeerSet) HasNetAddress(a NetAddress) bool

func (*PeerSet) IsEmpty added in v0.9.7

func (s *PeerSet) IsEmpty() bool

func (*PeerSet) Len added in v0.9.7

func (s *PeerSet) Len() int

func (*PeerSet) LenByProtocol added in v1.2.11

func (s *PeerSet) LenByProtocol(pi module.ProtocolInfo) int

func (*PeerSet) Merge

func (s *PeerSet) Merge(args ...*Peer)

func (*PeerSet) NetAddresses

func (s *PeerSet) NetAddresses() []NetAddress

func (*PeerSet) Remove

func (s *PeerSet) Remove(p *Peer) bool

type PeerToPeer

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

func (*PeerToPeer) EqualsRole added in v1.0.10

func (p2p *PeerToPeer) EqualsRole(r PeerRoleFlag) bool

func (*PeerToPeer) HasRole added in v1.0.10

func (p2p *PeerToPeer) HasRole(r PeerRoleFlag) bool

func (*PeerToPeer) ID added in v1.0.10

func (p2p *PeerToPeer) ID() module.PeerID

func (*PeerToPeer) IsStarted

func (p2p *PeerToPeer) IsStarted() bool

func (*PeerToPeer) NetAddress added in v1.0.10

func (p2p *PeerToPeer) NetAddress() NetAddress

func (*PeerToPeer) Role added in v1.0.10

func (p2p *PeerToPeer) Role() PeerRoleFlag

func (*PeerToPeer) Send

func (p2p *PeerToPeer) Send(pkt *Packet) error

func (*PeerToPeer) Start

func (p2p *PeerToPeer) Start()

func (*PeerToPeer) Stop

func (p2p *PeerToPeer) Stop()

type PriorityQueue

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

func NewPriorityQueue

func NewPriorityQueue(size int, maxPriority int) *PriorityQueue

func (*PriorityQueue) Available

func (q *PriorityQueue) Available(idx int) int

func (*PriorityQueue) Close

func (q *PriorityQueue) Close()

func (*PriorityQueue) Pop

func (q *PriorityQueue) Pop() context.Context

func (*PriorityQueue) Push

func (q *PriorityQueue) Push(c context.Context, idx int) bool

func (*PriorityQueue) Wait

func (q *PriorityQueue) Wait() <-chan bool

type ProtocolInfos added in v1.2.9

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

func (*ProtocolInfos) Add added in v1.2.9

func (pis *ProtocolInfos) Add(pi module.ProtocolInfo)

func (*ProtocolInfos) Array added in v1.2.9

func (pis *ProtocolInfos) Array() []module.ProtocolInfo

func (*ProtocolInfos) Exists added in v1.2.9

func (pis *ProtocolInfos) Exists(pi module.ProtocolInfo) bool

func (*ProtocolInfos) ExistsByID added in v1.2.11

func (pis *ProtocolInfos) ExistsByID(piList ...module.ProtocolInfo) bool

func (*ProtocolInfos) Len added in v1.2.9

func (pis *ProtocolInfos) Len() int

func (*ProtocolInfos) LenOfIDSet added in v1.2.9

func (pis *ProtocolInfos) LenOfIDSet() int

func (*ProtocolInfos) Remove added in v1.2.9

func (pis *ProtocolInfos) Remove(pi module.ProtocolInfo)

func (*ProtocolInfos) Resolve added in v1.2.9

func (pis *ProtocolInfos) Resolve(target *ProtocolInfos)

func (*ProtocolInfos) Set added in v1.2.9

func (pis *ProtocolInfos) Set(piList []module.ProtocolInfo)

type QueryMessage

type QueryMessage struct {
	Role PeerRoleFlag
}

type QueryResultMessage

type QueryResultMessage struct {
	Role     PeerRoleFlag
	Seeds    []NetAddress
	Roots    []NetAddress
	Children []NetAddress
	Nephews  []NetAddress
	Message  string
}

type Queue

type Queue interface {
	Push(ctx context.Context) bool
	Pop() context.Context
	Wait() <-chan bool
	Available() int
	Close()
}

func NewQueue

func NewQueue(size int) Queue

type RttMessage

type RttMessage struct {
	Last    time.Duration
	Average time.Duration
}

type SecureAead

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

func (*SecureAead) Read

func (sa *SecureAead) Read(b []byte) (n int, err error)

func (*SecureAead) Write

func (sa *SecureAead) Write(b []byte) (n int, err error)

type SecureAeadSuite

type SecureAeadSuite byte

func SecureAeadSuiteFromString

func SecureAeadSuiteFromString(s string) SecureAeadSuite

func (SecureAeadSuite) String

func (s SecureAeadSuite) String() string

type SecureConn

type SecureConn struct {
	//*tls.Conn
	net.Conn
	// contains filtered or unexported fields
}

func NewSecureConn

func NewSecureConn(conn net.Conn, sa SecureAeadSuite, k *secureKey) (*SecureConn, error)

func (*SecureConn) Read

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

func (*SecureConn) Write

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

type SecureError

type SecureError string

type SecureRequest

type SecureRequest struct {
	Channel          string
	SecureSuites     []SecureSuite
	SecureAeadSuites []SecureAeadSuite
	SecureParam      []byte
}

type SecureResponse

type SecureResponse struct {
	Channel         string
	SecureSuite     SecureSuite
	SecureAeadSuite SecureAeadSuite
	SecureParam     []byte
	SecureError     SecureError
}

type SecureSuite

type SecureSuite byte

func SecureSuiteFromString

func SecureSuiteFromString(s string) SecureSuite

func (SecureSuite) String

func (s SecureSuite) String() string

type Set

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

func NewSet

func NewSet() *Set

func (*Set) Add

func (s *Set) Add(v interface{}) bool

func (*Set) Array

func (s *Set) Array() interface{}

Not ordered array

func (*Set) Clear

func (s *Set) Clear()

func (*Set) Contains

func (s *Set) Contains(v interface{}) bool

func (*Set) IsEmpty

func (s *Set) IsEmpty() bool

func (*Set) Len

func (s *Set) Len() int

func (*Set) Map

func (s *Set) Map() map[interface{}]interface{}

func (*Set) Merge

func (s *Set) Merge(args ...interface{})

func (*Set) Remove

func (s *Set) Remove(v interface{}) bool

func (*Set) Set

func (s *Set) Set(v interface{}, d interface{}) interface{}

func (*Set) String

func (s *Set) String() string

type SignatureRequest

type SignatureRequest struct {
	PublicKey []byte
	Signature []byte
	Rtt       time.Duration
}

type SignatureResponse

type SignatureResponse struct {
	PublicKey []byte
	Signature []byte
	Rtt       time.Duration
	Error     string
}

type TimestampPool

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

func NewTimestampPool

func NewTimestampPool(numOfBucket uint8) *TimestampPool

func (*TimestampPool) Clear

func (p *TimestampPool) Clear()

func (*TimestampPool) Contains

func (p *TimestampPool) Contains(k interface{}) bool

func (*TimestampPool) Put

func (p *TimestampPool) Put(k interface{})

func (*TimestampPool) RemoveBefore

func (p *TimestampPool) RemoveBefore(secondDuration int)

type WeightQueue

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

func NewWeightQueue

func NewWeightQueue(size int, nq int) *WeightQueue

func (*WeightQueue) Available

func (q *WeightQueue) Available(idx int) int

func (*WeightQueue) Close

func (q *WeightQueue) Close()

func (*WeightQueue) Pop

func (q *WeightQueue) Pop() context.Context

func (*WeightQueue) Push

func (q *WeightQueue) Push(c context.Context, idx int) bool

func (*WeightQueue) SetWeight

func (q *WeightQueue) SetWeight(idx int, weight int) error

func (*WeightQueue) Wait

func (q *WeightQueue) Wait() <-chan bool

Jump to

Keyboard shortcuts

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