identify

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: MIT Imports: 19 Imported by: 107

Documentation

Index

Constants

View Source
const ID = "/ipfs/id/1.0.0"

ID is the protocol.ID of the Identify Service.

View Source
const IDDelta = "/p2p/id/delta/1.0.0"
View Source
const IDPush = "/ipfs/id/push/1.0.0"

IDPush is the protocol.ID of the Identify push protocol. It sends full identify messages containing the current state of the peer.

It is in the process of being replaced by identify delta, which sends only diffs for better resource utilisation.

View Source
const LibP2PVersion = "ipfs/0.1.0"

LibP2PVersion holds the current protocol version for a client running this code TODO(jbenet): fix the versioning mess. XXX: Don't change this till 2020. You'll break all go-ipfs versions prior to 0.4.17 which asserted an exact version match.

Variables

View Source
var ActivationThresh = 4

ActivationThresh sets how many times an address must be seen as "activated" and therefore advertised to other peers as an address that the local peer can be contacted on. The "seen" events expire by default after 40 minutes (OwnObservedAddressTTL * ActivationThreshold). The are cleaned up during the GC rounds set by GCInterval.

View Source
var ClientVersion = "github.com/libp2p/go-libp2p"

ClientVersion is the default user agent.

Deprecated: Set this with the UserAgent option.

View Source
var GCInterval = 10 * time.Minute

GCInterval specicies how often to make a round cleaning seen events and observed addresses. An address will be cleaned if it has not been seen in OwnObservedAddressTTL (10 minutes). A "seen" event will be cleaned up if it is older than OwnObservedAddressTTL * ActivationThresh (40 minutes).

Functions

func HasConsistentTransport

func HasConsistentTransport(a ma.Multiaddr, green []ma.Multiaddr) bool

HasConsistentTransport returns true if the address 'a' shares a protocol set with any address in the green set. This is used to check if a given address might be one of the addresses a peer is listening on.

Types

type IDService

type IDService struct {
	Host      host.Host
	UserAgent string
	// contains filtered or unexported fields
}

IDService is a structure that implements ProtocolIdentify. It is a trivial service that gives the other peer some useful information about the local peer. A sort of hello.

The IDService sends:

  • Our IPFS Protocol Version
  • Our IPFS Agent Version
  • Our public Listen Addresses

func NewIDService

func NewIDService(ctx context.Context, h host.Host, opts ...Option) *IDService

NewIDService constructs a new *IDService and activates it by attaching its stream handler to the given host.Host.

func (*IDService) IdentifyConn

func (ids *IDService) IdentifyConn(c network.Conn)

func (*IDService) IdentifyWait

func (ids *IDService) IdentifyWait(c network.Conn) <-chan struct{}

IdentifyWait returns a channel which will be closed once "ProtocolIdentify" (handshake3) finishes on given conn. This happens async so the connection can start to be used even if handshake3 knowledge is not necessary. Users **MUST** call IdentifyWait _after_ IdentifyConn

func (*IDService) ObservedAddrsFor added in v0.0.2

func (ids *IDService) ObservedAddrsFor(local ma.Multiaddr) []ma.Multiaddr

func (*IDService) OwnObservedAddrs

func (ids *IDService) OwnObservedAddrs() []ma.Multiaddr

OwnObservedAddrs returns the addresses peers have reported we've dialed from

func (*IDService) Push

func (ids *IDService) Push()

Push pushes a full identify message to all peers containing the current state.

type ObservedAddr

type ObservedAddr struct {
	Addr     ma.Multiaddr
	SeenBy   map[string]observation // peer(observer) address -> observation info
	LastSeen time.Time
}

ObservedAddr is an entry for an address reported by our peers. We only use addresses that:

  • have been observed at least 4 times in last 40 minutes. (counter symmetric nats)
  • have been observed at least once recently (10 minutes), because our position in the network, or network port mapppings, may have changed.

type ObservedAddrSet

type ObservedAddrSet struct {
	sync.RWMutex // guards whole datastruct.
	// contains filtered or unexported fields
}

ObservedAddrSet keeps track of a set of ObservedAddrs the zero-value is ready to be used.

func NewObservedAddrSet added in v0.0.7

func NewObservedAddrSet(ctx context.Context) *ObservedAddrSet

NewObservedAddrSet returns a new set using peerstore.OwnObservedAddressTTL as the TTL.

func (*ObservedAddrSet) Add

func (oas *ObservedAddrSet) Add(observed, local, observer ma.Multiaddr,
	direction network.Direction)

Add attemps to queue a new observed address to be added to the set.

func (*ObservedAddrSet) Addrs

func (oas *ObservedAddrSet) Addrs() (addrs []ma.Multiaddr)

Addrs return all activated observed addresses

func (*ObservedAddrSet) AddrsFor added in v0.0.2

func (oas *ObservedAddrSet) AddrsFor(addr ma.Multiaddr) (addrs []ma.Multiaddr)

AddrsFor return all activated observed addresses associated with the given (resolved) listen address.

func (*ObservedAddrSet) SetTTL

func (oas *ObservedAddrSet) SetTTL(ttl time.Duration)

SetTTL sets the TTL of an observed address-set.

func (*ObservedAddrSet) TTL

func (oas *ObservedAddrSet) TTL() time.Duration

TTL gets the TTL of an observed address-set.

type Option added in v0.4.0

type Option func(*config)

Option is an option function for identify.

func UserAgent added in v0.4.0

func UserAgent(ua string) Option

UserAgent sets the user agent this node will identify itself with to peers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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