berty: berty.tech/berty/go/internal/ipfsutil Index | Files

package ipfsutil

import "berty.tech/berty/go/internal/ipfsutil"

Package ipfsutil contains helpers around IPFS (logging, datastore, networking, core API, ...).

Index

Package Files

api.go collector_bandwidth.go collector_host.go conn_logger.go datastore_namespaced.go doc.go extended_core_api.go helpers.go http_api.go keystore_datastore.go localrecord.go mdns_discovery.go metrics.go pubsub_adaptater.go pubsub_api.go pubsub_monitor.go repo.go testing.go util.go

Constants

const DefaultCloseTimeout = time.Second * 5
const UnknownProtocol = "UnknownProtocol"

Variables

var DefaultSwarmListeners = []string{
    "/ip4/0.0.0.0/tcp/0",
    "/ip6/::/tcp/0",
    "/ip4/0.0.0.0/udp/0/quic",
    "/ip6/::/udp/0/quic",
}
var ErrExpectedEOF = errors.New("red data when expecting EOF")

func CreateBuildConfig Uses

func CreateBuildConfig(repo ipfs_repo.Repo, opts *CoreAPIConfig) (*ipfs_node.BuildCfg, error)

func CreateMockedRepo Uses

func CreateMockedRepo(dstore ipfs_ds.Batching) (ipfs_repo.Repo, error)

func EnableConnLogger Uses

func EnableConnLogger(ctx context.Context, logger *zap.Logger, h host.Host)

func FullClose Uses

func FullClose(s network.Stream) error

func InjectPubSubAPI Uses

func InjectPubSubAPI(api ipfs_interface.CoreAPI, ps ipfs_interface.PubSubAPI) ipfs_interface.CoreAPI

func LoadRepoFromPath Uses

func LoadRepoFromPath(path string) (ipfs_repo.Repo, error)

func MultiaddrIsEqual Uses

func MultiaddrIsEqual(a Multiaddrs, b Multiaddrs) bool

MultiaddrIsEqual return true if both slice are equal

func NewDatastoreKeystore Uses

func NewDatastoreKeystore(ds datastore.Datastore) keystore.Keystore

func NewNamespacedDatastore Uses

func NewNamespacedDatastore(child ds.Datastore, prefix ds.Key) ds.Batching

func NewPubSubAPI Uses

func NewPubSubAPI(ctx context.Context, logger *zap.Logger, disc p2p_disc.Discovery, ps *p2p_pubsub.PubSub) ipfs_interface.PubSubAPI

func OptionLocalRecord Uses

func OptionLocalRecord(node *ipfs_core.IpfsNode, api ipfs_interface.CoreAPI) error

OptionLocalRecord is given to CoreAPIOption.Options when the ipfs node setup

func OptionMDNSDiscovery Uses

func OptionMDNSDiscovery(ctx context.Context, node *ipfs_core.IpfsNode, api ipfs_interface.CoreAPI) error

func ParseAddr Uses

func ParseAddr(addr string) (ma.Multiaddr, error)

func ParseAddrs Uses

func ParseAddrs(addrs ...string) ([]ma.Multiaddr, error)

func ParseAndResolveIpfsAddr Uses

func ParseAndResolveIpfsAddr(ctx context.Context, addr string) (*peer.AddrInfo, error)

func ParseAndResolveRdvpMaddrs Uses

func ParseAndResolveRdvpMaddrs(ctx context.Context, log *zap.Logger, addrs []string) ([]*peer.AddrInfo, error)

func ServeHTTPApi Uses

func ServeHTTPApi(logger *zap.Logger, node *core.IpfsNode, rootDirectory string) error

ServeHTTPApi collects options, creates listener, prints status message and starts serving requests

func ServeHTTPWebui Uses

func ServeHTTPWebui(listenerAddr string, logger *zap.Logger) func()

func TestingRDVP Uses

func TestingRDVP(ctx context.Context, t testing.TB, h host.Host) (*rendezvous.RendezvousService, func())

func TestingRepo Uses

func TestingRepo(t testing.TB, datastore ds.Datastore) ipfs_repo.Repo

type BandwidthCollector Uses

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

func NewBandwidthCollector Uses

func NewBandwidthCollector(reporter *metrics.BandwidthCounter) *BandwidthCollector

func (*BandwidthCollector) Collect Uses

func (bc *BandwidthCollector) Collect(cmetric chan<- prometheus.Metric)

func (*BandwidthCollector) Describe Uses

func (bc *BandwidthCollector) Describe(ch chan<- *prometheus.Desc)

type ConnMgr Uses

