config

package
v0.0.0-...-65f3eb6 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigPath = "~/.p2p-proxy.yaml"
)

Variables

View Source
var Default = &Config{
	P2P: P2P{
		Addrs: []string{
			"/ip4/0.0.0.0/tcp/8888",
		},
		BootstrapPeers: []string{},
	},
	Logging: Logging{
		File:   "~/p2p-proxy.log",
		Format: "console",
		Level: map[string]string{
			"all": "info",
		},
	},
	Version:    metadata.Version,
	ServiceTag: "p2p-proxy/0.0.1",
	Proxy: Proxy{
		Protocols: []Protocol{
			{
				Protocol: "/p2p-proxy/http/0.0.1",
				Config:   map[string]interface{}{},
			},
			{
				Protocol: "/p2p-proxy/shadowsocks/0.0.1",
				Config:   map[string]interface{}{},
			},
			{
				Protocol: "/p2p-proxy/socks5/0.0.1",
				Config:   map[string]interface{}{},
			},
		},
		ServiceAdvertiseInterval: time.Hour,
	},
	Endpoint: Endpoint{
		ProxyProtocols: []ProxyProtocol{
			{
				Protocol: "/p2p-proxy/http/0.0.1",
				Listen:   "127.0.0.1:8010",
			},
			{
				Protocol: "/p2p-proxy/shadowsocks/0.0.1",
				Listen:   "127.0.0.1:8020",
			},
			{
				Protocol: "/p2p-proxy/socks5/0.0.1",
				Listen:   "127.0.0.1:8030",
			},
		},

		ServiceDiscoveryInterval: time.Hour,

		Balancer: "round_robin",
	},
	Interactive: false,
}
View Source
var InvalidErr = errors.New("config invalid or not checked")

Functions

This section is empty.

Types

type BandWidthReporter

type BandWidthReporter struct {
	Enable bool `yaml:"Enable"`

	Interval time.Duration `yaml:"Interval"`
}

type Config

type Config struct {
	// config version
	Version string `yaml:"Version"`

	Logging Logging `yaml:"Logging"`

	ServiceTag string `yaml:"ServiceTag"`

	P2P P2P `yaml:"P2P"`

	Proxy Proxy `yaml:"Proxy"`

	Endpoint Endpoint `yaml:"Endpoint"`

	Interactive bool `yaml:"Interactive"`
	// contains filtered or unexported fields
}

func Initialize

func Initialize(cfgPath string) (*Config, error)

func LoadOrInitializeIfNotPresent

func LoadOrInitializeIfNotPresent(configPath string) (cfg *Config, cfgFile string, err error)

func (*Config) SetupLogging

func (c *Config) SetupLogging(defaultLevel string) (err error)

func (*Config) Validate

func (c *Config) Validate(proxy bool) error

func (*Config) Work4Proxy

func (c *Config) Work4Proxy() bool

type DHT

type DHT struct {
	Client bool `yaml:"Client"`
}

type Endpoint

type Endpoint struct {
	ProxyProtocols []ProxyProtocol `yaml:"ProxyProtocols"`

	ServiceDiscoveryInterval time.Duration `yaml:"ServiceDiscoveryInterval"`

	Balancer string `yaml:"Balancer"`
}

type Identity

type Identity struct {
	PrivKey string `yaml:"PrivKey"`

	ObservedAddrActivationThresh int `yaml:"ObservedAddrActivationThresh"`
}

type Logging

type Logging struct {
	File string `yaml:"File"`
	// json console nocolor, default nocolor
	Format string            `yaml:"Format"`
	Level  map[string]string `yaml:"Level"`
}

type P2P

type P2P struct {
	Identity Identity `yaml:"Identity"`
	// libp2p multi address
	Addrs []string `yaml:"Addrs"`

	BootstrapPeers []string `yaml:"BootstrapPeers"`

	BandWidthReporter BandWidthReporter `yaml:"BandWidthReporter"`

	EnableAutoRelay bool `yaml:"EnableAutoRelay"`

	AutoNATService bool `yaml:"AutoNATService"`

	DHT DHT `yaml:"DHT"`
}

type Protocol

type Protocol struct {
	Protocol string                 `yaml:"Protocol"`
	Config   map[string]interface{} `yaml:"Config"`
}

type Proxy

type Proxy struct {
	Protocols []Protocol `yaml:"Protocols"`

	ServiceAdvertiseInterval time.Duration `yaml:"ServiceAdvertiseInterval"`
}

type ProxyProtocol

type ProxyProtocol struct {
	Protocol string `yaml:"Protocol"`
	Listen   string `yaml:"Listen"`
}

Jump to

Keyboard shortcuts

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