config

package
v1.20.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvYeagerAddress   = "YEAGER_ADDRESS"
	EnvYeagerUUID      = "YEAGER_UUID"
	EnvYeagerTransport = "YEAGER_TRANSPORT"
	EnvYeagerDomain    = "YEAGER_DOMAIN"
	EnvYeagerSecurity  = "YEAGER_SECURITY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Acme

type Acme struct {
	Domain string `json:"domain"`
}

type ClientMTLS

type ClientMTLS struct {
	CertFile   string `json:"certFile"`
	CertPEM    []byte `json:"-"`
	KeyFile    string `json:"keyFile"`
	KeyPEM     []byte `json:"-"`
	RootCAFile string `json:"rootCAFile"`
	RootCA     []byte `json:"-"`
}

type ClientSecurityType

type ClientSecurityType string
const (
	ClientNoSecurity ClientSecurityType = ""           // no security, means plaintext
	ClientTLS        ClientSecurityType = "tls"        // security by TLS, manage certificate manually
	ClientTLSMutual  ClientSecurityType = "tls-mutual" // security by mutual TLS
)

type ClientTls

type ClientTls struct {
	Insecure bool `json:"insecure,omitempty"` // allow insecure
}

type Config

type Config struct {
	Inbounds  Inbounds        `json:"inbounds,omitempty"`  // 入站代理
	Outbounds []*YeagerClient `json:"outbounds,omitempty"` // 出站代理
	Rules     []string        `json:"rules,omitempty"`     // 路由规则
	Develop   bool            `json:"develop,omitempty"`   // developer only

	// 参考 transport/grpc/pool.go 如何预估连接池大小
	GrpcChannelPoolSize int `json:"grpcChannelPoolSize,omitempty"`
}

func C added in v1.20.0

func C() Config

func LoadEnv

func LoadEnv() (conf *Config, err error, foundEnv bool)

LoadEnv generate configuration from environment variables, suitable for server side plaintext or TLS with ACME

func LoadFile

func LoadFile(filename string) (*Config, error)

LoadFile load config from JSON file

func LoadJSON

func LoadJSON(bs []byte) (*Config, error)

LoadJSON load config from bytes in JSON format

type HTTPProxy

type HTTPProxy struct {
	Listen string `json:"listen"`
}

type Inbounds

type Inbounds struct {
	SOCKS  *SOCKSProxy   `json:"socks,omitempty"`
	HTTP   *HTTPProxy    `json:"http,omitempty"`
	Yeager *YeagerServer `json:"yeager,omitempty"`
}

type Mtls

type Mtls struct {
	CertFile     string `json:"certFile"`
	CertPEM      []byte `json:"-"`
	KeyFile      string `json:"keyFile"`
	KeyPEM       []byte `json:"-"`
	ClientCAFile string `json:"clientCAFile"`
	ClientCA     []byte `json:"-"`
}

type SOCKSProxy

type SOCKSProxy struct {
	Listen string `json:"listen"`
}

type ServerSecurityType

type ServerSecurityType string
const (
	NoSecurity ServerSecurityType = ""           // no security, means plaintext
	TLS        ServerSecurityType = "tls"        // security by TLS, manage certificate manually
	TLSAcme    ServerSecurityType = "tls-acme"   // security by TLS, manage certificate automatically
	TLSMutual  ServerSecurityType = "tls-mutual" // security by mutual TLS
)

type Tls

type Tls struct {
	CertFile string `json:"certFile"`
	CertPEM  []byte `json:"-"`
	KeyFile  string `json:"keyFile"`
	KeyPEM   []byte `json:"-"`
}

type Transport

type Transport string
const (
	TransTCP  Transport = "tcp"
	TransGRPC Transport = "grpc"
	TransQUIC Transport = "quic"
)

type YeagerClient

type YeagerClient struct {
	Tag       string             `json:"tag"` // 出站标记,用于路由规则指定出站代理
	Address   string             `json:"address"`
	UUID      string             `json:"uuid"` // ignored when Security is TLSMutual
	Transport Transport          `json:"transport"`
	Security  ClientSecurityType `json:"security"`
	TLS       ClientTls          `json:"tls,omitempty"`  // available when Security is ClientTLS
	MTLS      ClientMTLS         `json:"mtls,omitempty"` // available when Security is ClientTLSMutual
}

type YeagerServer

type YeagerServer struct {
	Listen    string             `json:"listen"`
	UUID      string             `json:"uuid"` // ignored when Security is TLSMutual
	Transport Transport          `json:"transport"`
	Security  ServerSecurityType `json:"security"`
	TLS       Tls                `json:"tls,omitempty"`  // available when Security is TLS
	ACME      Acme               `json:"acme,omitempty"` // available when Security is TLSAcme
	MTLS      Mtls               `json:"mtls,omitempty"` // available when Security is TLSMutual
}

Jump to

Keyboard shortcuts

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