go_ipfs_p2p

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 34 Imported by: 1

README

go-ipfs-p2p

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBootstrapConfig = BootstrapConfig{
	MinPeerThreshold:  4,
	Period:            30 * time.Second,
	ConnectionTimeout: (30 * time.Second) / 3,
}

DefaultBootstrapConfig specifies default sane parameters for bootstrapping.

View Source
var ErrNotEnoughBootstrapPeers = errors.New("not enough bootstrap peers to bootstrap")

ErrNotEnoughBootstrapPeers signals that we do not have enough bootstrap peers to bootstrap correctly.

Functions

func Bootstrap

func Bootstrap(id peer.ID, host host.Host, rt routing.Routing, cfg BootstrapConfig) (io.Closer, error)

Bootstrap kicks off IpfsNode bootstrapping. This function will periodically check the number of open connections and -- if there are too few -- initiate connections to well-known bootstrap peers. It also kicks off subsystem bootstrapping (i.e. routing).

Types

type BootstrapConfig

type BootstrapConfig struct {
	// MinPeerThreshold governs whether to bootstrap more connections. If the
	// node has less open connections than this number, it will open connections
	// to the bootstrap nodes. From there, the routing system should be able
	// to use the connections to the bootstrap nodes to connect to even more
	// peers. Routing systems like the IpfsDHT do so in their own Bootstrap
	// process, which issues random queries to find more peers.
	MinPeerThreshold int

	// Period governs the periodic interval at which the node will
	// attempt to bootstrap. The bootstrap process is not very expensive, so
	// this threshold can afford to be small (<=30s).
	Period time.Duration

	// ConnectionTimeout determines how long to wait for a bootstrap
	// connection attempt before cancelling it.
	ConnectionTimeout time.Duration

	// BootstrapPeers is a function that returns a set of bootstrap peers
	// for the bootstrap process to use. This makes it possible for clients
	// to control the peers the process uses at any moment.
	BootstrapPeers func() []peer.AddrInfo
}

type IdOutput

type IdOutput struct {
	ID              string
	PublicKey       string
	Addresses       []string
	AgentVersion    string
	ProtocolVersion string
}

Borrowed from ipfs code to parse the results of the command `ipfs id`

type ListenReply added in v0.0.3

type ListenReply struct {
	Protocol      string
	ListenAddress string
	TargetAddress string
}

type P2PListenerInfoOutput

type P2PListenerInfoOutput struct {
	Protocol      string
	ListenAddress string
	TargetAddress string
}

P2PListenerInfoOutput p2p monitoring or mapping information

type P2PLsOutput

type P2PLsOutput struct {
	Listeners []P2PListenerInfoOutput
}

P2PLsOutput p2p monitor or map information output

type P2pClient

type P2pClient struct {
	Host       host.Host
	P2P        *ipfsp2p.P2P
	DHT        *dht.IpfsDHT
	RoutedHost *rhost.RoutedHost
	Peers      []string
}

P2pClient p2p client

func NewP2pClient

func NewP2pClient(listenPort int, privstr string, swarmkey string, peers []string) (*P2pClient, error)

func (*P2pClient) CheckForwardHealth

func (c *P2pClient) CheckForwardHealth(proto, peerId string) error

CheckForwardHealth check if the remote node is connected

func (*P2pClient) Close

func (c *P2pClient) Close(target string) (int, error)

Close turn off p2p listening connection

func (*P2pClient) ConnectCircuit

func (c *P2pClient) ConnectCircuit(circuitPeer, targetPeer string) error

func (*P2pClient) Destroy

func (c *P2pClient) Destroy() error

Destroy: destroy and close the p2p client, including all subordinate listeners, stream objects

func (*P2pClient) Forward

func (c *P2pClient) Forward(protoOpt string, port int, peerId string) error

Forward connect p2p network to remote nodes / map to local port

func (*P2pClient) ForwardWithRandomPort added in v0.0.3

func (s *P2pClient) ForwardWithRandomPort(peerId string) (string, string, error)

func (*P2pClient) List

func (c *P2pClient) List() *P2PLsOutput

List p2p monitor message list

func (*P2pClient) ListListen added in v0.0.3

func (s *P2pClient) ListListen() ([]*ListenReply, error)

func (*P2pClient) Listen

func (c *P2pClient) Listen(proto, targetOpt string) error

Listen map local ports to p2p networks

Jump to

Keyboard shortcuts

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