Documentation ¶
Index ¶
- Constants
- Variables
- func Can(action string, addr string, whitelist, blacklist *Permissions) bool
- func ClientObfsTLSConn(conn net.Conn, host string) net.Conn
- func Connect(conn net.Conn, addr string) (net.Conn, error)
- func Dial(addr string, options ...DialOption) (net.Conn, error)
- func GenCertificate() (cert tls.Certificate, err error)
- func Handshake(conn net.Conn, options ...HandshakeOption) (net.Conn, error)
- func IsIPv6Multicast(addr net.HardwareAddr) bool
- func Obfs4Init(node Node, isServeNode bool) error
- func ParseSSHAuthorizedKeysFile(fp string) (map[string]bool, error)
- func ParseSSHKeyFile(fp string) (ssh.Signer, error)
- func PeriodReload(r Reloader, configFile string) error
- func ServerObfsTLSConn(conn net.Conn, host string) net.Conn
- func SetLogger(logger log.Logger)
- type Accepter
- type Authenticator
- type Bypass
- func (bp *Bypass) AddMatchers(matchers ...Matcher)
- func (bp *Bypass) Contains(addr string) bool
- func (bp *Bypass) Matchers() []Matcher
- func (bp *Bypass) Period() time.Duration
- func (bp *Bypass) Reload(r io.Reader) error
- func (bp *Bypass) Reversed() bool
- func (bp *Bypass) Stop()
- func (bp *Bypass) Stopped() bool
- func (bp *Bypass) String() string
- type Chain
- func (c *Chain) AddNode(nodes ...Node)
- func (c *Chain) AddNodeGroup(groups ...*NodeGroup)
- func (c *Chain) Conn(opts ...ChainOption) (conn net.Conn, err error)
- func (c *Chain) Dial(address string, opts ...ChainOption) (conn net.Conn, err error)
- func (c *Chain) DialContext(ctx context.Context, network, address string, opts ...ChainOption) (conn net.Conn, err error)
- func (c *Chain) IsEmpty() bool
- func (c *Chain) LastNode() Node
- func (c *Chain) LastNodeGroup() *NodeGroup
- func (c *Chain) NodeGroups() []*NodeGroup
- func (c *Chain) Nodes() (nodes []Node)
- type ChainOption
- type ChainOptions
- type Client
- type ConnectOption
- func AddrConnectOption(addr string) ConnectOption
- func NoDelayConnectOption(b bool) ConnectOption
- func NoTLSConnectOption(b bool) ConnectOption
- func SelectorConnectOption(s gosocks5.Selector) ConnectOption
- func TimeoutConnectOption(timeout time.Duration) ConnectOption
- func UserAgentConnectOption(ua string) ConnectOption
- func UserConnectOption(user *url.Userinfo) ConnectOption
- type ConnectOptions
- type Connector
- func AutoConnector(user *url.Userinfo) Connector
- func ForwardConnector() Connector
- func HTTP2Connector(user *url.Userinfo) Connector
- func HTTPConnector(user *url.Userinfo) Connector
- func RelayConnector(user *url.Userinfo) Connector
- func SNIConnector(host string) Connector
- func SOCKS4AConnector() Connector
- func SOCKS4Connector() Connector
- func SOCKS5BindConnector(user *url.Userinfo) Connector
- func SOCKS5Connector(user *url.Userinfo) Connector
- func SOCKS5UDPConnector(user *url.Userinfo) Connector
- func SOCKS5UDPTunConnector(user *url.Userinfo) Connector
- func SSHDirectForwardConnector() Connector
- func SSHRemoteForwardConnector() Connector
- func ShadowConnector(info *url.Userinfo) Connector
- func ShadowUDPConnector(info *url.Userinfo) Connector
- func Socks5MuxBindConnector() Connector
- type DNSOptions
- type DialOption
- type DialOptions
- type Exchanger
- func NewDNSExchanger(addr string, opts ...ExchangerOption) Exchanger
- func NewDNSTCPExchanger(addr string, opts ...ExchangerOption) Exchanger
- func NewDoHExchanger(urlStr *url.URL, tlsConfig *tls.Config, opts ...ExchangerOption) Exchanger
- func NewDoTExchanger(addr string, tlsConfig *tls.Config, opts ...ExchangerOption) Exchanger
- type ExchangerOption
- type FIFOStrategy
- type FailFilter
- type FakeTCPListenConfig
- type Filter
- type Handler
- func AutoHandler(opts ...HandlerOption) Handler
- func DNSHandler(raddr string, opts ...HandlerOption) Handler
- func HTTP2Handler(opts ...HandlerOption) Handler
- func HTTPHandler(opts ...HandlerOption) Handler
- func RelayHandler(raddr string, opts ...HandlerOption) Handler
- func SNIHandler(opts ...HandlerOption) Handler
- func SOCKS4Handler(opts ...HandlerOption) Handler
- func SOCKS5Handler(opts ...HandlerOption) Handler
- func SSHForwardHandler(opts ...HandlerOption) Handler
- func ShadowHandler(opts ...HandlerOption) Handler
- func ShadowUDPHandler(opts ...HandlerOption) Handler
- func TCPDirectForwardHandler(raddr string, opts ...HandlerOption) Handler
- func TCPRedirectHandler(opts ...HandlerOption) Handler
- func TCPRemoteForwardHandler(raddr string, opts ...HandlerOption) Handler
- func TapHandler(opts ...HandlerOption) Handler
- func TunHandler(opts ...HandlerOption) Handler
- func UDPDirectForwardHandler(raddr string, opts ...HandlerOption) Handler
- func UDPRedirectHandler(opts ...HandlerOption) Handler
- func UDPRemoteForwardHandler(raddr string, opts ...HandlerOption) Handler
- type HandlerOption
- func AddrHandlerOption(addr string) HandlerOption
- func AuthenticatorHandlerOption(au Authenticator) HandlerOption
- func BlacklistHandlerOption(blacklist *Permissions) HandlerOption
- func BypassHandlerOption(bypass *Bypass) HandlerOption
- func ChainHandlerOption(chain *Chain) HandlerOption
- func FailTimeoutHandlerOption(d time.Duration) HandlerOption
- func HTTPTunnelHandlerOption(tunnelMode bool) HandlerOption
- func HostHandlerOption(host string) HandlerOption
- func HostsHandlerOption(hosts *Hosts) HandlerOption
- func IPRoutesHandlerOption(routes ...IPRoute) HandlerOption
- func IPsHandlerOption(ips []string) HandlerOption
- func KnockingHandlerOption(host string) HandlerOption
- func MaxFailsHandlerOption(n int) HandlerOption
- func NodeHandlerOption(node Node) HandlerOption
- func ProbeResistHandlerOption(pr string) HandlerOption
- func ProxyAgentHandlerOption(agent string) HandlerOption
- func ResolverHandlerOption(resolver Resolver) HandlerOption
- func RetryHandlerOption(retries int) HandlerOption
- func StrategyHandlerOption(strategy Strategy) HandlerOption
- func TCPModeHandlerOption(b bool) HandlerOption
- func TLSConfigHandlerOption(config *tls.Config) HandlerOption
- func TimeoutHandlerOption(timeout time.Duration) HandlerOption
- func UsersHandlerOption(users ...*url.Userinfo) HandlerOption
- func WhitelistHandlerOption(whitelist *Permissions) HandlerOption
- type HandlerOptions
- type HandshakeOption
- func AddrHandshakeOption(addr string) HandshakeOption
- func HostHandshakeOption(host string) HandshakeOption
- func IntervalHandshakeOption(interval time.Duration) HandshakeOption
- func KCPConfigHandshakeOption(config *KCPConfig) HandshakeOption
- func RetryHandshakeOption(retry int) HandshakeOption
- func SSHConfigHandshakeOption(config *SSHConfig) HandshakeOption
- func TLSConfigHandshakeOption(config *tls.Config) HandshakeOption
- func TimeoutHandshakeOption(timeout time.Duration) HandshakeOption
- func UserHandshakeOption(user *url.Userinfo) HandshakeOption
- func WSOptionsHandshakeOption(options *WSOptions) HandshakeOption
- type HandshakeOptions
- type Host
- type Hosts
- type IPRoute
- type InvalidFilter
- type KCPConfig
- type Listener
- func DNSListener(addr string, options *DNSOptions) (Listener, error)
- func FakeTCPListener(addr string, cfg *FakeTCPListenConfig) (Listener, error)
- func H2CListener(addr string, path string) (Listener, error)
- func H2Listener(addr string, config *tls.Config, path string) (Listener, error)
- func HTTP2Listener(addr string, config *tls.Config) (Listener, error)
- func KCPListener(addr string, config *KCPConfig) (Listener, error)
- func MTLSListener(addr string, config *tls.Config) (Listener, error)
- func MWSListener(addr string, options *WSOptions) (Listener, error)
- func MWSSListener(addr string, tlsConfig *tls.Config, options *WSOptions) (Listener, error)
- func Obfs4Listener(addr string) (Listener, error)
- func ObfsHTTPListener(addr string) (Listener, error)
- func ObfsTLSListener(addr string) (Listener, error)
- func SSHTunnelListener(addr string, config *SSHConfig) (Listener, error)
- func TCPListener(addr string) (Listener, error)
- func TCPRemoteForwardListener(addr string, chain *Chain) (Listener, error)
- func TLSListener(addr string, config *tls.Config) (Listener, error)
- func TapListener(cfg TapConfig) (Listener, error)
- func TunListener(cfg TunConfig) (Listener, error)
- func UDPListener(addr string, cfg *UDPListenConfig) (Listener, error)
- func UDPRedirectListener(addr string, cfg *UDPListenConfig) (Listener, error)
- func UDPRemoteForwardListener(addr string, chain *Chain, cfg *UDPListenConfig) (Listener, error)
- func WSListener(addr string, options *WSOptions) (Listener, error)
- func WSSListener(addr string, tlsConfig *tls.Config, options *WSOptions) (Listener, error)
- type LocalAuthenticator
- func (au *LocalAuthenticator) Add(k, v string)
- func (au *LocalAuthenticator) Authenticate(user, password string) bool
- func (au *LocalAuthenticator) Period() time.Duration
- func (au *LocalAuthenticator) Reload(r io.Reader) error
- func (au *LocalAuthenticator) Stop()
- func (au *LocalAuthenticator) Stopped() bool
- type LogLogger
- type Matcher
- type NameServer
- type NameServerOption
- type Node
- func (node *Node) Clone() Node
- func (node *Node) Get(key string) string
- func (node *Node) GetBool(key string) bool
- func (node *Node) GetDuration(key string) time.Duration
- func (node *Node) GetInt(key string) int
- func (node *Node) MarkDead()
- func (node *Node) ResetDead()
- func (node Node) String() string
- type NodeGroup
- func (group *NodeGroup) AddNode(node ...Node)
- func (group *NodeGroup) GetNode(i int) Node
- func (group *NodeGroup) Next() (node Node, err error)
- func (group *NodeGroup) Nodes() []Node
- func (group *NodeGroup) SetNodes(nodes ...Node) []Node
- func (group *NodeGroup) SetSelector(selector NodeSelector, opts ...SelectOption)
- type NodeSelector
- type NopLogger
- type PasswordCallbackFunc
- type Permission
- type Permissions
- type PortRange
- type PortSet
- type PublicKeyCallbackFunc
- type RandomStrategy
- type ReloadResolver
- type Reloader
- type Resolver
- type ResolverOption
- type RoundStrategy
- type SSHConfig
- type SelectOption
- type SelectOptions
- type Server
- type ServerOption
- type ServerOptions
- type Stoppable
- type Strategy
- type StringSet
- type TapConfig
- type TempError
- type Transporter
- func FakeTCPTransporter() Transporter
- func H2CTransporter(path string) Transporter
- func H2Transporter(config *tls.Config, path string) Transporter
- func HTTP2Transporter(config *tls.Config) Transporter
- func KCPTransporter(config *KCPConfig) Transporter
- func MTLSTransporter() Transporter
- func MWSSTransporter(opts *WSOptions) Transporter
- func MWSTransporter(opts *WSOptions) Transporter
- func Obfs4Transporter() Transporter
- func ObfsHTTPTransporter() Transporter
- func ObfsTLSTransporter() Transporter
- func SOCKS5MuxBindTransporter(bindAddr string) Transporter
- func SSHForwardTransporter() Transporter
- func SSHTunnelTransporter() Transporter
- func TCPTransporter() Transporter
- func TLSTransporter() Transporter
- func UDPTransporter() Transporter
- func WSSTransporter(opts *WSOptions) Transporter
- func WSTransporter(opts *WSOptions) Transporter
- type TunConfig
- type UDPListenConfig
- type WSOptions
Constants ¶
const ( DefaultMaxFails = 1 DefaultFailTimeout = 30 * time.Second )
default options for FailFilter
const ( // MethodTLS is an extended SOCKS5 method with tls encryption support. MethodTLS uint8 = 0x80 // MethodTLSAuth is an extended SOCKS5 method with tls encryption and authentication support. MethodTLSAuth uint8 = 0x82 // MethodMux is an extended SOCKS5 method for stream multiplexing. MethodMux = 0x88 )
const ( // CmdMuxBind is an extended SOCKS5 request CMD for // multiplexing transport with the binding server. CmdMuxBind uint8 = 0xF2 // CmdUDPTun is an extended SOCKS5 request CMD for UDP over TCP. CmdUDPTun uint8 = 0xF3 )
const ( DirectForwardRequest = "direct-tcpip" // RFC 4254 7.2 RemoteForwardRequest = "tcpip-forward" // RFC 4254 7.1 ForwardedTCPReturnRequest = "forwarded-tcpip" // RFC 4254 7.2 CancelRemoteForwardRequest = "cancel-tcpip-forward" // RFC 4254 7.1 GostSSHTunnelRequest = "gost-tunnel" // extended request type for ssh tunnel )
Applicable SSH Request types for Port Forwarding - RFC 4254 7.X
const Version = "2.11.5"
Version is the gost version.
Variables ¶
var ( // KeepAliveTime is the keep alive time period for TCP connection. KeepAliveTime = 180 * time.Second // DialTimeout is the timeout of dial. DialTimeout = 5 * time.Second // HandshakeTimeout is the timeout of handshake. HandshakeTimeout = 5 * time.Second // ConnectTimeout is the timeout for connect. ConnectTimeout = 5 * time.Second // ReadTimeout is the timeout for reading. ReadTimeout = 10 * time.Second // WriteTimeout is the timeout for writing. WriteTimeout = 10 * time.Second // PingTimeout is the timeout for pinging. PingTimeout = 30 * time.Second // PingRetries is the reties of ping. PingRetries = 1 )
var ( // DefaultTLSConfig is a default TLS config for internal use. DefaultTLSConfig *tls.Config // DefaultUserAgent is the default HTTP User-Agent header used by HTTP and websocket. DefaultUserAgent = "Chrome/78.0.3904.106" DefaultProxyAgent = "gost/" + Version // DefaultMTU is the default mtu for tun/tap device DefaultMTU = 1350 )
var ( ErrBadType = errors.New("bad type") ErrBadMajorVersion = errors.New("bad major version") ErrBadMinorVersion = errors.New("bad minor version") ErrMaxDataLen = errors.New("bad tls data len") )
var Debug bool
Debug is a flag that enables the debug log.
var DefaultClient = &Client{Connector: HTTPConnector(nil), Transporter: TCPTransporter()}
DefaultClient is a standard HTTP proxy client.
var ( // DefaultKCPConfig is the default KCP config. DefaultKCPConfig = KCPConfig{ Key: "it's a secrect", Crypt: "aes", Mode: "fast", MTU: 1350, SndWnd: 1024, RcvWnd: 1024, DataShard: 10, ParityShard: 3, DSCP: 0, NoComp: false, AckNodelay: false, NoDelay: 0, Interval: 50, Resend: 0, NoCongestion: 0, SockBuf: 4194304, SmuxVer: 1, SmuxBuf: 4194304, StreamBuf: 2097152, KeepAlive: 10, SnmpLog: "", SnmpPeriod: 60, Signal: false, TCP: false, } )
var ( // DefaultResolverTimeout is the default timeout for name resolution. DefaultResolverTimeout = 5 * time.Second )
var ( // ErrEmptyChain is an error that implies the chain is empty. ErrEmptyChain = errors.New("empty chain") )
var ( // ErrInvalidNode is an error that implies the node is invalid. ErrInvalidNode = errors.New("invalid node") )
var ( // ErrNoneAvailable indicates there is no node available. ErrNoneAvailable = errors.New("none node available") )
var (
// KCPSalt is the default salt for KCP cipher.
KCPSalt = "kcp-go"
)
Functions ¶
func Can ¶
func Can(action string, addr string, whitelist, blacklist *Permissions) bool
Can tests whether the given action and address is allowed by the whitelist and blacklist.
func ClientObfsTLSConn ¶
ClientObfsTLSConn creates a connection for obfs-tls client.
func Dial ¶
func Dial(addr string, options ...DialOption) (net.Conn, error)
Dial connects to the address addr via the DefaultClient.
func GenCertificate ¶
func GenCertificate() (cert tls.Certificate, err error)
GenCertificate generates a random TLS certificate.
func IsIPv6Multicast ¶
func IsIPv6Multicast(addr net.HardwareAddr) bool
IsIPv6Multicast reports whether the address addr is an IPv6 multicast address.
func ParseSSHAuthorizedKeysFile ¶
ParseSSHAuthorizedKeysFile parses ssh Authorized Keys file.
func ParseSSHKeyFile ¶
ParseSSHKeyFile parses ssh key file.
func PeriodReload ¶
PeriodReload reloads the config configFile periodically according to the period of the Reloader r.
func ServerObfsTLSConn ¶
ServerObfsTLSConn creates a connection for obfs-tls server.
Types ¶
type Authenticator ¶
Authenticator is an interface for user authentication.
type Bypass ¶
type Bypass struct {
// contains filtered or unexported fields
}
Bypass is a filter for address (IP or domain). It contains a list of matchers.
func NewBypass ¶
NewBypass creates and initializes a new Bypass using matchers as its match rules. The rules will be reversed if the reversed is true.
func NewBypassPatterns ¶
NewBypassPatterns creates and initializes a new Bypass using matcher patterns as its match rules. The rules will be reversed if the reverse is true.
func (*Bypass) AddMatchers ¶
AddMatchers appends matchers to the bypass matcher list.
type Chain ¶
type Chain struct { Retries int Mark int Interface string // contains filtered or unexported fields }
Chain is a proxy chain that holds a list of proxy node groups.
func NewChain ¶
NewChain creates a proxy chain with a list of proxy nodes. It creates the node groups automatically, one group per node.
func (*Chain) AddNodeGroup ¶
AddNodeGroup appends the group(s) to the chain.
func (*Chain) Conn ¶
func (c *Chain) Conn(opts ...ChainOption) (conn net.Conn, err error)
Conn obtains a handshaked connection to the last node of the chain.
func (*Chain) Dial ¶
Dial connects to the target TCP address addr through the chain. Deprecated: use DialContext instead.
func (*Chain) DialContext ¶
func (c *Chain) DialContext(ctx context.Context, network, address string, opts ...ChainOption) (conn net.Conn, err error)
DialContext connects to the address on the named network using the provided context.
func (*Chain) IsEmpty ¶
IsEmpty checks if the chain is empty. An empty chain means that there is no proxy node or node group in the chain.
func (*Chain) LastNode ¶
LastNode returns the last node of the node list. If the chain is empty, an empty node will be returned. If the last node is a node group, the first node in the group will be returned.
func (*Chain) LastNodeGroup ¶
LastNodeGroup returns the last group of the group list.
func (*Chain) NodeGroups ¶
NodeGroups returns the list of node group.
type ChainOption ¶
type ChainOption func(opts *ChainOptions)
ChainOption allows a common way to set chain options.
func HostsChainOption ¶
func HostsChainOption(hosts *Hosts) ChainOption
HostsChainOption specifies the hosts used by Chain.Dial.
func ResolverChainOption ¶
func ResolverChainOption(resolver Resolver) ChainOption
ResolverChainOption specifies the Resolver used by Chain.Dial.
func RetryChainOption ¶
func RetryChainOption(retries int) ChainOption
RetryChainOption specifies the times of retry used by Chain.Dial.
func TimeoutChainOption ¶
func TimeoutChainOption(timeout time.Duration) ChainOption
TimeoutChainOption specifies the timeout used by Chain.Dial.
type ChainOptions ¶
type ChainOptions struct { Retries int Timeout time.Duration Hosts *Hosts Resolver Resolver Mark int }
ChainOptions holds options for Chain.
type Client ¶
type Client struct { Connector Transporter }
Client is a proxy client. A client is divided into two layers: connector and transporter. Connector is responsible for connecting to the destination address through this proxy. Transporter performs a handshake with this proxy.
type ConnectOption ¶
type ConnectOption func(opts *ConnectOptions)
ConnectOption allows a common way to set ConnectOptions.
func AddrConnectOption ¶
func AddrConnectOption(addr string) ConnectOption
AddrConnectOption specifies the corresponding address of the target.
func NoDelayConnectOption ¶
func NoDelayConnectOption(b bool) ConnectOption
NoDelayConnectOption specifies the NoDelay option for ss.Connect.
func NoTLSConnectOption ¶
func NoTLSConnectOption(b bool) ConnectOption
NoTLSConnectOption specifies the SOCKS5 method without TLS.
func SelectorConnectOption ¶
func SelectorConnectOption(s gosocks5.Selector) ConnectOption
SelectorConnectOption specifies the SOCKS5 client selector.
func TimeoutConnectOption ¶
func TimeoutConnectOption(timeout time.Duration) ConnectOption
TimeoutConnectOption specifies the timeout for connecting to target.
func UserAgentConnectOption ¶
func UserAgentConnectOption(ua string) ConnectOption
UserAgentConnectOption specifies the HTTP user-agent header.
func UserConnectOption ¶
func UserConnectOption(user *url.Userinfo) ConnectOption
UserConnectOption specifies the user info for authentication.
type ConnectOptions ¶
type ConnectOptions struct { Addr string Timeout time.Duration User *url.Userinfo Selector gosocks5.Selector UserAgent string NoTLS bool NoDelay bool }
ConnectOptions describes the options for Connector.Connect.
type Connector ¶
type Connector interface { // Deprecated: use ConnectContext instead. Connect(conn net.Conn, address string, options ...ConnectOption) (net.Conn, error) ConnectContext(ctx context.Context, conn net.Conn, network, address string, options ...ConnectOption) (net.Conn, error) }
Connector is responsible for connecting to the destination address.
func ForwardConnector ¶
func ForwardConnector() Connector
ForwardConnector creates a Connector for data forward client.
func HTTP2Connector ¶
HTTP2Connector creates a Connector for HTTP2 proxy client. It accepts an optional auth info for HTTP Basic Authentication.
func HTTPConnector ¶
HTTPConnector creates a Connector for HTTP proxy client. It accepts an optional auth info for HTTP Basic Authentication.
func RelayConnector ¶
RelayConnector creates a Connector for TCP/UDP data relay.
func SNIConnector ¶
SNIConnector creates a Connector for SNI proxy client.
func SOCKS4AConnector ¶
func SOCKS4AConnector() Connector
SOCKS4AConnector creates a Connector for SOCKS4A proxy client.
func SOCKS4Connector ¶
func SOCKS4Connector() Connector
SOCKS4Connector creates a Connector for SOCKS4 proxy client.
func SOCKS5BindConnector ¶
SOCKS5BindConnector creates a connector for SOCKS5 bind. It accepts an optional auth info for SOCKS5 Username/Password Authentication.
func SOCKS5Connector ¶
SOCKS5Connector creates a connector for SOCKS5 proxy client. It accepts an optional auth info for SOCKS5 Username/Password Authentication.
func SOCKS5UDPConnector ¶
SOCKS5UDPConnector creates a connector for SOCKS5 UDP relay. It accepts an optional auth info for SOCKS5 Username/Password Authentication.
func SOCKS5UDPTunConnector ¶
SOCKS5UDPTunConnector creates a connector for SOCKS5 UDP-over-TCP relay. It accepts an optional auth info for SOCKS5 Username/Password Authentication.
func SSHDirectForwardConnector ¶
func SSHDirectForwardConnector() Connector
SSHDirectForwardConnector creates a Connector for SSH TCP direct port forwarding.
func SSHRemoteForwardConnector ¶
func SSHRemoteForwardConnector() Connector
SSHRemoteForwardConnector creates a Connector for SSH TCP remote port forwarding.
func ShadowConnector ¶
ShadowConnector creates a Connector for shadowsocks proxy client. It accepts an optional cipher info for shadowsocks data encryption/decryption.
func ShadowUDPConnector ¶
ShadowUDPConnector creates a Connector for shadowsocks UDP client. It accepts an optional cipher info for shadowsocks data encryption/decryption.
func Socks5MuxBindConnector ¶
func Socks5MuxBindConnector() Connector
Socks5MuxBindConnector creates a Connector for SOCKS5 multiplex bind client.
type DNSOptions ¶
type DNSOptions struct { Mode string UDPSize int ReadTimeout time.Duration WriteTimeout time.Duration TLSConfig *tls.Config }
DNSOptions is options for DNS Listener.
type DialOption ¶
type DialOption func(opts *DialOptions)
DialOption allows a common way to set DialOptions.
func ChainDialOption ¶
func ChainDialOption(chain *Chain) DialOption
ChainDialOption specifies a chain used by Transporter.Dial
func HostDialOption ¶
func HostDialOption(host string) DialOption
HostDialOption specifies the host used by Transporter.Dial
func TimeoutDialOption ¶
func TimeoutDialOption(timeout time.Duration) DialOption
TimeoutDialOption specifies the timeout used by Transporter.Dial
type DialOptions ¶
DialOptions describes the options for Transporter.Dial.
type Exchanger ¶
Exchanger is an interface for DNS synchronous query.
func NewDNSExchanger ¶
func NewDNSExchanger(addr string, opts ...ExchangerOption) Exchanger
NewDNSExchanger creates a DNS over UDP Exchanger
func NewDNSTCPExchanger ¶
func NewDNSTCPExchanger(addr string, opts ...ExchangerOption) Exchanger
NewDNSTCPExchanger creates a DNS over TCP Exchanger
func NewDoHExchanger ¶
NewDoHExchanger creates a DNS over HTTPS Exchanger
func NewDoTExchanger ¶
func NewDoTExchanger(addr string, tlsConfig *tls.Config, opts ...ExchangerOption) Exchanger
NewDoTExchanger creates a DNS over TLS Exchanger
type ExchangerOption ¶
type ExchangerOption func(opts *exchangerOptions)
ExchangerOption allows a common way to set Exchanger options.
func ChainExchangerOption ¶
func ChainExchangerOption(chain *Chain) ExchangerOption
ChainExchangerOption sets the chain for Exchanger.
func TimeoutExchangerOption ¶
func TimeoutExchangerOption(timeout time.Duration) ExchangerOption
TimeoutExchangerOption sets the timeout for Exchanger.
type FIFOStrategy ¶
type FIFOStrategy struct{}
FIFOStrategy is a strategy for node selector. The node will be selected from first to last, and will stick to the selected node until it is failed.
func (*FIFOStrategy) Apply ¶
func (s *FIFOStrategy) Apply(nodes []Node) Node
Apply applies the fifo strategy for the nodes.
func (*FIFOStrategy) String ¶
func (s *FIFOStrategy) String() string
type FailFilter ¶
FailFilter filters the dead node. A node is marked as dead if its failed count is greater than MaxFails.
func (*FailFilter) Filter ¶
func (f *FailFilter) Filter(nodes []Node) []Node
Filter filters dead nodes.
func (*FailFilter) String ¶
func (f *FailFilter) String() string
type FakeTCPListenConfig ¶
FakeTCPListenConfig is config for fake TCP Listener.
type Handler ¶
type Handler interface { Init(options ...HandlerOption) Handle(net.Conn) }
Handler is a proxy server handler
func AutoHandler ¶
func AutoHandler(opts ...HandlerOption) Handler
AutoHandler creates a server Handler for auto proxy server.
func DNSHandler ¶
func DNSHandler(raddr string, opts ...HandlerOption) Handler
DNSHandler creates a Handler for DNS server.
func HTTP2Handler ¶
func HTTP2Handler(opts ...HandlerOption) Handler
HTTP2Handler creates a server Handler for HTTP2 proxy server.
func HTTPHandler ¶
func HTTPHandler(opts ...HandlerOption) Handler
HTTPHandler creates a server Handler for HTTP proxy server.
func RelayHandler ¶
func RelayHandler(raddr string, opts ...HandlerOption) Handler
RelayHandler creates a server Handler for TCP/UDP relay server.
func SNIHandler ¶
func SNIHandler(opts ...HandlerOption) Handler
SNIHandler creates a server Handler for SNI proxy server.
func SOCKS4Handler ¶
func SOCKS4Handler(opts ...HandlerOption) Handler
SOCKS4Handler creates a server Handler for SOCKS4(A) proxy server.
func SOCKS5Handler ¶
func SOCKS5Handler(opts ...HandlerOption) Handler
SOCKS5Handler creates a server Handler for SOCKS5 proxy server.
func SSHForwardHandler ¶
func SSHForwardHandler(opts ...HandlerOption) Handler
SSHForwardHandler creates a server Handler for SSH port forwarding server.
func ShadowHandler ¶
func ShadowHandler(opts ...HandlerOption) Handler
ShadowHandler creates a server Handler for shadowsocks proxy server.
func ShadowUDPHandler ¶
func ShadowUDPHandler(opts ...HandlerOption) Handler
ShadowUDPHandler creates a server Handler for shadowsocks UDP relay server.
func TCPDirectForwardHandler ¶
func TCPDirectForwardHandler(raddr string, opts ...HandlerOption) Handler
TCPDirectForwardHandler creates a server Handler for TCP port forwarding server. The raddr is the remote address that the server will forward to. NOTE: as of 2.6, remote address can be a comma-separated address list.
func TCPRedirectHandler ¶
func TCPRedirectHandler(opts ...HandlerOption) Handler
TCPRedirectHandler creates a server Handler for TCP transparent server.
func TCPRemoteForwardHandler ¶
func TCPRemoteForwardHandler(raddr string, opts ...HandlerOption) Handler
TCPRemoteForwardHandler creates a server Handler for TCP remote port forwarding server. The raddr is the remote address that the server will forward to. NOTE: as of 2.6, remote address can be a comma-separated address list.
func TapHandler ¶
func TapHandler(opts ...HandlerOption) Handler
TapHandler creates a handler for tap tunnel.
func TunHandler ¶
func TunHandler(opts ...HandlerOption) Handler
TunHandler creates a handler for tun tunnel.
func UDPDirectForwardHandler ¶
func UDPDirectForwardHandler(raddr string, opts ...HandlerOption) Handler
UDPDirectForwardHandler creates a server Handler for UDP port forwarding server. The raddr is the remote address that the server will forward to. NOTE: as of 2.6, remote address can be a comma-separated address list.
func UDPRedirectHandler ¶
func UDPRedirectHandler(opts ...HandlerOption) Handler
UDPRedirectHandler creates a server Handler for UDP transparent server.
func UDPRemoteForwardHandler ¶
func UDPRemoteForwardHandler(raddr string, opts ...HandlerOption) Handler
UDPRemoteForwardHandler creates a server Handler for UDP remote port forwarding server. The raddr is the remote address that the server will forward to. NOTE: as of 2.6, remote address can be a comma-separated address list.
type HandlerOption ¶
type HandlerOption func(opts *HandlerOptions)
HandlerOption allows a common way to set handler options.
func AddrHandlerOption ¶
func AddrHandlerOption(addr string) HandlerOption
AddrHandlerOption sets the Addr option of HandlerOptions.
func AuthenticatorHandlerOption ¶
func AuthenticatorHandlerOption(au Authenticator) HandlerOption
AuthenticatorHandlerOption sets the Authenticator option of HandlerOptions.
func BlacklistHandlerOption ¶
func BlacklistHandlerOption(blacklist *Permissions) HandlerOption
BlacklistHandlerOption sets the Blacklist option of HandlerOptions.
func BypassHandlerOption ¶
func BypassHandlerOption(bypass *Bypass) HandlerOption
BypassHandlerOption sets the bypass option of HandlerOptions.
func ChainHandlerOption ¶
func ChainHandlerOption(chain *Chain) HandlerOption
ChainHandlerOption sets the Chain option of HandlerOptions.
func FailTimeoutHandlerOption ¶
func FailTimeoutHandlerOption(d time.Duration) HandlerOption
FailTimeoutHandlerOption sets the fail_timeout option of HandlerOptions.
func HTTPTunnelHandlerOption ¶ added in v0.0.3
func HTTPTunnelHandlerOption(tunnelMode bool) HandlerOption
HTTPTunnelHandlerOption sets the Tunnel mode for HTTP client used in HTTP handler.
func HostHandlerOption ¶
func HostHandlerOption(host string) HandlerOption
HostHandlerOption sets the target host for SNI proxy.
func HostsHandlerOption ¶
func HostsHandlerOption(hosts *Hosts) HandlerOption
HostsHandlerOption sets the Hosts option of HandlerOptions.
func IPRoutesHandlerOption ¶
func IPRoutesHandlerOption(routes ...IPRoute) HandlerOption
IPRoutesHandlerOption sets the IP routes for tun tunnel.
func IPsHandlerOption ¶
func IPsHandlerOption(ips []string) HandlerOption
IPsHandlerOption sets the ip list for port forward.
func KnockingHandlerOption ¶
func KnockingHandlerOption(host string) HandlerOption
KnockingHandlerOption adds the knocking host for probe resistance.
func MaxFailsHandlerOption ¶
func MaxFailsHandlerOption(n int) HandlerOption
MaxFailsHandlerOption sets the max_fails option of HandlerOptions.
func NodeHandlerOption ¶
func NodeHandlerOption(node Node) HandlerOption
NodeHandlerOption set the server node for server handler.
func ProbeResistHandlerOption ¶
func ProbeResistHandlerOption(pr string) HandlerOption
ProbeResistHandlerOption adds the probe resistance for HTTP proxy.
func ProxyAgentHandlerOption ¶ added in v0.0.3
func ProxyAgentHandlerOption(agent string) HandlerOption
ProxyAgentHandlerOption sets the proxy agent for http handler.
func ResolverHandlerOption ¶
func ResolverHandlerOption(resolver Resolver) HandlerOption
ResolverHandlerOption sets the resolver option of HandlerOptions.
func RetryHandlerOption ¶
func RetryHandlerOption(retries int) HandlerOption
RetryHandlerOption sets the retry option of HandlerOptions.
func StrategyHandlerOption ¶
func StrategyHandlerOption(strategy Strategy) HandlerOption
StrategyHandlerOption sets the strategy option of HandlerOptions.
func TCPModeHandlerOption ¶
func TCPModeHandlerOption(b bool) HandlerOption
TCPModeHandlerOption sets the tcp mode for tun/tap device.
func TLSConfigHandlerOption ¶
func TLSConfigHandlerOption(config *tls.Config) HandlerOption
TLSConfigHandlerOption sets the TLSConfig option of HandlerOptions.
func TimeoutHandlerOption ¶
func TimeoutHandlerOption(timeout time.Duration) HandlerOption
TimeoutHandlerOption sets the timeout option of HandlerOptions.
func UsersHandlerOption ¶
func UsersHandlerOption(users ...*url.Userinfo) HandlerOption
UsersHandlerOption sets the Users option of HandlerOptions.
func WhitelistHandlerOption ¶
func WhitelistHandlerOption(whitelist *Permissions) HandlerOption
WhitelistHandlerOption sets the Whitelist option of HandlerOptions.
type HandlerOptions ¶
type HandlerOptions struct { Addr string Chain *Chain Users []*url.Userinfo Authenticator Authenticator TLSConfig *tls.Config Whitelist *Permissions Blacklist *Permissions Strategy Strategy MaxFails int FailTimeout time.Duration Bypass *Bypass Retries int Timeout time.Duration Resolver Resolver Hosts *Hosts ProbeResist string KnockingHost string Node Node Host string IPs []string TCPMode bool IPRoutes []IPRoute ProxyAgent string HTTPTunnel bool }
HandlerOptions describes the options for Handler.
type HandshakeOption ¶
type HandshakeOption func(opts *HandshakeOptions)
HandshakeOption allows a common way to set HandshakeOptions.
func AddrHandshakeOption ¶
func AddrHandshakeOption(addr string) HandshakeOption
AddrHandshakeOption specifies the server address
func HostHandshakeOption ¶
func HostHandshakeOption(host string) HandshakeOption
HostHandshakeOption specifies the hostname
func IntervalHandshakeOption ¶
func IntervalHandshakeOption(interval time.Duration) HandshakeOption
IntervalHandshakeOption specifies the interval time used by Transporter.Handshake
func KCPConfigHandshakeOption ¶
func KCPConfigHandshakeOption(config *KCPConfig) HandshakeOption
KCPConfigHandshakeOption specifies the KCP config used by KCP handshake
func RetryHandshakeOption ¶
func RetryHandshakeOption(retry int) HandshakeOption
RetryHandshakeOption specifies the times of retry used by Transporter.Handshake
func SSHConfigHandshakeOption ¶
func SSHConfigHandshakeOption(config *SSHConfig) HandshakeOption
SSHConfigHandshakeOption specifies the ssh config used by SSH client handshake.
func TLSConfigHandshakeOption ¶
func TLSConfigHandshakeOption(config *tls.Config) HandshakeOption
TLSConfigHandshakeOption specifies the TLS config used by Transporter.Handshake
func TimeoutHandshakeOption ¶
func TimeoutHandshakeOption(timeout time.Duration) HandshakeOption
TimeoutHandshakeOption specifies the timeout used by Transporter.Handshake
func UserHandshakeOption ¶
func UserHandshakeOption(user *url.Userinfo) HandshakeOption
UserHandshakeOption specifies the user used by Transporter.Handshake
func WSOptionsHandshakeOption ¶
func WSOptionsHandshakeOption(options *WSOptions) HandshakeOption
WSOptionsHandshakeOption specifies the websocket options used by websocket handshake
type HandshakeOptions ¶
type HandshakeOptions struct { Addr string Host string User *url.Userinfo Timeout time.Duration Interval time.Duration Retry int TLSConfig *tls.Config WSOptions *WSOptions KCPConfig *KCPConfig SSHConfig *SSHConfig }
HandshakeOptions describes the options for handshake.
type Hosts ¶
type Hosts struct {
// contains filtered or unexported fields
}
Hosts is a static table lookup for hostnames. For each host a single line should be present with the following information: IP_address canonical_hostname [aliases...] Fields of the entry are separated by any number of blanks and/or tab characters. Text from a "#" character until the end of the line is a comment, and is ignored.
func (*Hosts) Lookup ¶
Lookup searches the IP address corresponds to the given host from the host table.
type InvalidFilter ¶
type InvalidFilter struct{}
InvalidFilter filters the invalid node. A node is invalid if its port is invalid (negative or zero value).
func (*InvalidFilter) Filter ¶
func (f *InvalidFilter) Filter(nodes []Node) []Node
Filter filters invalid nodes.
func (*InvalidFilter) String ¶
func (f *InvalidFilter) String() string
type KCPConfig ¶
type KCPConfig struct { Key string `json:"key"` Crypt string `json:"crypt"` Mode string `json:"mode"` MTU int `json:"mtu"` SndWnd int `json:"sndwnd"` RcvWnd int `json:"rcvwnd"` DataShard int `json:"datashard"` ParityShard int `json:"parityshard"` DSCP int `json:"dscp"` NoComp bool `json:"nocomp"` AckNodelay bool `json:"acknodelay"` NoDelay int `json:"nodelay"` Interval int `json:"interval"` Resend int `json:"resend"` NoCongestion int `json:"nc"` SockBuf int `json:"sockbuf"` SmuxBuf int `json:"smuxbuf"` StreamBuf int `json:"streambuf"` SmuxVer int `json:"smuxver"` KeepAlive int `json:"keepalive"` SnmpLog string `json:"snmplog"` SnmpPeriod int `json:"snmpperiod"` Signal bool `json:"signal"` // Signal enables the signal SIGUSR1 feature. TCP bool `json:"tcp"` }
KCPConfig describes the config for KCP.
type Listener ¶
Listener is a proxy server listener, just like a net.Listener.
func DNSListener ¶
func DNSListener(addr string, options *DNSOptions) (Listener, error)
DNSListener creates a Listener for DNS proxy server.
func FakeTCPListener ¶
func FakeTCPListener(addr string, cfg *FakeTCPListenConfig) (Listener, error)
FakeTCPListener creates a Listener for fake TCP server.
func H2CListener ¶
H2CListener creates a Listener for HTTP2 h2c tunnel server.
func H2Listener ¶
H2Listener creates a Listener for HTTP2 h2 tunnel server.
func HTTP2Listener ¶
HTTP2Listener creates a Listener for HTTP2 proxy server.
func KCPListener ¶
KCPListener creates a Listener for KCP proxy server.
func MTLSListener ¶
MTLSListener creates a Listener for multiplex-TLS proxy server.
func MWSListener ¶
MWSListener creates a Listener for multiplex-websocket proxy server.
func MWSSListener ¶
MWSSListener creates a Listener for multiplex-websocket secure proxy server.
func Obfs4Listener ¶
Obfs4Listener creates a Listener for obfs4 server.
func ObfsHTTPListener ¶
ObfsHTTPListener creates a Listener for HTTP obfuscating tunnel server.
func ObfsTLSListener ¶
ObfsTLSListener creates a Listener for TLS obfuscating server.
func SSHTunnelListener ¶
SSHTunnelListener creates a Listener for SSH tunnel server.
func TCPListener ¶
TCPListener creates a Listener for TCP proxy server.
func TCPRemoteForwardListener ¶
TCPRemoteForwardListener creates a Listener for TCP remote port forwarding server.
func TLSListener ¶
TLSListener creates a Listener for TLS proxy server.
func TapListener ¶
TapListener creates a listener for tap tunnel.
func TunListener ¶
TunListener creates a listener for tun tunnel.
func UDPListener ¶
func UDPListener(addr string, cfg *UDPListenConfig) (Listener, error)
UDPListener creates a Listener for UDP server.
func UDPRedirectListener ¶
func UDPRedirectListener(addr string, cfg *UDPListenConfig) (Listener, error)
UDPRedirectListener creates a Listener for UDP transparent proxy server.
func UDPRemoteForwardListener ¶
func UDPRemoteForwardListener(addr string, chain *Chain, cfg *UDPListenConfig) (Listener, error)
UDPRemoteForwardListener creates a Listener for UDP remote port forwarding server.
func WSListener ¶
WSListener creates a Listener for websocket proxy server.
type LocalAuthenticator ¶
type LocalAuthenticator struct {
// contains filtered or unexported fields
}
LocalAuthenticator is an Authenticator that authenticates client by local key-value pairs.
func NewLocalAuthenticator ¶
func NewLocalAuthenticator(kvs map[string]string) *LocalAuthenticator
NewLocalAuthenticator creates an Authenticator that authenticates client by local infos.
func (*LocalAuthenticator) Add ¶
func (au *LocalAuthenticator) Add(k, v string)
Add adds a key-value pair to the Authenticator.
func (*LocalAuthenticator) Authenticate ¶
func (au *LocalAuthenticator) Authenticate(user, password string) bool
Authenticate checks the validity of the provided user-password pair.
func (*LocalAuthenticator) Period ¶
func (au *LocalAuthenticator) Period() time.Duration
Period returns the reload period.
func (*LocalAuthenticator) Reload ¶
func (au *LocalAuthenticator) Reload(r io.Reader) error
Reload parses config from r, then live reloads the Authenticator.
func (*LocalAuthenticator) Stopped ¶
func (au *LocalAuthenticator) Stopped() bool
Stopped checks whether the reloader is stopped.
type LogLogger ¶
type LogLogger struct { }
LogLogger uses the standard log package as the logger
type Matcher ¶
Matcher is a generic pattern matcher, it gives the match result of the given pattern for specific v.
func CIDRMatcher ¶
CIDRMatcher creates a Matcher for a specific CIDR notation IP address.
func DomainMatcher ¶
DomainMatcher creates a Matcher for a specific domain pattern, the pattern can be a plain domain such as 'example.com', a wildcard such as '*.exmaple.com' or a special wildcard '.example.com'.
func NewMatcher ¶
NewMatcher creates a Matcher for the given pattern. The acutal Matcher depends on the pattern: IP Matcher if pattern is a valid IP address. CIDR Matcher if pattern is a valid CIDR address. Domain Matcher if both of the above are not.
type NameServer ¶
type NameServer struct { Addr string Protocol string Hostname string // for TLS handshake verification // contains filtered or unexported fields }
NameServer is a name server. Currently supported protocol: TCP, UDP and TLS.
func (*NameServer) Init ¶
func (ns *NameServer) Init(opts ...NameServerOption) error
Init initializes the name server.
func (*NameServer) String ¶
func (ns *NameServer) String() string
type NameServerOption ¶
type NameServerOption func(*nameServerOptions)
NameServerOption allows a common way to set name server options.
func ChainNameServerOption ¶
func ChainNameServerOption(chain *Chain) NameServerOption
ChainNameServerOption sets the chain for name server.
func TimeoutNameServerOption ¶
func TimeoutNameServerOption(timeout time.Duration) NameServerOption
TimeoutNameServerOption sets the timeout for name server.
type Node ¶
type Node struct { ID int Addr string Host string Protocol string Transport string Remote string // remote address, used by tcp/udp port forwarding User *url.Userinfo Values url.Values DialOptions []DialOption HandshakeOptions []HandshakeOption ConnectOptions []ConnectOption Client *Client Bypass *Bypass // contains filtered or unexported fields }
Node is a proxy node, mainly used to construct a proxy chain.
func ParseNode ¶
ParseNode parses the node info. The proxy node string pattern is [scheme://][user:pass@host]:port. Scheme can be divided into two parts by character '+', such as: http+tls.
func (*Node) GetDuration ¶
GetDuration converts node parameter value to time.Duration.
type NodeGroup ¶
type NodeGroup struct { ID int // contains filtered or unexported fields }
NodeGroup is a group of nodes.
func (*NodeGroup) SetNodes ¶
SetNodes replaces the group nodes to the specified nodes, and returns the previous nodes.
func (*NodeGroup) SetSelector ¶
func (group *NodeGroup) SetSelector(selector NodeSelector, opts ...SelectOption)
SetSelector sets node selector with options for the group.
type NodeSelector ¶
type NodeSelector interface {
Select(nodes []Node, opts ...SelectOption) (Node, error)
}
NodeSelector as a mechanism to pick nodes and mark their status.
type NopLogger ¶
type NopLogger struct { }
NopLogger is a dummy logger that discards the log outputs
type PasswordCallbackFunc ¶
type PasswordCallbackFunc func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error)
PasswordCallbackFunc is a callback function used by SSH server. It authenticates user using a password.
type Permission ¶
Permission is a rule for blacklist and whitelist.
type Permissions ¶
type Permissions []Permission
Permissions is a set of Permission.
func ParsePermissions ¶
func ParsePermissions(s string) (*Permissions, error)
ParsePermissions parses the s to a Permissions.
type PortRange ¶
type PortRange struct {
Min, Max int
}
PortRange specifies the range of port, such as 1000-2000.
func ParsePortRange ¶
ParsePortRange parses the s to a PortRange. The s may be a '*' means 0-65535.
type PortSet ¶
type PortSet []PortRange
PortSet is a set of PortRange
func ParsePortSet ¶
ParsePortSet parses the s to a PortSet. The s shoud be a comma separated string.
type PublicKeyCallbackFunc ¶
type PublicKeyCallbackFunc func(c ssh.ConnMetadata, pubKey ssh.PublicKey) (*ssh.Permissions, error)
PublicKeyCallbackFunc is a callback function used by SSH server. It offers a public key for authentication.
type RandomStrategy ¶
type RandomStrategy struct { Seed int64 // contains filtered or unexported fields }
RandomStrategy is a strategy for node selector. The node will be selected randomly.
func (*RandomStrategy) Apply ¶
func (s *RandomStrategy) Apply(nodes []Node) Node
Apply applies the random strategy for the nodes.
func (*RandomStrategy) String ¶
func (s *RandomStrategy) String() string
type ReloadResolver ¶
ReloadResolver is resolover that support live reloading.
func NewResolver ¶
func NewResolver(ttl time.Duration, servers ...NameServer) ReloadResolver
NewResolver create a new Resolver with the given name servers and resolution timeout.
type Resolver ¶
type Resolver interface { // Init initializes the Resolver instance. Init(opts ...ResolverOption) error // Resolve returns a slice of that host's IPv4 and IPv6 addresses. Resolve(host string) ([]net.IP, error) // Exchange performs a synchronous query, // It sends the message query and waits for a reply. Exchange(ctx context.Context, query []byte) (reply []byte, err error) }
Resolver is a name resolver for domain name. It contains a list of name servers.
type ResolverOption ¶
type ResolverOption func(*resolverOptions)
ResolverOption allows a common way to set Resolver options.
func ChainResolverOption ¶
func ChainResolverOption(chain *Chain) ResolverOption
ChainResolverOption sets the chain for Resolver.
func PreferResolverOption ¶
func PreferResolverOption(prefer string) ResolverOption
PreferResolverOption sets the prefer for Resolver.
func SrcIPResolverOption ¶
func SrcIPResolverOption(ip net.IP) ResolverOption
SrcIPResolverOption sets the source IP for Resolver.
func TTLResolverOption ¶
func TTLResolverOption(ttl time.Duration) ResolverOption
TTLResolverOption sets the timeout for Resolver.
func TimeoutResolverOption ¶
func TimeoutResolverOption(timeout time.Duration) ResolverOption
TimeoutResolverOption sets the timeout for Resolver.
type RoundStrategy ¶
type RoundStrategy struct {
// contains filtered or unexported fields
}
RoundStrategy is a strategy for node selector. The node will be selected by round-robin algorithm.
func (*RoundStrategy) Apply ¶
func (s *RoundStrategy) Apply(nodes []Node) Node
Apply applies the round-robin strategy for the nodes.
func (*RoundStrategy) String ¶
func (s *RoundStrategy) String() string
type SSHConfig ¶
type SSHConfig struct { Authenticator Authenticator TLSConfig *tls.Config Key ssh.Signer AuthorizedKeys map[string]bool }
SSHConfig holds the SSH tunnel server config
type SelectOption ¶
type SelectOption func(*SelectOptions)
SelectOption is the option used when making a select call.
func WithFilter ¶
func WithFilter(f ...Filter) SelectOption
WithFilter adds a filter function to the list of filters used during the Select call.
func WithStrategy ¶
func WithStrategy(s Strategy) SelectOption
WithStrategy sets the selector strategy
type SelectOptions ¶
SelectOptions is the options for node selection.
type Server ¶
Server is a proxy server.
func (*Server) Init ¶
func (s *Server) Init(opts ...ServerOption)
Init intializes server with given options.
type ServerOption ¶
type ServerOption func(opts *ServerOptions)
ServerOption allows a common way to set server options.
type Stoppable ¶
type Stoppable interface { Stop() Stopped() bool }
Stoppable is the interface that indicates a Reloader can be stopped.
type Strategy ¶
Strategy is a selection strategy e.g random, round-robin.
func NewStrategy ¶
NewStrategy creates a Strategy by the name s.
type StringSet ¶
type StringSet []string
StringSet is a set of string.
func ParseStringSet ¶
ParseStringSet parses the s to a StringSet. The s shoud be a comma separated string.
type TempError ¶ added in v0.0.3
type TempError struct {
// contains filtered or unexported fields
}
TempError satisfies the net.Error interface and presents itself as temporary to make sure that it gets retried by the Accept loop in server.go.
type Transporter ¶
type Transporter interface { Dial(addr string, options ...DialOption) (net.Conn, error) Handshake(conn net.Conn, options ...HandshakeOption) (net.Conn, error) // Indicate that the Transporter supports multiplex Multiplex() bool }
Transporter is responsible for handshaking with the proxy server.
func FakeTCPTransporter ¶
func FakeTCPTransporter() Transporter
FakeTCPTransporter creates a Transporter that is used by fake tcp client.
func H2CTransporter ¶
func H2CTransporter(path string) Transporter
H2CTransporter creates a Transporter that is used by HTTP2 h2c tunnel client.
func H2Transporter ¶
func H2Transporter(config *tls.Config, path string) Transporter
H2Transporter creates a Transporter that is used by HTTP2 h2 tunnel client.
func HTTP2Transporter ¶
func HTTP2Transporter(config *tls.Config) Transporter
HTTP2Transporter creates a Transporter that is used by HTTP2 h2 proxy client.
func KCPTransporter ¶
func KCPTransporter(config *KCPConfig) Transporter
KCPTransporter creates a Transporter that is used by KCP proxy client.
func MTLSTransporter ¶
func MTLSTransporter() Transporter
MTLSTransporter creates a Transporter that is used by multiplex-TLS proxy client.
func MWSSTransporter ¶
func MWSSTransporter(opts *WSOptions) Transporter
MWSSTransporter creates a Transporter that is used by multiplex-websocket secure proxy client.
func MWSTransporter ¶
func MWSTransporter(opts *WSOptions) Transporter
MWSTransporter creates a Transporter that is used by multiplex-websocket proxy client.
func Obfs4Transporter ¶
func Obfs4Transporter() Transporter
Obfs4Transporter creates a Transporter that is used by obfs4 client.
func ObfsHTTPTransporter ¶
func ObfsHTTPTransporter() Transporter
ObfsHTTPTransporter creates a Transporter that is used by HTTP obfuscating tunnel client.
func ObfsTLSTransporter ¶
func ObfsTLSTransporter() Transporter
ObfsTLSTransporter creates a Transporter that is used by TLS obfuscating.
func SOCKS5MuxBindTransporter ¶
func SOCKS5MuxBindTransporter(bindAddr string) Transporter
SOCKS5MuxBindTransporter creates a Transporter for SOCKS5 multiplex bind client.
func SSHForwardTransporter ¶
func SSHForwardTransporter() Transporter
SSHForwardTransporter creates a Transporter that is used by SSH port forwarding server.
func SSHTunnelTransporter ¶
func SSHTunnelTransporter() Transporter
SSHTunnelTransporter creates a Transporter that is used by SSH tunnel client.
func TLSTransporter ¶
func TLSTransporter() Transporter
TLSTransporter creates a Transporter that is used by TLS proxy client.
func UDPTransporter ¶
func UDPTransporter() Transporter
UDPTransporter creates a Transporter for UDP client.
func WSSTransporter ¶
func WSSTransporter(opts *WSOptions) Transporter
WSSTransporter creates a Transporter that is used by websocket secure proxy client.
func WSTransporter ¶
func WSTransporter(opts *WSOptions) Transporter
WSTransporter creates a Transporter that is used by websocket proxy client.
type TunConfig ¶
type TunConfig struct { Name string Addr string Peer string // peer addr of point-to-point on MacOS MTU int Routes []IPRoute Gateway string }
TunConfig is the config for TUN device.
Source Files ¶
- auth.go
- bypass.go
- chain.go
- client.go
- dns.go
- forward.go
- ftcp.go
- gost.go
- handler.go
- hosts.go
- http.go
- http2.go
- kcp.go
- log.go
- mux.go
- node.go
- obfs.go
- permissions.go
- redirect.go
- relay.go
- reload.go
- resolver.go
- selector.go
- server.go
- signal_unix.go
- sni.go
- sockopts_linux.go
- socks.go
- ss.go
- ssh.go
- tcp.go
- tls.go
- tuntap.go
- tuntap_linux.go
- udp.go
- ws.go