ipfs

package module
v0.0.0-...-109c5d9 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 37 Imported by: 1

README

Concepts

Discovery

  • DHT/kadelmia. Avoid 'dual' - it gets confused. LAN/local should be kept separated, use auth.
  • mDNS local
  • also called 'signaling' in WebRTC
  • key is a SHA32 (of something), value is the address[]
  • example key: sha("/libp2p/relay") - address are nodes providing relay service

Circuits / Relay

  • IPFS network provides a number of well-known and discoverable open relays
  • useful for 'behind the NAT' - but should be used primarily for signaling
  • IMO the use or relay for data is a major flaw in IPFS/LIBP2P.

A better alternative is to use them only for push, with a larger set of nodes ( ideally all ), to initiate quic or webrtc connections. For fallback - standard TURN servers could be used.

This allows many home servers to get high speed ( no relay ).

Record store

  • Key is a public key - ideally ED25519
  • Value is a signed proto, typically a /ipfs address but it's a byte[]

Transports

webrtc

  • compatible with browsers, required
  • 'star' and 'direct'
  • /dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star/p2p/
  • start not supported in go, protocol not documented/clear

ws + mplex + noise|secio

  • primarily for use with browser-based nodes, without RTC
  • requires DNS certs (apparently for wss)

quic

  • not compatible with browsers
  • flow control on streams
  • mostly standards based

Interfaces

API

https://docs.ipfs.io/reference/http/api/

http://localhost:5001/api/v0/swarm/peers query: arg (repeated), rest are flags.

Response: JSON

Gateway

/p2p/${PEER_ID}/http/${PATH}

/p2p/${PEER_ID}/x/${PROTO}/http/${PATH}

Documentation

Index

Constants

View Source
const Protocol = "/ugate/0.0.1"

Variables

This section is empty.

Functions

func P2PAddrFromString

func P2PAddrFromString(c string) (*peer.AddrInfo, error)

Types

type IPFS

type IPFS struct {
	*IPFSConfig

	Host host.Host

	// Only set for discovery nodes.
	// Mobile/battery powered/clients use Routing
	DHT *dht.IpfsDHT

	// Combines ContentRouting, PeerRouting, ValueStore
	Routing routing.Routing // may be same as DHT
	// contains filtered or unexported fields
}

ConnectionGater, Server

func InitIPFS

func InitIPFS(auth *auth.Auth, p2pport int, mux *http.ServeMux) *IPFS

InitIPFS creates LibP2P compatible transport. Identity is based on the EC256 workload identity in auth.

Will use a select set of transports, remotely based on standards: - QUIC - WS

UGate implements H2, WebRTC variants, with a IPFS transport adapter.

func (*IPFS) Find

func (p2p *IPFS) Find(ns string)

func (*IPFS) InitEvent

func (p2p *IPFS) InitEvent()

Track events in the P2P implementation

func (*IPFS) InterceptAccept

func (p2p *IPFS) InterceptAccept(multiaddrs network.ConnMultiaddrs) (allow bool)

func (*IPFS) InterceptAddrDial

func (p2p *IPFS) InterceptAddrDial(id peer.ID, m multiaddr.Multiaddr) (allow bool)

func (*IPFS) InterceptPeerDial

func (p2p *IPFS) InterceptPeerDial(p peer.ID) (allow bool)

func (*IPFS) InterceptSecured

func (p2p *IPFS) InterceptSecured(direction network.Direction, id peer.ID, multiaddrs network.ConnMultiaddrs) (allow bool)

func (*IPFS) InterceptUpgraded

func (p2p *IPFS) InterceptUpgraded(conn network.Conn) (allow bool, reason control.DisconnectReason)

func (*IPFS) Provide

func (p2p *IPFS) Provide(ns string) error

Announce this node is a provider for the key. Normally used for IPFS, key is the sha of the content. Also used for advertise, in Discovery and autorelay.go (/libp2p/relay) According to routing.go, 24h is the normal validity, recommended 6hours refresh.

func (*IPFS) Put

func (p2p *IPFS) Put(key ed25519.PrivateKey, v []byte, seq uint64, exp time.Duration) (string, error)

Add a signed proto, key is the public key. 'IPNS' - typically the value is an ipfs address, but can be anything.

func (*IPFS) ServeHTTP

func (p2p *IPFS) ServeHTTP(w http.ResponseWriter, r *http.Request)

IPFS debug/control function

type IPFSConfig

type IPFSConfig struct {
	// If true enable the DHT functionality.
	// In this mode, we act as 'control plane'. If false, the node acts
	// as a gateway, using a CP for discovery and control.
	// The DHT requires maintaining a lot of connections, best for an internet
	// connected host - not for mobile.
	UseDHT bool
}

type PeeringService

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

PeeringService maintains connections to specified peers, reconnecting on disconnect with a back-off.

func NewPeeringService

func NewPeeringService(host host.Host) *PeeringService

NewPeeringService constructs a new peering service. Peers can be added and removed immediately, but connections won't be formed until `Start` is called.

func (*PeeringService) AddPeer

func (ps *PeeringService) AddPeer(info peer.AddrInfo)

AddPeer adds a peer to the peering service. This function may be safely called at any time: before the service is started, while running, or after it stops.

Add peer may also be called multiple times for the same peer. The new addresses will replace the old.

func (*PeeringService) RemovePeer

func (ps *PeeringService) RemovePeer(id peer.ID)

RemovePeer removes a peer from the peering service. This function may be safely called at any time: before the service is started, while running, or after it stops.

func (*PeeringService) Start

func (ps *PeeringService) Start() error

Start starts the peering service, connecting and maintaining connections to all registered peers. It returns an error if the service has already been stopped.

func (*PeeringService) Stop

func (ps *PeeringService) Stop() error

Stop stops the peering service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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