Config

package
v0.0.0-...-7685a06 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: GPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	// proxy proto type
	ProtoType string `json:"type"` // http sock4 sock5

	// [proto]&[name] as ident
	Name string `yaml:"name"`

	// proxy server
	Server string `yaml:"server"`
	Port   int    `yaml:"port"`

	// auth message
	UserName string `yaml:"username"`
	Password string `yaml:"password"`
}

proxy type

type ProxyConfig

type ProxyConfig struct {
	AllProxies map[string]ScopeProxies `yaml:"all-proxies"` // map[global,app]ScopeProxies
}

proxy config

func NewProxyCfg

func NewProxyCfg() *ProxyConfig

create new

func (*ProxyConfig) GetProxy

func (p *ProxyConfig) GetProxy(scope string, proto string, name string) (Proxy, error)

get proxy from config map, index: [global,app] -> [http,sock4,sock5] -> [proxy-name]

func (*ProxyConfig) GetScopeProxies

func (p *ProxyConfig) GetScopeProxies(scope define.Scope) (ScopeProxies, error)

get proxy by scope

func (*ProxyConfig) LoadPxyCfg

func (p *ProxyConfig) LoadPxyCfg(path string) error

load config file

func (*ProxyConfig) SetScopeProxies

func (p *ProxyConfig) SetScopeProxies(scope define.Scope, proxies ScopeProxies)

func (*ProxyConfig) WritePxyCfg

func (p *ProxyConfig) WritePxyCfg(path string) error

write config file

type ProxyNetwork

type ProxyNetwork int

proxy proto, support tcp udp

const (
	TcpProxy ProxyNetwork = iota
	UdpProxy
)

func (ProxyNetwork) String

func (p ProxyNetwork) String() string

type ProxyProto

type ProxyProto int

proxy type, support HTTP SOCK4 SOCK5

const (
	HttpProxy ProxyProto = iota
	Sock4Proxy
	Sock5Proxy
)

func (ProxyProto) String

func (p ProxyProto) String() string

type ScopeProxies

type ScopeProxies struct {
	Proxies map[string][]Proxy `yaml:"proxies"` // map[http,sock4,sock5][]proxy
	// proxy setting
	ProxyProgram   []string `yaml:"proxy-program"`    // global proxy will ignore
	NoProxyProgram []string `yaml:"no-proxy-program"` // app proxy will ignore

	// white list
	WhiteList []string `yaml:"whitelist"` // white site dont use proxy, not use this time
	TPort     int      `yaml:"t-port"`
	DNSPort   int      `yaml:"dns-port"`

	UseFakeIP bool `yaml:"use-fake-ip"`
}

scope proxy

func (*ScopeProxies) ClearProxy

func (p *ScopeProxies) ClearProxy()

func (*ScopeProxies) GetProxy

func (p *ScopeProxies) GetProxy(proto string, name string) (Proxy, error)

func (*ScopeProxies) SetProxy

func (p *ScopeProxies) SetProxy(proto string, name string, proxy Proxy)

set and add proxy

Jump to

Keyboard shortcuts

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