Versions in this module Expand all Collapse all v0 v0.1.0 Dec 10, 2018 Changes in this version + const ConnActionGen + const ConnActionP2P + const FuzzModeDelay + const FuzzModeDrop + const PexChannel + const Version + var ErrBinaryReadOverflow = errors.New("Error:bin binary read overflow") + var ErrSwitchDuplicatePeer = errors.New("Duplicate peer") + var ErrSwitchMaxPeersPerIPRange = errors.New("IP range has too many peers") + var PanicOnAddPeerErr = false + func AddToIPRangeCounts(counts map[string]int, ip string) map[string]int + func CheckIPRangeCounts(counts map[string]int, limits []int) bool + func Connect2Switches(switches []*Switch, i, j int) + func FuzzConn(config *viper.Viper, conn net.Conn) net.Conn + func StartSwitches(switches []*Switch) error + type AddrBook struct + func NewAddrBook(logger *zap.Logger, filePath string, routabilityStrict bool) *AddrBook + func (a *AddrBook) AddAddress(addr *NetAddress, src *NetAddress) + func (a *AddrBook) AddOurAddress(addr *NetAddress) + func (a *AddrBook) GetSelection() []*NetAddress + func (a *AddrBook) MarkAttempt(addr *NetAddress) + func (a *AddrBook) MarkBad(addr *NetAddress) + func (a *AddrBook) MarkGood(addr *NetAddress) + func (a *AddrBook) NeedMoreAddrs() bool + func (a *AddrBook) OnStart() error + func (a *AddrBook) OnStop() + func (a *AddrBook) OurAddresses() []*NetAddress + func (a *AddrBook) PickAddress(newBias int) *NetAddress + func (a *AddrBook) Save() + func (a *AddrBook) Size() int + func (a *AddrBook) String() string + type AuthorizationFunc func(nodeinfo *NodeInfo) error + type BaseReactor struct + Switch *Switch + func NewBaseReactor(logger *zap.Logger, name string, impl Reactor) *BaseReactor + func (_ *BaseReactor) AddPeer(peer *Peer) + func (_ *BaseReactor) GetChannels() []*ChannelDescriptor + func (_ *BaseReactor) Receive(chID byte, peer *Peer, msgBytes []byte) + func (_ *BaseReactor) RemovePeer(peer *Peer, reason interface{}) + func (br *BaseReactor) SetSwitch(sw *Switch) + type Channel struct + type ChannelDescriptor struct + ID byte + Priority int + RecvBufferCapacity int + RecvMessageCapacity int + SendQueueCapacity int + func (chDesc *ChannelDescriptor) FillDefaults() + type ChannelStatus struct + ID byte + Priority int + RecentlySent int64 + SendQueueCapacity int + SendQueueSize int + type ConnectionStatus struct + Channels []ChannelStatus + RecvMonitor flow.Status + SendMonitor flow.Status + type DefaultListener struct + func (l *DefaultListener) Connections() <-chan net.Conn + func (l *DefaultListener) ExternalAddress() *NetAddress + func (l *DefaultListener) InternalAddress() *NetAddress + func (l *DefaultListener) NetListener() net.Listener + func (l *DefaultListener) OnStart() error + func (l *DefaultListener) OnStop() + func (l *DefaultListener) String() string + type FilterFunc func(*crypto.PubKeyEd25519) error + type FuzzedConnection struct + func (fc *FuzzedConnection) Active() bool + func (fc *FuzzedConnection) Close() error + func (fc *FuzzedConnection) Fuzz() bool + func (fc *FuzzedConnection) LocalAddr() net.Addr + func (fc *FuzzedConnection) MaxDelayMilliseconds() int + func (fc *FuzzedConnection) Mode() string + func (fc *FuzzedConnection) ProbDropConn() float64 + func (fc *FuzzedConnection) ProbDropRW() float64 + func (fc *FuzzedConnection) ProbSleep() float64 + func (fc *FuzzedConnection) Read(data []byte) (n int, err error) + func (fc *FuzzedConnection) RemoteAddr() net.Addr + func (fc *FuzzedConnection) SetDeadline(t time.Time) error + func (fc *FuzzedConnection) SetReadDeadline(t time.Time) error + func (fc *FuzzedConnection) SetWriteDeadline(t time.Time) error + func (fc *FuzzedConnection) Write(data []byte) (n int, err error) + type IPeerErrorReporter interface + ReportPeerError func(crypto.PubKey, interface{}) + type IPeerSet interface + Get func(key string) *Peer + Has func(key string) bool + List func() []*Peer + Size func() int + type Listener interface + Connections func() <-chan net.Conn + ExternalAddress func() *NetAddress + InternalAddress func() *NetAddress + Stop func() bool + String func() string + func NewDefaultListener(logger *zap.Logger, protocol string, lAddr string, skipUPNP bool) (Listener, error) + type MConnection struct + LocalAddress *NetAddress + RemoteAddress *NetAddress + func NewMConnection(logger *zap.Logger, config *viper.Viper, conn net.Conn, ...) *MConnection + func (c *MConnection) CanSend(chID byte) bool + func (c *MConnection) OnStart() error + func (c *MConnection) OnStop() + func (c *MConnection) Send(chID byte, msg []byte) bool + func (c *MConnection) Status() ConnectionStatus + func (c *MConnection) String() string + func (c *MConnection) TrySend(chID byte, msg []byte) bool + type NetAddress struct + IP net.IP + Port uint16 + func NewNetAddress(logger *zap.Logger, addr net.Addr) *NetAddress + func NewNetAddressIPPort(ip net.IP, port uint16) *NetAddress + func NewNetAddressString(addr string) (*NetAddress, error) + func NewNetAddressStrings(addrs []string) ([]*NetAddress, error) + func (na *NetAddress) Dial() (net.Conn, error) + func (na *NetAddress) DialTimeout(timeout time.Duration) (net.Conn, error) + func (na *NetAddress) Equals(other interface{}) bool + func (na *NetAddress) Less(other interface{}) bool + func (na *NetAddress) Local() bool + func (na *NetAddress) RFC1918() bool + func (na *NetAddress) RFC3849() bool + func (na *NetAddress) RFC3927() bool + func (na *NetAddress) RFC3964() bool + func (na *NetAddress) RFC4193() bool + func (na *NetAddress) RFC4380() bool + func (na *NetAddress) RFC4843() bool + func (na *NetAddress) RFC4862() bool + func (na *NetAddress) RFC6052() bool + func (na *NetAddress) RFC6145() bool + func (na *NetAddress) ReachabilityTo(o *NetAddress) int + func (na *NetAddress) Routable() bool + func (na *NetAddress) String() string + func (na *NetAddress) Valid() bool + type NodeInfo struct + ListenAddr string + Moniker string + Network string + Other []string + PubKey crypto.PubKeyEd25519 + RemoteAddr string + SigndPubKey string + Version string + func (info *NodeInfo) CompatibleWith(other *NodeInfo) error + func (info *NodeInfo) ListenHost() string + func (info *NodeInfo) ListenPort() int + type PEXReactor struct + func NewPEXReactor(logger *zap.Logger, book *AddrBook) *PEXReactor + func (pexR *PEXReactor) AddPeer(peer *Peer) + func (pexR *PEXReactor) GetChannels() []*ChannelDescriptor + func (pexR *PEXReactor) OnStart() error + func (pexR *PEXReactor) OnStop() + func (pexR *PEXReactor) Receive(chID byte, src *Peer, msgBytes []byte) + func (pexR *PEXReactor) RemovePeer(peer *Peer, reason interface{}) + func (pexR *PEXReactor) RequestPEX(peer *Peer) + func (pexR *PEXReactor) SendAddrs(peer *Peer, addrs []*NetAddress) + type Peer struct + Data *CMap + Key string + func (p *Peer) CanSend(chID byte) bool + func (p *Peer) Connection() *MConnection + func (p *Peer) Equals(other *Peer) bool + func (p *Peer) Get(key string) interface{} + func (p *Peer) IsOutbound() bool + func (p *Peer) OnStart() error + func (p *Peer) OnStop() + func (p *Peer) Send(chID byte, msg interface{}) bool + func (p *Peer) SendBytes(chID byte, msg []byte) bool + func (p *Peer) String() string + func (p *Peer) TrySend(chID byte, msg interface{}) bool + func (p *Peer) TrySendBytes(chID byte, msg []byte) bool + func (p *Peer) WriteTo(w io.Writer) (n int64, err error) + type PeerSet struct + func NewPeerSet() *PeerSet + func (ps *PeerSet) Add(peer *Peer) error + func (ps *PeerSet) Get(peerKey string) *Peer + func (ps *PeerSet) Has(peerKey string) bool + func (ps *PeerSet) List() []*Peer + func (ps *PeerSet) Remove(peer *Peer) + func (ps *PeerSet) Size() int + type PexMessage interface + func DecodeMessage(bz []byte) (msgType byte, msg PexMessage, err error) + type Reactor interface + AddPeer func(peer *Peer) + GetChannels func() []*ChannelDescriptor + Receive func(chID byte, peer *Peer, msgBytes []byte) + RemovePeer func(peer *Peer, reason interface{}) + SetSwitch func(*Switch) + type SecretConnection struct + func MakeSecretConnection(conn io.ReadWriteCloser, locPrivKey crypto.PrivKeyEd25519) (*SecretConnection, error) + func (sc *SecretConnection) Close() error + func (sc *SecretConnection) LocalAddr() net.Addr + func (sc *SecretConnection) Read(data []byte) (n int, err error) + func (sc *SecretConnection) RemoteAddr() net.Addr + func (sc *SecretConnection) RemotePubKey() *crypto.PubKeyEd25519 + func (sc *SecretConnection) SetDeadline(t time.Time) error + func (sc *SecretConnection) SetReadDeadline(t time.Time) error + func (sc *SecretConnection) SetWriteDeadline(t time.Time) error + func (sc *SecretConnection) Write(data []byte) (n int, err error) + type Switch struct + func MakeConnectedSwitches(logger *zap.Logger, cfg *viper.Viper, n int, ...) []*Switch + func NewSwitch(logger *zap.Logger, config *viper.Viper, genesis []byte) *Switch + func (sw *Switch) AddListener(l Listener) + func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) (*Peer, error) + func (sw *Switch) AddReactor(name string, reactor Reactor) Reactor + func (sw *Switch) AddToRefuselist(pk [32]byte) error + func (sw *Switch) AuthByCA(peerInfo *NodeInfo) error + func (sw *Switch) Broadcast(chID byte, msg interface{}) chan bool + func (sw *Switch) BroadcastBytes(chID byte, msg []byte) chan bool + func (sw *Switch) DialPeerWithAddress(addr *NetAddress) (*Peer, error) + func (sw *Switch) DialSeeds(addrBook *AddrBook, seeds []string) error + func (sw *Switch) FilterConnByAddr(addr net.Addr) error + func (sw *Switch) FilterConnByPubKey(pubkey *crypto.PubKeyEd25519) error + func (sw *Switch) FilterConnByRefuselist(pubkey *crypto.PubKeyEd25519) error + func (sw *Switch) IsDialing(addr *NetAddress) bool + func (sw *Switch) IsListening() bool + func (sw *Switch) Listeners() []Listener + func (sw *Switch) NodeInfo() *NodeInfo + func (sw *Switch) NodePrivkey() crypto.PrivKeyEd25519 + func (sw *Switch) NumPeers() (outbound, inbound, dialing int) + func (sw *Switch) OnStart() error + func (sw *Switch) OnStop() + func (sw *Switch) Peers() IPeerSet + func (sw *Switch) Reactor(name string) Reactor + func (sw *Switch) Reactors() map[string]Reactor + func (sw *Switch) SetAddToRefuselist(f func([32]byte) error) + func (sw *Switch) SetAddrFilter(f func(net.Addr) error) + func (sw *Switch) SetAuthByCA(f AuthorizationFunc) + func (sw *Switch) SetGenesisUnmarshal(cb func([]byte) error) + func (sw *Switch) SetNodeInfo(nodeInfo *NodeInfo) + func (sw *Switch) SetNodePrivKey(nodePrivKey crypto.PrivKeyEd25519) + func (sw *Switch) SetPeerErrorReporter(reporter IPeerErrorReporter) + func (sw *Switch) SetPubKeyFilter(f FilterFunc) + func (sw *Switch) SetRefuseListFilter(cb func(*crypto.PubKeyEd25519) error) + func (sw *Switch) StopPeerForError(peer *Peer, reason interface{}) + func (sw *Switch) StopPeerGracefully(peer *Peer) + type SwitchEventDonePeer struct + Error interface{} + Peer *Peer + type SwitchEventNewPeer struct + Peer *Peer