peerserver

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: ISC Imports: 29 Imported by: 0

Documentation

Overview

Copyright (c) 2020-2021 The bitcoinpay developers Copyright (c) 2013-2016 The btcsuite developers Copyright (c) 2015-2018 The Decred developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020-2021 The bitcoinpay developers Copyright (c) 2013-2016 The btcsuite developers Copyright (c) 2015-2018 The Decred developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020-2021 The bitcoinpay developers Copyright (c) 2013-2016 The btcsuite developers Copyright (c) 2015-2018 The Decred developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020-2021 The bitcoinpay developers Copyright (c) 2013-2016 The btcsuite developers Copyright (c) 2015-2018 The Decred developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020-2021 The bitcoinpay developers Copyright (c) 2013-2016 The btcsuite developers Copyright (c) 2015-2018 The Decred developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Just enough UPnP to be able to forward ports

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BanPeerMsg

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

type NAT

type NAT interface {
	// Get the external address from outside the NAT.
	GetExternalAddress() (addr net.IP, err error)
	// Add a port mapping for protocol ("udp" or "tcp") from externalport to
	// internal port with description lasting for timeout.
	AddPortMapping(protocol string, externalPort, internalPort int, description string, timeout int) (mappedExternalPort int, err error)
	// Remove a previously added port mapping from externalport to
	// internal port.
	DeletePortMapping(protocol string, externalPort, internalPort int) (err error)
}

NAT is an interface representing a NAT traversal options for example UPNP or NAT-PMP. It provides methods to query and manipulate this traversal to allow access to services.

func Discover

func Discover() (nat NAT, err error)

Discover searches the local network for a UPnP router returning a NAT for the network if so, nil if not.

type PeerServer

type PeerServer struct {
	TimeSource   blockchain.MedianTimeSource
	BlockManager *blkmgr.BlockManager
	TxMemPool    *mempool.TxPool
	// contains filtered or unexported fields
}

Use start to begin accepting connections from peers. peer server handling communications to and from bitcoinpay peers.

func NewPeerServer

func NewPeerServer(cfg *config.Config, chainParams *params.Params) (*PeerServer, error)

func (*PeerServer) AddBytesReceived

func (s *PeerServer) AddBytesReceived(bytesReceived uint64)

AddBytesReceived adds the passed number of bytes to the total bytes received counter for the server. It is safe for concurrent access.

func (*PeerServer) AddBytesSent

func (s *PeerServer) AddBytesSent(bytesSent uint64)

AddBytesSent adds the passed number of bytes to the total bytes sent counter for the server. It is safe for concurrent access.

func (*PeerServer) AddPeer

func (s *PeerServer) AddPeer(sp *serverPeer)

AddPeer adds a new peer that has already been connected to the server.

func (*PeerServer) BanPeer

func (s *PeerServer) BanPeer(msg *BanPeerMsg)

BanPeer bans a peer that has already been connected to the server by ip.

func (*PeerServer) BroadcastMessage

func (s *PeerServer) BroadcastMessage(msg message.Message, exclPeers ...*serverPeer)

func (*PeerServer) ConnectedCount

func (s *PeerServer) ConnectedCount() int32

ConnectedCount returns the number of currently connected peers.

func (*PeerServer) ConnectedPeers

func (s *PeerServer) ConnectedPeers() []*serverPeer

ConnectedPeers returns an array consisting of all connected peers.

func (*PeerServer) Dial

func (s *PeerServer) Dial(network, addr string) (net.Conn, error)

Dial connects to the address on the named network.

func (*PeerServer) GetBanlist

func (s *PeerServer) GetBanlist() map[string]time.Time

func (*PeerServer) HasPeer

func (s *PeerServer) HasPeer(uuid uuid.UUID) bool

Whether it has peer.

func (*PeerServer) OutboundGroupCount

func (s *PeerServer) OutboundGroupCount(key string) int

OutboundGroupCount returns the number of peers connected to the given outbound group key.

func (*PeerServer) RelayInventory

func (s *PeerServer) RelayInventory(invVect *message.InvVect, data interface{})

RelayInventory relays the passed inventory vector to all connected peers that are not already known to have it.

func (*PeerServer) RemoveBan

func (s *PeerServer) RemoveBan(host string)

func (*PeerServer) Start

func (p *PeerServer) Start() error

func (*PeerServer) Stop

func (p *PeerServer) Stop() error

Jump to

Keyboard shortcuts

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