identify

package
v0.0.0-...-c9eddef Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

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

ID is the protocol.ID of the Identify Service.

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.

Variables

View Source
var ClientVersion = "go-libp2p/3.3.4"

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

	Reporter metrics.Reporter
	// 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(h host.Host) *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 inet.Conn)

func (*IDService) IdentifyWait

func (ids *IDService) IdentifyWait(c inet.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 necesary. Users **MUST** call IdentifyWait _after_ IdentifyConn

func (*IDService) OwnObservedAddrs

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

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

func (*IDService) RequestHandler

func (ids *IDService) RequestHandler(s inet.Stream)

func (*IDService) ResponseHandler

func (ids *IDService) ResponseHandler(s inet.Stream)

type ObservedAddr

type ObservedAddr struct {
	Addr      ma.Multiaddr
	SeenBy    map[string]time.Time
	LastSeen  time.Time
	Activated bool
}

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 1h. (counter symmetric nats)
  • have been observed at least once recently (1h), because our position in the network, or network port mapppings, may have changed.

func (*ObservedAddr) TryActivate

func (oa *ObservedAddr) TryActivate(ttl time.Duration) bool

type ObservedAddrSet

type ObservedAddrSet struct {
	sync.Mutex // 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 (*ObservedAddrSet) Add

func (oas *ObservedAddrSet) Add(addr ma.Multiaddr, observer ma.Multiaddr)

func (*ObservedAddrSet) Addrs

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

func (*ObservedAddrSet) SetTTL

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

func (*ObservedAddrSet) TTL

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

Directories

Path Synopsis
Package identify_pb is a generated protocol buffer package.
Package identify_pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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