relay

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(ln *libp2pnet.LibP2pNet, opts ...NetOption) error

Apply . @Description: options. @param ln: @param opts: @return error:

func NewNet

func NewNet(cfg *NetConfig, readySignalC chan struct{}) (protocol.Net, error)

NewNet . @Description: create a net instance @param cfg: @param readySignalC: @return protocol.Net: @return error:

Types

type CustomTrustRootsConfig

type CustomTrustRootsConfig struct {
	ChainId    string   `mapstructure:"chain_id"`
	TrustRoots []string `mapstructure:"trust_roots"`
}

CustomTrustRootsConfig .

type NetConfig

type NetConfig struct {
	AuthType                string                   `mapstructure:"auth_type"`
	ListenAddr              string                   `mapstructure:"listen_addr"`
	PeerStreamPoolSize      int                      `mapstructure:"peer_stream_pool_size"`
	MaxPeerCountAllow       int                      `mapstructure:"max_peer_count_allow"`
	PeerEliminationStrategy int                      `mapstructure:"peer_elimination_strategy"` // default LIFO
	Seeds                   []string                 `mapstructure:"seeds"`
	TLSConfig               netTlsConfig             `mapstructure:"tls"`
	BlackList               blackList                `mapstructure:"blacklist"`
	IsNetInsecurity         bool                     `mapstructure:"is_net_insecurity"`
	UseNetMsgCompression    bool                     `mapstructure:"use_net_msg_compression"`
	CustomTrustRootsConfigs []CustomTrustRootsConfig `mapstructure:"custom_trust_roots"` // custom trust root
}

NetConfig .

type NetOption

type NetOption func(ln *libp2pnet.LibP2pNet) error

NetOption is a function apply options to net instance.

func WithBlackAddresses

func WithBlackAddresses(blackAddresses ...string) NetOption

WithBlackAddresses . @Description: set addresses of the nodes for blacklist. @param blackAddresses: @return NetOption:

func WithBlackNodeIds

func WithBlackNodeIds(blackNodeIds ...string) NetOption

WithBlackNodeIds . @Description: set ids of the nodes for blacklist. @param blackNodeIds: @return NetOption:

func WithCrypto

func WithCrypto(pkMode bool, keyFile string, certFile string) NetOption

WithCrypto . @Description: set private key file and tls cert file for the net to create connection. @param pkMode: @param keyFile: @param certFile: @return NetOption:

func WithInsecurity

func WithInsecurity(isInsecurity bool) NetOption

WithInsecurity . @Description: set is insecurity @param isInsecurity: @return NetOption:

func WithListenAddr

func WithListenAddr(addr string) NetOption

WithListenAddr . @Description: set addr that the local net will listen on. @param addr: @return NetOption:

func WithMaxPeerCountAllowed

func WithMaxPeerCountAllowed(max int) NetOption

WithMaxPeerCountAllowed . @Description: set max count of nodes that connected to us. @param max: @return NetOption:

func WithPeerEliminationStrategy

func WithPeerEliminationStrategy(strategy int) NetOption

WithPeerEliminationStrategy set the strategy for eliminating node when the count of nodes that connected to us reach the max value.

func WithPeerStreamPoolSize

func WithPeerStreamPoolSize(size int) NetOption

WithPeerStreamPoolSize . @Description: set the max stream pool size for every node that connected to us. @param size: @return NetOption:

func WithReadySignalC

func WithReadySignalC(signalC chan struct{}) NetOption

WithReadySignalC . @Description: set signal channel @param signalC: @return NetOption:

func WithSeeds

func WithSeeds(seeds ...string) NetOption

WithSeeds . @Description: set addresses of discovery service node. @param seeds: @return NetOption:

type RelayConfig

type RelayConfig struct {
	NetConfig NetConfig `mapstructure:"net"` // net config
}

RelayConfig .

func LoadRelayCfg

func LoadRelayCfg(configPath string) (*RelayConfig, error)

LoadRelayCfg . @Description: load relay config file @param configPath: @return *RelayConfig: @return error:

type RelayService

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

RelayService relay service, provide relay function

func NewRelayService

func NewRelayService(cfg *RelayConfig) (*RelayService, error)

NewRelayService . @Description: create a relay service instance @param cfg: @return *RelayService: @return error:

func (*RelayService) Start

func (rs *RelayService) Start() error

Start . @Description: RelayService start @receiver rs @return error:

func (*RelayService) Stop

func (rs *RelayService) Stop() error

Stop . @Description: RelayService stop @receiver rs @return error:

Jump to

Keyboard shortcuts

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