config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultModule            = "p2pv2"
	DefaultPort              = 47101 // p2p port
	DefaultAddress           = "/ip4/127.0.0.1/tcp/47101"
	DefaultNetKeyPath        = "netkeys" // node private key path
	DefaultNetIsNat          = true      // use NAT
	DefaultNetIsTls          = false     // use tls secure transport
	DefaultNetIsHidden       = false
	DefaultMaxStreamLimits   = 1024
	DefaultMaxMessageSize    = 128
	DefaultTimeout           = 3
	DefaultStreamIPLimitSize = 10
	DefaultMaxBroadcastPeers = 20
	DefaultServiceName       = "localhost"
	DefaultIsBroadCast       = true
)

default settings

Variables

This section is empty.

Functions

This section is empty.

Types

type NetConf

type NetConf struct {
	// Module is the name of p2p module plugin
	Module string `yaml:"module,omitempty"`
	// Port the p2p network listened for p2pv1
	Port int32 `yaml:"port,omitempty"`
	// Address multiaddr string, /ip4/127.0.0.1/tcp/8080
	Address string `yaml:"address,omitempty"`
	// keyPath is the node private key path, xuper will gen a random one if is nil
	KeyPath string `yaml:"keyPath,omitempty"`
	// isNat config whether the node use NAT manager
	IsNat bool `yaml:"isNat,omitempty"`
	// isHidden config whether the node can be found
	IsHidden bool `yaml:"isHidden,omitempty"`
	// bootNodes config the bootNodes the node to connect
	BootNodes []string `yaml:"bootNodes,omitempty"`
	// staticNodes config the nodes which you trust
	StaticNodes map[string][]string `yaml:"staticNodes,omitempty"`
	// isBroadCast config whether broadcast to all StaticNodes
	IsBroadCast bool `yaml:"isBroadCast,omitempty"`
	// maxStreamLimits config the max stream num
	MaxStreamLimits int32 `yaml:"maxStreamLimits,omitempty"`
	// maxMessageSize config the max message size
	MaxMessageSize int64 `yaml:"maxMessageSize,omitempty"`
	// timeout config the timeout of Request with response
	Timeout int64 `yaml:"timeout,omitempty"`
	// StreamIPLimitSize set the limitation size for same ip
	StreamIPLimitSize int64 `yaml:"streamIPLimitSize,omitempty"`
	// MaxBroadcastPeers limit the number of common peers in a broadcast,
	// this number do not include MaxBroadcastCorePeers.
	MaxBroadcastPeers int `yaml:"maxBroadcastPeers,omitempty"`
	// isTls config the node use tls secure transparent
	IsTls bool `yaml:"isTls,omitempty"`
	// ServiceName
	ServiceName string `yaml:"serviceName,omitempty"`
}

Config is the config of p2p server. Attention, config of dht are not expose

func GetDefP2PConf

func GetDefP2PConf() *NetConf

func LoadP2PConf

func LoadP2PConf(cfgFile string) (*NetConf, error)

Jump to

Keyboard shortcuts

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