Documentation ¶
Overview ¶
Package p2p
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Package p2p ¶
@author: xwc1125
Index ¶
- Constants
- func NewP2P(rootCtx context.Context, opts ...option) (protocol.P2PService, error)
- func P2PToPeerID(id peer.ID) models.P2PID
- func PeerIDtoP2P(peerId models.P2PID) (peer.ID, error)
- func WithAPIs(apis protocol.APIs) option
- func WithConfig(config protocol.Config) option
- type API
- type AdminApi
- type Certificate
- type ConnGater
- func (cg *ConnGater) InterceptAccept(cm network.ConnMultiaddrs) (allow bool)
- func (cg *ConnGater) InterceptAddrDial(peerId peer.ID, addr multiaddr.Multiaddr) (allow bool)
- func (cg *ConnGater) InterceptPeerDial(peerId peer.ID) (allow bool)
- func (cg *ConnGater) InterceptSecured(d network.Direction, peerId peer.ID, cm network.ConnMultiaddrs) (allow bool)
- func (cg *ConnGater) InterceptUpgraded(c network.Conn) (allow bool, reason control.DisconnectReason)
- type NetAPI
Constants ¶
View Source
const ( ProtocolID = "/chain5j/1.0.0" // 协议版本 MaxPeers = 25 // 最大的peer数 )
Variables ¶
This section is empty.
Functions ¶
func NewP2P ¶
func NewP2P(rootCtx context.Context, opts ...option) (protocol.P2PService, error)
NewP2P 创建p2p服务
func PeerIDtoP2P ¶
PeerIDtoP2P 将peerId转为peer.ID
func WithConfig ¶
Types ¶
type Certificate ¶
type Certificate struct { TlsType int Certificate interface{} }
type ConnGater ¶
type ConnGater struct {
// contains filtered or unexported fields
}
ConnGater p2p网关 对出入站的peerId及连接进行权限管控
func (*ConnGater) InterceptAccept ¶
func (cg *ConnGater) InterceptAccept(cm network.ConnMultiaddrs) (allow bool)
InterceptAccept 【入站】是否允许连接入站 它会被upgrader或者直接被transport在从socket中接受一个链接之后立即被调用。 入站校验第一步
func (*ConnGater) InterceptAddrDial ¶
InterceptAddrDial 是否允许向给定的地址及peerId进行拨号 在Network解析了节点地址之后向其拨号之前被调用。
func (*ConnGater) InterceptPeerDial ¶
InterceptPeerDial 【出站】是否允许向peerId进行拨号
func (*ConnGater) InterceptSecured ¶
func (cg *ConnGater) InterceptSecured(d network.Direction, peerId peer.ID, cm network.ConnMultiaddrs) (allow bool)
InterceptSecured 【入站】是否允许给定的连接(已经过身份验证)入站。 它会被upgrader执行安全握手之后协商muxer之前调用; 或者被transport直接在同一个检查点调用。 包含入站出站
func (*ConnGater) InterceptUpgraded ¶
func (cg *ConnGater) InterceptUpgraded(c network.Conn) (allow bool, reason control.DisconnectReason)
InterceptUpgraded 是否允许连接升级
Source Files ¶
Click to show internal directories.
Click to hide internal directories.