type ConnMgr interface {
    TagPeer(peer.ID, string, int)
    UntagPeer(p peer.ID, tag string)
    Protect(id peer.ID, tag string)
    Unprotect(id peer.ID, tag string) (protected bool)
    GetTagInfo(p peer.ID) *connmgr.TagInfo
}

type CoreAPIConfig Uses

type CoreAPIConfig struct {
    BootstrapAddrs []string
    SwarmAddrs     []string
    APIAddrs       []string
    Announce       []string
    NoAnnounce     []string
    APIConfig      config.API

    DisableCorePubSub bool
    HostConfig        func(host.Host, p2p_routing.Routing) error
    ExtraLibp2pOption p2p.Option
    DHTOption         []p2p_dht.Option
    IpfsConfigPatch   IpfsConfigPatcher

    Routing ipfs_libp2p.RoutingOption
    Host    ipfs_libp2p.HostOption

    Options []CoreAPIOption
}

type CoreAPIMock Uses

type CoreAPIMock interface {
    API() ExtendedCoreAPI

    PubSub() *pubsub.PubSub
    Tinder() tinder.Driver
    MockNetwork() p2p_mocknet.Mocknet
    MockNode() *ipfs_core.IpfsNode
    Close()
}

CoreAPIMock implements ipfs.CoreAPI and adds some debugging helpers

func TestingCoreAPI Uses

func TestingCoreAPI(ctx context.Context, t testing.TB) (CoreAPIMock, func())

TestingCoreAPI returns a fully initialized mocked Core API. If you want to do some tests involving multiple peers you should use `TestingCoreAPIUsingMockNet` with the same mocknet instead.

func TestingCoreAPIUsingMockNet Uses

func TestingCoreAPIUsingMockNet(ctx context.Context, t testing.TB, opts *TestingAPIOpts) (CoreAPIMock, func())

TestingCoreAPIUsingMockNet returns a fully initialized mocked Core API with the given mocknet

type CoreAPIOption Uses

type CoreAPIOption func(context.Context, *ipfs_core.IpfsNode, ipfs_interface.CoreAPI) error

type DiscoveryNotifee Uses

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

func (*DiscoveryNotifee) HandlePeerFound Uses

func (n *DiscoveryNotifee) HandlePeerFound(pi peer.AddrInfo)

type EventMonitor Uses

type EventMonitor int
const (
    TypeEventMonitorPeerUnknown EventMonitor = iota
    TypeEventMonitorPeerJoined
    TypeEventMonitorPeerLeaved
)

type EventTracer Uses

type EventTracer interface {
    EventTracerOption() ps.Option
}

func NewPubsubMonitor Uses

func NewPubsubMonitor(l *zap.Logger, h host.Host) (EventTracer, error)

type EvtPubSubTopic Uses

type EvtPubSubTopic struct {
    EventType EventMonitor
    Topic     string
    PeerID    peer.ID
}

type ExtendedCoreAPI Uses

type ExtendedCoreAPI interface {
    ipfs_interface.CoreAPI
    ipfs_host.Host

    ConnMgr() ConnMgr
}

func InjectPubSubCoreAPIExtendedAdaptater Uses

func InjectPubSubCoreAPIExtendedAdaptater(exapi ExtendedCoreAPI, ps ipfs_interface.PubSubAPI) ExtendedCoreAPI

func NewConfigurableCoreAPI Uses

func NewConfigurableCoreAPI(ctx context.Context, bcfg *ipfs_node.BuildCfg, opts ...CoreAPIOption) (ExtendedCoreAPI, *ipfs_core.IpfsNode, error)

NewConfigurableCoreAPI returns an IPFS CoreAPI from a provided ipfs_node.BuildCfg

func NewCoreAPI Uses

func NewCoreAPI(ctx context.Context, cfg *CoreAPIConfig) (ExtendedCoreAPI, *ipfs_core.IpfsNode, error)

func NewCoreAPIFromDatastore Uses

func NewCoreAPIFromDatastore(ctx context.Context, ds ds.Batching, cfg *CoreAPIConfig) (ExtendedCoreAPI, *ipfs_core.IpfsNode, error)

func NewCoreAPIFromRepo Uses

func NewCoreAPIFromRepo(ctx context.Context, repo ipfs_repo.Repo, cfg *CoreAPIConfig) (ExtendedCoreAPI, *ipfs_core.IpfsNode, error)

func NewExtendedCoreAPI Uses

func NewExtendedCoreAPI(host ipfs_host.Host, api ipfs_interface.CoreAPI) ExtendedCoreAPI

type HostCollector Uses

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

func NewHostCollector Uses

