Documentation ¶
Index ¶
- func ConnectHost(thisHost host.Host, relayHostAddr string) error
- func ReadBytesFromStream(stream network.Stream) ([]byte, error)
- func WriteBytesToStream(stream network.Stream, dataBytes []byte) error
- type FileDataModel
- type P2pRelayHost
- func (p *P2pRelayHost) ConnectRelayHost(relayHostAddr string) error
- func (p *P2pRelayHost) HostInfo() string
- func (p *P2pRelayHost) Regist(targetHostAddr string, uri string, dataBytes []byte) ([]byte, error)
- func (p *P2pRelayHost) Request(c *fasthttp.RequestCtx, targetHostAddr string, uri string, dataBytes []byte) (int64, error)
- func (p *P2pRelayHost) SetStreamHandler(uri string, handler network.StreamHandler)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectHost ¶
当前节点作为客户端连接到指定地址节点 /ip4/{ip}/tcp/{port}/p2p/{peerid}
Types ¶
type FileDataModel ¶
type P2pRelayHost ¶
func NewP2pRelayHost ¶
func NewP2pRelayHost(key string, port string) (*P2pRelayHost, error)
新建中继P2P节点
func (*P2pRelayHost) ConnectRelayHost ¶
func (p *P2pRelayHost) ConnectRelayHost(relayHostAddr string) error
当前节点作为客户端连接到中继节点 /ip4/{ip}/tcp/{port}/p2p/{peerid}
func (*P2pRelayHost) Regist ¶
【注册】向目标节点发起请求并返回响应结果,地址通常为 /ip4/{ip}/tcp/{port}/p2p/{peerid} 或 /p2p/{relayPeerid}/p2p-circuit/p2p/{peerid} 或 /p2p/{peerid}
func (*P2pRelayHost) Request ¶
func (p *P2pRelayHost) Request(c *fasthttp.RequestCtx, targetHostAddr string, uri string, dataBytes []byte) (int64, error)
【请求】向目标节点发起请求并返回响应结果,地址通常为 /ip4/{ip}/tcp/{port}/p2p/{peerid} 或 /p2p/{relayPeerid}/p2p-circuit/p2p/{peerid} 或 /p2p/{peerid}
func (*P2pRelayHost) SetStreamHandler ¶
func (p *P2pRelayHost) SetStreamHandler(uri string, handler network.StreamHandler)
设定处理器
Click to show internal directories.
Click to hide internal directories.