Versions in this module Expand all Collapse all v2 v2.12.1 Apr 17, 2021 Changes in this version + var BAD_CREDENTIALS = newResponseStatus(407, "Wrong password") + var DISABLED = newResponseStatus(407, "Disabled") + var EXPIRED = newResponseStatus(407, "Expired") + var IP_NOT_AVAILABLE = newResponseStatus(407, "Current IP is not available") + var IP_NOT_MATCHED = newResponseStatus(407, "The current IP is not bound") + var MSG_NO_VALID_PROXY = newResponseStatus(407, "Invalid proxy") + var NOT_AUTHORIZATION = newResponseStatus(407, "No Proxy-Authorization or Authorization can be found") + var NOT_FOUND = newResponseStatus(407, "Not found") + var NOT_FOUND_OR_EXPIRED = newResponseStatus(407, "Not found or expired") + var NOT_NUMBER = newResponseStatus(407, "Appkey is not a number") + var PROXY_TYPE_MISMATCHING = newResponseStatus(407, "Proxy type mismatch") + var REMAINING_NOT_ENOUGH = newResponseStatus(407, "Remaining not enough") + var TUNNEL_OVER_FREQ_LIMIT = newResponseStatus(http.StatusTooManyRequests, http.StatusText(http.StatusTooManyRequests)) + var UN_KNOW_ERROR = newResponseStatus(500, "Unknown exception") + type ResponseStatus struct + func ParseStatus(reasonPhrase string) *ResponseStatus + func (status *ResponseStatus) GetReasonPhrase() string + func (status *ResponseStatus) GetStatus() string + func (status *ResponseStatus) GetStatusCode() int v2.11.2 Apr 17, 2021 Changes in this version + const CancelRemoteForwardRequest + const CmdMuxBind + const CmdUDPTun + const DefaultFailTimeout + const DefaultMaxFails + const DirectForwardRequest + const ForwardedTCPReturnRequest + const GostSSHTunnelRequest + const MethodMux + const MethodTLS + const MethodTLSAuth + const RemoteForwardRequest + const Version + var ConnectTimeout = 5 * time.Second + var Debug bool + var DefaultClient = &Client + var DefaultKCPConfig = KCPConfig + var DefaultMTU = 1350 + var DefaultResolverTimeout = 5 * time.Second + var DefaultTLSConfig *tls.Config + var DefaultUserAgent = "Chrome/78.0.3904.106" + var DialTimeout = 5 * time.Second + var ErrBadMajorVersion = errors.New("bad major version") + var ErrBadMinorVersion = errors.New("bad minor version") + var ErrBadType = errors.New("bad type") + var ErrEmptyChain = errors.New("empty chain") + var ErrInvalidNode = errors.New("invalid node") + var ErrMaxDataLen = errors.New("bad tls data len") + var ErrNoneAvailable = errors.New("none available") + var HandshakeTimeout = 5 * time.Second + var KCPSalt = "kcp-go" + var KeepAliveTime = 180 * time.Second + var PingRetries = 1 + var PingTimeout = 30 * time.Second + var ReadTimeout = 10 * time.Second + var WriteTimeout = 10 * time.Second + 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 interface + Accept func() (net.Conn, error) + type Authenticator interface + Authenticate func(user, password string) bool + type Bypass struct + func NewBypass(reversed bool, matchers ...Matcher) *Bypass + func NewBypassPatterns(reversed bool, patterns ...string) *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 struct + Retries int + func NewChain(nodes ...Node) *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 func(opts *ChainOptions) + func HostsChainOption(hosts *Hosts) ChainOption + func ResolverChainOption(resolver Resolver) ChainOption + func RetryChainOption(retries int) ChainOption + func TimeoutChainOption(timeout time.Duration) ChainOption + type ChainOptions struct + Hosts *Hosts + Resolver Resolver + Retries int + Timeout time.Duration + type Client struct + type ConnectOption func(opts *ConnectOptions) + 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 struct + Addr string + NoDelay bool + NoTLS bool + Selector gosocks5.Selector + Timeout time.Duration + User *url.Userinfo + UserAgent string + type Connector interface + Connect func(conn net.Conn, address string, options ...ConnectOption) (net.Conn, error) + ConnectContext func(ctx context.Context, conn net.Conn, network, address string, ...) (net.Conn, error) + 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 struct + Mode string + ReadTimeout time.Duration + TLSConfig *tls.Config + UDPSize int + WriteTimeout time.Duration + type DialOption func(opts *DialOptions) + func ChainDialOption(chain *Chain) DialOption + func HostDialOption(host string) DialOption + func TimeoutDialOption(timeout time.Duration) DialOption + type DialOptions struct + Chain *Chain + Host string + Timeout time.Duration + type Exchanger interface + Exchange func(ctx context.Context, query []byte) ([]byte, error) + 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 func(opts *exchangerOptions) + func ChainExchangerOption(chain *Chain) ExchangerOption + func TimeoutExchangerOption(timeout time.Duration) ExchangerOption + type FIFOStrategy struct + func (s *FIFOStrategy) Apply(nodes []Node) Node + func (s *FIFOStrategy) String() string + type FailFilter struct + FailTimeout time.Duration + MaxFails int + func (f *FailFilter) Filter(nodes []Node) []Node + func (f *FailFilter) String() string + type FakeTCPListenConfig struct + Backlog int + QueueSize int + TTL time.Duration + type Filter interface + Filter func([]Node) []Node + String func() string + type Handler interface + Handle func(net.Conn) + Init func(options ...HandlerOption) + 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(opts *HandlerOptions) + 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 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 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 struct + Addr string + Authenticator Authenticator + Blacklist *Permissions + Bypass *Bypass + Chain *Chain + FailTimeout time.Duration + Host string + Hosts *Hosts + IPRoutes []IPRoute + IPs []string + KnockingHost string + MaxFails int + Node Node + ProbeResist string + Resolver Resolver + Retries int + Strategy Strategy + TCPMode bool + TLSConfig *tls.Config + Timeout time.Duration + Users []*url.Userinfo + Whitelist *Permissions + type HandshakeOption func(opts *HandshakeOptions) + func AddrHandshakeOption(addr string) HandshakeOption + func HostHandshakeOption(host string) HandshakeOption + func IntervalHandshakeOption(interval time.Duration) HandshakeOption + func KCPConfigHandshakeOption(config *KCPConfig) HandshakeOption + func QUICConfigHandshakeOption(config *QUICConfig) 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 struct + Addr string + Host string + Interval time.Duration + KCPConfig *KCPConfig + QUICConfig *QUICConfig + Retry int + SSHConfig *SSHConfig + TLSConfig *tls.Config + Timeout time.Duration + User *url.Userinfo + WSOptions *WSOptions + type Host struct + Aliases []string + Hostname string + IP net.IP + func NewHost(ip net.IP, hostname string, aliases ...string) Host + type Hosts struct + func NewHosts(hosts ...Host) *Hosts + func (h *Hosts) AddHost(host ...Host) + func (h *Hosts) Lookup(host string) (ip net.IP) + func (h *Hosts) Period() time.Duration + func (h *Hosts) Reload(r io.Reader) error + func (h *Hosts) Stop() + func (h *Hosts) Stopped() bool + type IPRoute struct + Dest *net.IPNet + Gateway net.IP + type InvalidFilter struct + func (f *InvalidFilter) Filter(nodes []Node) []Node + func (f *InvalidFilter) String() string + type KCPConfig struct + AckNodelay bool + Crypt string + DSCP int + DataShard int + Interval int + KeepAlive int + Key string + MTU int + Mode string + NoComp bool + NoCongestion int + NoDelay int + ParityShard int + RcvWnd int + Resend int + Signal bool + SndWnd int + SnmpLog string + SnmpPeriod int + SockBuf int + TCP bool + func (c *KCPConfig) Init() + type Listener interface + 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 QUICListener(addr string, config *QUICConfig) (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 struct + func NewLocalAuthenticator(kvs map[string]string) *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 struct + func (l *LogLogger) Log(v ...interface{}) + func (l *LogLogger) Logf(format string, v ...interface{}) + type Matcher interface + Match func(v string) bool + String func() string + func CIDRMatcher(inet *net.IPNet) Matcher + func DomainMatcher(pattern string) Matcher + func IPMatcher(ip net.IP) Matcher + func NewMatcher(pattern string) Matcher + type NameServer struct + Addr string + Hostname string + Protocol string + func (ns *NameServer) Init(opts ...NameServerOption) error + func (ns *NameServer) String() string + type NameServerOption func(*nameServerOptions) + func ChainNameServerOption(chain *Chain) NameServerOption + func TimeoutNameServerOption(timeout time.Duration) NameServerOption + type Node struct + Addr string + Bypass *Bypass + Client *Client + ConnectOptions []ConnectOption + DialOptions []DialOption + HandshakeOptions []HandshakeOption + Host string + ID int + Protocol string + Remote string + Transport string + User *url.Userinfo + Values url.Values + func ParseNode(s string) (node Node, err error) + 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 struct + ID int + func NewNodeGroup(nodes ...Node) *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 interface + Select func(nodes []Node, opts ...SelectOption) (Node, error) + type NopLogger struct + func (l *NopLogger) Log(v ...interface{}) + func (l *NopLogger) Logf(format string, v ...interface{}) + type PasswordCallbackFunc func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error) + type Permission struct + Actions StringSet + Hosts StringSet + Ports PortSet + type Permissions []Permission + func ParsePermissions(s string) (*Permissions, error) + func (ps *Permissions) Can(action string, host string, port int) bool + type PortRange struct + Max int + Min int + func ParsePortRange(s string) (*PortRange, error) + func (ir *PortRange) Contains(value int) bool + type PortSet []PortRange + func ParsePortSet(s string) (*PortSet, error) + func (ps *PortSet) Contains(value int) bool + type PublicKeyCallbackFunc func(c ssh.ConnMetadata, pubKey ssh.PublicKey) (*ssh.Permissions, error) + type QUICConfig struct + IdleTimeout time.Duration + KeepAlive bool + Key []byte + TLSConfig *tls.Config + Timeout time.Duration + type RandomStrategy struct + Seed int64 + func (s *RandomStrategy) Apply(nodes []Node) Node + func (s *RandomStrategy) String() string + type ReloadResolver interface + func NewResolver(ttl time.Duration, servers ...NameServer) ReloadResolver + type Reloader interface + Period func() time.Duration + Reload func(r io.Reader) error + type Resolver interface + Exchange func(ctx context.Context, query []byte) (reply []byte, err error) + Init func(opts ...ResolverOption) error + Resolve func(host string) ([]net.IP, error) + type ResolverOption func(*resolverOptions) + func ChainResolverOption(chain *Chain) ResolverOption + func PreferResolverOption(prefer string) ResolverOption + func SrcIPResolverOption(ip net.IP) ResolverOption + func TTLResolverOption(ttl time.Duration) ResolverOption + func TimeoutResolverOption(timeout time.Duration) ResolverOption + type RoundStrategy struct + func (s *RoundStrategy) Apply(nodes []Node) Node + func (s *RoundStrategy) String() string + type SSHConfig struct + Authenticator Authenticator + AuthorizedKeys map[string]bool + Key ssh.Signer + TLSConfig *tls.Config + type SelectOption func(*SelectOptions) + func WithFilter(f ...Filter) SelectOption + func WithStrategy(s Strategy) SelectOption + type SelectOptions struct + Filters []Filter + Strategy Strategy + type Server struct + Handler Handler + Listener Listener + func (s *Server) Addr() net.Addr + func (s *Server) Close() error + func (s *Server) Init(opts ...ServerOption) + func (s *Server) Run() error + func (s *Server) Serve(h Handler, opts ...ServerOption) error + type ServerOption func(opts *ServerOptions) + type ServerOptions struct + type Stoppable interface + Stop func() + Stopped func() bool + type Strategy interface + Apply func([]Node) Node + String func() string + func NewStrategy(s string) Strategy + type StringSet []string + func ParseStringSet(s string) (*StringSet, error) + func (ss *StringSet) Contains(subj string) bool + type TapConfig struct + Addr string + Gateway string + MTU int + Name string + Routes []string + type Transporter interface + Dial func(addr string, options ...DialOption) (net.Conn, error) + Handshake func(conn net.Conn, options ...HandshakeOption) (net.Conn, error) + Multiplex func() bool + 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 QUICTransporter(config *QUICConfig) 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 struct + Addr string + Gateway string + MTU int + Name string + Peer string + Routes []IPRoute + type UDPListenConfig struct + Backlog int + QueueSize int + TTL time.Duration + type WSOptions struct + EnableCompression bool + HandshakeTimeout time.Duration + Path string + ReadBufferSize int + UserAgent string + WriteBufferSize int Other modules containing this package github.com/lemos1235/gost