app

package
v0.0.0-...-8e6527b Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: GPL-3.0 Imports: 21 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDomainTree

func NewDomainTree(conf *Conf) (*suffixtree.DomainTree, error)

NewDomainTree is ... generate domain tree from configuration

func NewGeoSiteMatcher

func NewGeoSiteMatcher(conf *Conf) (geosite.Matcher, error)

NewGeoSiteMatcher is ...

Types

type App

type App struct {
	// Logger is ...
	// to print logs
	Logger logger.Logger
	// Conf is ...
	// shadow configuration
	Conf *Conf
	// Timeout is ...
	// timeout for closing UDP connections
	Timeout time.Duration
	// contains filtered or unexported fields
}

App is shadow application

func NewApp

func NewApp(s string, timeout time.Duration, w io.Writer) (*App, error)

NewApp is new shadow app from config file

func NewAppFromByteSlice

func NewAppFromByteSlice(b []byte, timeout time.Duration, w io.Writer) (*App, error)

NewAppFromByteSlice is new shadow app from byte slice

func NewAppFromConf

func NewAppFromConf(conf *Conf, timeout time.Duration, w io.Writer) *App

NewAppFromConf is new shadow app from *Conf

func (*App) Close

func (app *App) Close() error

Close is shutdown application

func (*App) Done

func (app *App) Done() chan struct{}

Done is to give done channel

func (*App) Run

func (app *App) Run() error

Run is ...

func (*App) RunWithDevice

func (app *App) RunWithDevice(dev *tun.Device) (err error)

RunWithDevice is ...

type Command

type Command struct {
	Cmds []*exec.Cmd
}

Command is ...

func (*Command) Close

func (c *Command) Close() (last error)

Close is ...

type Conf

type Conf struct {
	// Server is ...
	// proxy server address
	// {
	//   "protocol": "",
	//   "url": "",
	//   "server": ""
	// }
	// ss://chacha20-ietf-poly1305:test1234@1.2.3.4:8388
	Server json.RawMessage `json:"server"`
	// NameServer is ...
	// dns resolver server address
	// tls://1.1.1.1:853
	// https://1.1.1.1:443/dns-query
	NameServer []string `json:"name_server"`
	// ProxyServer is ...
	// for incoming socks5/http proxy
	// 127.0.0.1:1080
	ProxyServer string `json:"proxy_server,omitempty"`

	// FilterString is ...
	// WinDivert fitler string
	// generate if not exist
	FilterString string `json:"windivert_filter_string,omitempty"`
	// GeoIP is ...
	// process packets by geo info of target IP
	GeoIP struct {
		// File is ...
		// mmdb file path
		File string `json:"file"`
		// Proxy is ...
		// ISO code of countries to be proxied
		Proxy []string `json:"proxy,omitempty"`
		// Bypass is ...
		// ISO code of countries to be bypassed
		Bypass []string `json:"bypass,omitempty"`
		// Final is ...
		// default action when country code does not appears in `Proxy` or `Bypass`
		Final string `json:"final"`
	} `json:"geo_ip_rules,omitempty"`
	// AppRules is ...
	// proxy selected programs
	AppRules struct {
		// Proxy is ...
		Proxy []string `json:"proxy"`
	} `json:"app_rules,omitempty"`

	// Tun is ...
	// config for tun device
	Tun struct {
		// TunName is ...
		// for macOS, this should be utun[0-9]
		TunName string `json:"tun_name,omitempty"`
		// TunAddr is ...
		// tun device ip address
		// 192.168.0.11/24
		// fe80:08ef:ae86:68ea::11/64
		TunAddr []string `json:"tun_addr,omitempty"`
		// NameServer is ...
		NameServer string `json:"name_server,omitempty"`
		// MTU is ...
		// set MTU for tun device
		MTU int `json:"mtu,omitempty"`
		// PreUp is ...
		PreUp string `json:"pre_up,omitempty"`
		// PostUp is ...
		PostUp string `json:"post_up,omitempty"`
		// PreDown is ...
		PreDown string `json:"pre_down,omitempty"`
		// PostDown is ...
		PostDown string `json:"post_down,omitempty"`
	} `json:"tun,omitempty"`

	// IPCIDRRules is ...
	// Tun: try to add these cidrs to route table
	// WinDivert: use radix tree to select packets
	IPCIDRRules struct {
		// Proxy is ...
		Proxy []string `json:"proxy"`
	} `json:"ip_cidr_rules"`
	// DomianRules is ...
	// hijack dns queries and process with domain rules
	DomainRules struct {
		// GeoSite is ...
		GeoSite struct {
			// File is ...
			// path to geosite.dat
			File string `json:"file"`
			// Proxy is ...
			Proxy []string `json:"proxy,omitempty"`
			// Bypass is ...
			Bypass []string `json:"bypass,omitempty"`
			// Final is ...
			Final string `json:"final,omitempty"`
		} `json:"geo_site,omitempty"`
		// DisableHijack is ...
		// hijack dns queries
		DisableHijack bool `json:"disable_hijack,omitempty"`
		// Proxy is ...
		// fake ip with prefix of 198.18 will be assigned
		Proxy []string `json:"proxy"`
		// Direct is ...
		// send queries to remote dns server
		Direct []string `json:"direct,omitempty"`
		// Blocked is ...
		// answer 0.0.0.0 or ::0
		Blocked []string `json:"blocked,omitempty"`
	} `json:"domain_rules"`
}

Conf is shadow application configuration

func (*Conf) ReadFromByteSlice

func (c *Conf) ReadFromByteSlice(b []byte) error

ReadFromByteSlice is to load config from byte slice

func (*Conf) ReadFromFile

func (c *Conf) ReadFromFile(file string) error

ReadFromFile is to read config from file

func (*Conf) ReadFromURL

func (c *Conf) ReadFromURL(s string) error

ReadFromURL is ...

type PAC

type PAC struct {
	// Format is ...
	Format string
}

PAC is ... serve proxy pac file

func NewPACForHTTP

func NewPACForHTTP() *PAC

NewPACForHTTP is ...

func NewPACForSocks5

func NewPACForSocks5() *PAC

NewPACForSocks5 is ...

func (*PAC) ServeHTTP

func (p *PAC) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is to serve proxy pac file

Jump to

Keyboard shortcuts

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