net

package
v0.0.0-...-e4696f9 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2014 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

package net provides an interface for ipfs to interact with the network through

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer

type Dialer interface {

	// DialPeer attempts to establish a connection to a given peer
	DialPeer(context.Context, peer.Peer) error
}

Dialer represents a service that can dial out to peers (this is usually just a Network, but other services may not need the whole stack, and thus it becomes easier to mock)

type Handler

type Handler srv.Handler

Handler interface for network services.

type IpfsNetwork

type IpfsNetwork struct {

	// network context closer
	ctxc.ContextCloser
	// contains filtered or unexported fields
}

IpfsNetwork implements the Network interface,

func NewIpfsNetwork

func NewIpfsNetwork(ctx context.Context, listen []ma.Multiaddr, local peer.Peer,
	peers peer.Peerstore, pmap *mux.ProtocolMap) (*IpfsNetwork, error)

NewIpfsNetwork is the structure that implements the network interface

func (*IpfsNetwork) ClosePeer

func (n *IpfsNetwork) ClosePeer(p peer.Peer) error

ClosePeer connection to peer

func (*IpfsNetwork) DialPeer

func (n *IpfsNetwork) DialPeer(ctx context.Context, p peer.Peer) error

DialPeer attempts to establish a connection to a given peer. Respects the context.

func (*IpfsNetwork) GetBandwidthTotals

func (n *IpfsNetwork) GetBandwidthTotals() (in uint64, out uint64)

GetBandwidthTotals returns the total amount of bandwidth transferred

func (*IpfsNetwork) GetConnections

func (n *IpfsNetwork) GetConnections() []conn.Conn

GetConnections returns the networks list of open connections

func (*IpfsNetwork) GetPeerList

func (n *IpfsNetwork) GetPeerList() []peer.Peer

GetPeerList returns the networks list of connected peers

func (*IpfsNetwork) GetProtocols

func (n *IpfsNetwork) GetProtocols() *mux.ProtocolMap

GetProtocols returns the protocols registered in the network.

func (*IpfsNetwork) InterfaceListenAddresses

func (n *IpfsNetwork) InterfaceListenAddresses() ([]ma.Multiaddr, error)

InterfaceListenAddresses returns a list of addresses at which this network listens. It expands "any interface" addresses (/ip4/0.0.0.0, /ip6/::) to use the known local interfaces.

func (*IpfsNetwork) IsConnected

func (n *IpfsNetwork) IsConnected(p peer.Peer) (bool, error)

IsConnected returns whether a connection to given peer exists.

func (*IpfsNetwork) ListenAddresses

func (n *IpfsNetwork) ListenAddresses() []ma.Multiaddr

ListenAddresses returns a list of addresses at which this network listens.

func (*IpfsNetwork) SendMessage

func (n *IpfsNetwork) SendMessage(m msg.NetMessage) error

SendMessage sends given Message out

type Network

type Network interface {
	ctxc.ContextCloser

	// DialPeer attempts to establish a connection to a given peer
	DialPeer(context.Context, peer.Peer) error

	// ClosePeer connection to peer
	ClosePeer(peer.Peer) error

	// IsConnected returns whether a connection to given peer exists.
	IsConnected(peer.Peer) (bool, error)

	// GetProtocols returns the protocols registered in the network.
	GetProtocols() *mux.ProtocolMap

	// GetPeerList returns the list of peers currently connected in this network.
	GetPeerList() []peer.Peer

	// GetConnections returns the list of connections currently open in this network.
	GetConnections() []conn.Conn

	// GetBandwidthTotals returns the total number of bytes passed through
	// the network since it was instantiated
	GetBandwidthTotals() (uint64, uint64)

	// SendMessage sends given Message out
	SendMessage(msg.NetMessage) error

	// ListenAddresses returns a list of addresses at which this network listens.
	ListenAddresses() []ma.Multiaddr

	// InterfaceListenAddresses returns a list of addresses at which this network
	// listens. It expands "any interface" addresses (/ip4/0.0.0.0, /ip6/::) to
	// use the known local interfaces.
	InterfaceListenAddresses() ([]ma.Multiaddr, error)
}

Network is the interface IPFS uses for connecting to the world.

type Sender

type Sender srv.Sender

Sender interface for network services.

type Service

type Service srv.Service

Service interface for network resources.

Directories

Path Synopsis
package handshake implements the ipfs handshake protocol IPFS Handshake The IPFS Protocol Handshake is divided into three sequential steps 1.
package handshake implements the ipfs handshake protocol IPFS Handshake The IPFS Protocol Handshake is divided into three sequential steps 1.
pb
Package handshake_pb is a generated protocol buffer package.
Package handshake_pb is a generated protocol buffer package.
mux
package mux implements a protocol muxer.
package mux implements a protocol muxer.
internal/pb
Package mux_pb is a generated protocol buffer package.
Package mux_pb is a generated protocol buffer package.
internal/pb
Package service_pb is a generated protocol buffer package.
Package service_pb is a generated protocol buffer package.
package swarm implements a connection muxer with a pair of channels to synchronize all network communication.
package swarm implements a connection muxer with a pair of channels to synchronize all network communication.

Jump to

Keyboard shortcuts

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