p2p

package module
v0.0.0-...-a6cdbf0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2022 License: Apache-2.0 Imports: 36 Imported by: 1

README

chain5j-p2p

简介

chain5j-p2p chain5j链对基于libp2p对protocol.P2P接口的实现。

功能

  • 基于libp2p 进行p2p的相关网络处理
  • 基于gmsm 实现p2p中的国密通信
  • 基于libp2p-tls 实现p2p的tls通信

证书

chain5j-p2p 的源码允许用户在遵循 Apache 2.0 开源证书 规则的前提下使用。

版权

Copyright@2022 chain5j

chain5j

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

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 P2PToPeerID

func P2PToPeerID(id peer.ID) models.P2PID

P2PToPeerID 将peer.ID转为models.P2PID

func PeerIDtoP2P

func PeerIDtoP2P(peerId models.P2PID) (peer.ID, error)

PeerIDtoP2P 将peerId转为peer.ID

func WithAPIs

func WithAPIs(apis protocol.APIs) option

func WithConfig

func WithConfig(config protocol.Config) option

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func (*API) Info

func (a *API) Info() map[string]interface{}

func (*API) Peers

func (a *API) Peers() map[string]*models.P2PInfo

type AdminApi

type AdminApi struct {
	// contains filtered or unexported fields
}

func (*AdminApi) AddPeer

func (api *AdminApi) AddPeer(url string) error

AddPeer 添加节点

func (*AdminApi) DropPeer

func (api *AdminApi) DropPeer(id string) error

DropPeer 删除节点

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

func (cg *ConnGater) InterceptAddrDial(peerId peer.ID, addr multiaddr.Multiaddr) (allow bool)

InterceptAddrDial 是否允许向给定的地址及peerId进行拨号 在Network解析了节点地址之后向其拨号之前被调用。

func (*ConnGater) InterceptPeerDial

func (cg *ConnGater) InterceptPeerDial(peerId peer.ID) (allow bool)

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 是否允许连接升级

type NetAPI

type NetAPI struct {
	// contains filtered or unexported fields
}

func (*NetAPI) Listening

func (s *NetAPI) Listening() bool

func (*NetAPI) PeerCount

func (s *NetAPI) PeerCount() hexutil.Uint

func (*NetAPI) Version

func (s *NetAPI) Version() string

Directories

Path Synopsis
Package p2pgmtls
Package p2pgmtls
Package p2ptls
Package p2ptls

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL