Documentation ¶
Index ¶
- func WithRelayAddrs(relays []string) config.AddrsFactory
- type MDNS
- type PubSub
- func (p *PubSub) FetchTopicPeers(topic string) []peer.ID
- func (p *PubSub) HasTopic(topic string) bool
- func (p *PubSub) JoinAndSubTopic(topic string, callback SubCallBack, opts ...pubsub.TopicOpt) error
- func (p *PubSub) JoinTopic(topic string, opts ...pubsub.TopicOpt) error
- func (p *PubSub) Publish(topic string, msg []byte) error
- func (p *PubSub) RemoveTopic(topic string)
- func (p *PubSub) TopicNum() int
- func (p *PubSub) TryJoinTopic(topic string, opts ...pubsub.TopicOpt) error
- type Relay
- type SubCallBack
- type SubMsg
- type TopicMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithRelayAddrs ¶
func WithRelayAddrs(relays []string) config.AddrsFactory
WithRelayAddrs 会自动把relay的地址加入到自己的addrs 中,然后进行广播,这样其他节点收到包含有relay地址格式的节点地址时, 如果接收到的节点打开了启用relay服务功能,就会触发relay协议进行尝试连接。
比如 中继服务器R的地址:/ip4/116.63.171.186/tcp/13801/p2p/16Uiu2HAm1Qgogf1vHj7WV7d8YmVNPw6PzRuYEnJbQsMDmDWtLoEM NAT 后面的一个普通节点A是:/ip4/192.168.1.101/tcp/13801/p2p/16Uiu2HAkw6w2YVenbCLAXHv2XVo1kh945GVxQrpm5Y6z2kE3eFSg 第一步:A--->R A连接到中继节点R 第二步:A开始组装自己的中继地址: [/ip4/116.63.171.186/tcp/13801/p2p/16Uiu2HAm1Qgogf1vHj7WV7d8YmVNPw6PzRuYEnJbQsMDmDWtLoEM/p2p-circuit/ip4/192.168.1.101/tcp /13801/p2p/16Uiu2HAkw6w2YVenbCLAXHv2XVo1kh945GVxQrpm5Y6z2kE3eFSg] 第三步:A广播这个拼接后的带有p2p-circuit的地址 第四步:网络中的节点不论是NAT前面的或者NAT后面的节点,如果想连接节点PID为16Uiu2HAkw6w2YVenbCLAXHv2XVo1kh945GVxQrpm5Y6z2kE3eFSg的A节点, 只需要通过上述组装的带有p2p-circuit的地址就可以建立到与A的连接
Types ¶
type PubSub ¶
PubSub pub sub
func (*PubSub) FetchTopicPeers ¶
FetchTopicPeers fetch peers with topic
func (*PubSub) JoinAndSubTopic ¶
JoinAndSubTopic 加入topic&subTopic
type Relay ¶
type Relay struct {
// contains filtered or unexported fields
}
Relay p2p relay
func NewRelayDiscovery ¶
func NewRelayDiscovery(host host.Host, adv *discovery.RoutingDiscovery, opts ...circuit.RelayOpt) *Relay
NewRelayDiscovery new relay discovery
func (*Relay) DialDestPeer ¶
DialDestPeer 通过hop中继节点连接dst节点
Click to show internal directories.
Click to hide internal directories.