ipfs, libp2p, How to identify the external IP address of myself

Serafina ·
更新时间:2024-11-15
· 956 次阅读

dialPeer -> go h.ids.IdentifyConn(c) -> c.NewStream("/ipfs/id/1.0.0") SelectProtoOrFail --> ProtocolID + ID responseHandler.readMsg -> ids.consumeMessage -> consumeObservedAddress -> ids.observedAddrs.Add( EXTERNAL ADDRESS)

peer.ID.Addr will call h.AllAddrs() -> observed := h.ids.ObservedAddrsFor(listen) …

func (oas *ObservedAddrSet) AddrsFor(addr ma.Multiaddr) (addrs []ma.Multiaddr) { oas.RLock() defer oas.RUnlock() if len(oas.addrs) == 0 { return nil } key := string(addr.Bytes()) observedAddrs, ok := oas.addrs[key] if !ok { return } now := time.Now() for _, a := range observedAddrs { if now.Sub(a.LastSeen) <= oas.ttl && a.activated(oas.ttl) { addrs = append(addrs, a.Addr) } } return addrs }
作者:Kingwel2020



identify myself ipfs TO

需要 登录 后方可回复, 如果你还没有账号请 注册新账号
相关文章