Documentation ¶
Index ¶
- Constants
- Variables
- func HasConsistentTransport(a ma.Multiaddr, green []ma.Multiaddr) bool
- func NewIDService(h host.Host, opts ...Option) (*idService, error)
- type IDService
- type ObservedAddrManager
- func (oas *ObservedAddrManager) Addrs() []ma.Multiaddr
- func (oas *ObservedAddrManager) AddrsFor(addr ma.Multiaddr) (addrs []ma.Multiaddr)
- func (oas *ObservedAddrManager) Close() error
- func (oas *ObservedAddrManager) Record(conn network.Conn, observed ma.Multiaddr)
- func (oas *ObservedAddrManager) SetTTL(ttl time.Duration)
- func (oas *ObservedAddrManager) TTL() time.Duration
- type Option
Constants ¶
const DefaultProtocolVersion = "ipfs/0.1.0"
const ID = "/ipfs/id/1.0.0"
ID is the protocol.ID of version 1.0.0 of the identify service.
const IDDelta = "/p2p/id/delta/1.0.0"
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.
const ServiceName = "libp2p.identify"
Variables ¶
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.
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).
var StreamReadTimeout = 60 * time.Second
StreamReadTimeout is the read timeout on all incoming Identify family streams.
Functions ¶
func HasConsistentTransport ¶
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 interface { // IdentifyConn synchronously triggers an identify request on the connection and // waits for it to complete. If the connection is being identified by another // caller, this call will wait. If the connection has already been identified, // it will return immediately. IdentifyConn(network.Conn) // IdentifyWait triggers an identify (if the connection has not already been // identified) and returns a channel that is closed when the identify protocol // completes. IdentifyWait(network.Conn) <-chan struct{} // OwnObservedAddrs returns the addresses peers have reported we've dialed from OwnObservedAddrs() []ma.Multiaddr // ObservedAddrsFor returns the addresses peers have reported we've dialed from, // for a specific local address. ObservedAddrsFor(local ma.Multiaddr) []ma.Multiaddr io.Closer }
type ObservedAddrManager ¶
type ObservedAddrManager struct {
// contains filtered or unexported fields
}
ObservedAddrManager keeps track of a ObservedAddrs.
func NewObservedAddrManager ¶
func NewObservedAddrManager(host host.Host) (*ObservedAddrManager, error)
NewObservedAddrManager returns a new address manager using peerstore.OwnObservedAddressTTL as the TTL.
func (*ObservedAddrManager) Addrs ¶
func (oas *ObservedAddrManager) Addrs() []ma.Multiaddr
Addrs return all activated observed addresses
func (*ObservedAddrManager) AddrsFor ¶
func (oas *ObservedAddrManager) AddrsFor(addr ma.Multiaddr) (addrs []ma.Multiaddr)
AddrsFor return all activated observed addresses associated with the given (resolved) listen address.
func (*ObservedAddrManager) Close ¶
func (oas *ObservedAddrManager) Close() error
func (*ObservedAddrManager) Record ¶
func (oas *ObservedAddrManager) Record(conn network.Conn, observed ma.Multiaddr)
Record records an address observation, if valid.
func (*ObservedAddrManager) SetTTL ¶
func (oas *ObservedAddrManager) SetTTL(ttl time.Duration)
SetTTL sets the TTL of an observed address manager.
func (*ObservedAddrManager) TTL ¶
func (oas *ObservedAddrManager) TTL() time.Duration
TTL gets the TTL of an observed address manager.
type Option ¶
type Option func(*config)
Option is an option function for identify.
func DisableSignedPeerRecord ¶
func DisableSignedPeerRecord() Option
DisableSignedPeerRecord disables populating signed peer records on the outgoing Identify response and ONLY sends the unsigned addresses.
func ProtocolVersion ¶
ProtocolVersion sets the protocol version string that will be used to identify the family of protocols used by the peer.