server

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultAddrFamilyDetectURL = []string{
		"http://detectportal.firefox.com/success.txt",
		"http://204.ustclug.org",
	}
	DefaultServerHealthcheck = []string{
		"http://www.google.com/generate_204",
		"http://maps.google.com/generate_204",
	}
)

Functions

This section is empty.

Types

type Advertise struct {
	IP   string `yaml:"ip,omitempty"`
	Port uint16 `yaml:"port,omitempty"`
}

Advertise since the socks5 server can listen to multiple network cards or be reverse-proxyed we need to set an advertising ip and port for example, socks5 UDP ASSOCIATE refers to this address when responding to the client

type Config

type Config struct {
	// maxmind geoip2 db path
	Geoip2 string `yaml:"geoip2,omitempty"`
	// socks5+http proxy server listen addr
	Listen string `yaml:"listen"`
	// advertised server addr
	Advertise *Advertise `yaml:"advertise,omitempty"`
	// toh server list
	Servers []*TohServer `yaml:"servers"`
	// group toh servers
	Groups []*ServerGroup `yaml:"groups,omitempty"`
	// local network settings
	LocalNet *LocalNet `yaml:"localnet,omitempty"`
}

type Group

type Group struct {
	// contains filtered or unexported fields
}

type GroupInfo

type GroupInfo struct {
	Name    string       `json:"name"`
	Servers []ServerInfo `json:"servers"`
}

type Latency added in v0.11.4

type Latency struct {
	IPv4 time.Duration `json:"ipv4"`
	IPv6 time.Duration `json:"ipv6"`
}

type LocalNet added in v0.12.0

type LocalNet struct {
	// url that responds to any http status code. dual stack IP should be supported
	AddrFamilyDetectURL []string `yaml:"afdetect,omitempty"`
}

type LocalNetInfo added in v0.12.0

type LocalNetInfo struct {
	IPv6 bool `json:"ipv6"`
	IPv4 bool `json:"ipv4"`
}

type Options

type Options struct {
	// config from file
	Cfg Config
	// socks5+http listen address (specify this to override from config)
	Listen string
	// data root directory. i.e. $HOME/.config/toh
	DataRoot string
	// when using socks5 proxy dns query, if the query dns is consistent with the fake ip
	// the query request will be processed by the built-in local dns
	DNSFake []string
	// build-in local dns listen address
	DNSListen string
	// build-in local dns used upstream dns
	DNSUpstream string
	// how often query results are completely removed from the cache
	DNSEvict time.Duration
}

type OutboundInfo added in v0.10.0

type OutboundInfo struct {
	Group  string     `json:"group"`
	Server ServerInfo `json:"server"`
	Error  string     `json:"error"`
}

type S5Server

type S5Server struct {
	// contains filtered or unexported fields
}

func NewS5Server

func NewS5Server(opts Options) (s5Server *S5Server, err error)

func (*S5Server) Run

func (s *S5Server) Run() error

type Server

type Server struct {
	// contains filtered or unexported fields
}

type ServerGroup

type ServerGroup struct {
	// name to identify the server group
	Name string `yaml:"name"`
	// toh server name list from `servers` section
	Servers []string `yaml:"servers"`
	// same as `servers` section
	Ruleset []string `yaml:"ruleset"`
	// loadbalancer rule. Round Robin (rr) or Best Latency (bl), default is bl
	Loadbalancer string `yaml:"loadbalancer"`
}

type ServerInfo

type ServerInfo struct {
	Name      string             `json:"name"`
	Latency   *Latency           `json:"latency"`
	Limit     *api.Stats         `json:"limit"`
	Conntrack []client.ConnEntry `json:"conntrack"`
}

type TohServer

type TohServer struct {
	// name to identify the toh server
	Name string `yaml:"name"`
	// toh server adderss. i.e. https://fill-in-your-server-here.toh.sh/ws
	Addr string `yaml:"addr"`
	// toh server authcate key
	Key string `yaml:"key"`
	// this server is used when the remote accessed by the user hits this ruleset
	Ruleset []string `yaml:"ruleset,omitempty"`
	// url that responds to any http status code. dual stack IP should be supported
	Healthcheck []string `yaml:"healthcheck,omitempty"`
	// the interval send ping to the under websocket conn for keepalive
	Keepalive string `yaml:"keepalive,omitempty"`
	// customize the request header sent to the toh server
	Headers http.Header `yaml:"headers,omitempty"`
}

Jump to

Keyboard shortcuts

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