func NewHostCollector(h host.Host) *HostCollector

func (*HostCollector) ClosedStream Uses

func (cc *HostCollector) ClosedStream(n network.Network, s network.Stream)

func (*HostCollector) Collect Uses

func (cc *HostCollector) Collect(cmetric chan<- prometheus.Metric)

func (*HostCollector) Connected Uses

func (cc *HostCollector) Connected(n network.Network, c network.Conn)

func (*HostCollector) Describe Uses

func (cc *HostCollector) Describe(ch chan<- *prometheus.Desc)

func (*HostCollector) Disconnected Uses

func (cc *HostCollector) Disconnected(n network.Network, c network.Conn)

func (*HostCollector) Listen Uses

func (cc *HostCollector) Listen(network.Network, ma.Multiaddr)

func (*HostCollector) ListenClose Uses

func (cc *HostCollector) ListenClose(network.Network, ma.Multiaddr)

func (*HostCollector) OpenedStream Uses

func (cc *HostCollector) OpenedStream(n network.Network, s network.Stream)

type IpfsConfigPatcher Uses

type IpfsConfigPatcher func(*config.Config) error

func ChainIpfsConfigPatch Uses

func ChainIpfsConfigPatch(ps ...IpfsConfigPatcher) IpfsConfigPatcher

ChainIpfsConfigPatch will execute multiple IpfsConfigPatcher from the first to the last. They can be safely be nilled and will just be ignored.

type LocalRecord Uses

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

func (*LocalRecord) ClosedStream Uses

func (lr *LocalRecord) ClosedStream(network.Network, network.Stream)

called when a stream closed

func (*LocalRecord) Connected Uses

func (lr *LocalRecord) Connected(net network.Network, c network.Conn)

called when a connection opened

func (*LocalRecord) Disconnected Uses

func (lr *LocalRecord) Disconnected(network.Network, network.Conn)

called when a connection closed

func (*LocalRecord) Listen Uses

func (lr *LocalRecord) Listen(network.Network, ma.Multiaddr)

called when network starts listening on an addr

func (*LocalRecord) ListenClose Uses

func (lr *LocalRecord) ListenClose(network.Network, ma.Multiaddr)

called when network stops listening on an addr

func (*LocalRecord) OpenedStream Uses

func (lr *LocalRecord) OpenedStream(network.Network, network.Stream)

called when a stream opened

type Multiaddrs Uses

type Multiaddrs []ma.Multiaddr

func NewMultiaddrs Uses

func NewMultiaddrs(m []ma.Multiaddr) Multiaddrs

func (Multiaddrs) Len Uses

func (ms Multiaddrs) Len() int

Len is the number of elements in the collection.

func (Multiaddrs) Less Uses

func (ms Multiaddrs) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Multiaddrs) Swap Uses

func (ms Multiaddrs) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type PubSubAPI Uses

type PubSubAPI struct {
    *p2p_pubsub.PubSub
    // contains filtered or unexported fields
}

func (*PubSubAPI) Ls Uses

func (ps *PubSubAPI) Ls(ctx context.Context) ([]string, error)

Ls lists subscribed topics by name

func (*PubSubAPI) Peers Uses

func (ps *PubSubAPI) Peers(ctx context.Context, opts ...ipfs_iopts.PubSubPeersOption) ([]p2p_peer.ID, error)

Peers list peers we are currently pubsubbing with

func (*PubSubAPI) Publish Uses

func (ps *PubSubAPI) Publish(ctx context.Context, topic string, msg []byte) error

Publish a message to a given pubsub topic

func (*PubSubAPI) Subscribe Uses

func (ps *PubSubAPI) Subscribe(ctx context.Context, topic string, opts ...ipfs_iopts.PubSubSubscribeOption) (ipfs_interface.PubSubSubscription, error)

Subscribe to messages on a given topic

type PubsubMonitor Uses

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

func (*PubsubMonitor) Emit Uses

func (pt *PubsubMonitor) Emit(e *EvtPubSubTopic)

func (*PubsubMonitor) EventTracerOption Uses

func (pt *PubsubMonitor) EventTracerOption() ps.Option

func (*PubsubMonitor) Trace Uses

func (pt *PubsubMonitor) Trace(e *ps_pb.TraceEvent)

type TestingAPIOpts Uses

type TestingAPIOpts struct {
    Logger    *zap.Logger
    Mocknet   p2p_mocknet.Mocknet
    RDVPeer   p2p_peer.AddrInfo
    Datastore ds.Batching
}

Package ipfsutil imports 70 packages (graph). Updated 2021-01-22. Refresh now. Tools for package owners.