Documentation ¶
Index ¶
- func FindNordVpnServer(ctx context.Context) (host string, err error)
- type Server
- type ServerOption
- func WithAddr(addr string) ServerOption
- func WithOnConnect(fn func(id int64, conn net.Conn)) ServerOption
- func WithOnDisconnect(fn func(id int64, conn net.Conn)) ServerOption
- func WithOnError(fn func(id int64, conn net.Conn, err error)) ServerOption
- func WithServerFinder(fn func(context.Context) (string, error)) ServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Server ¶
type Server struct { Addr string RemoteHost string RemoteUser string RemotePass string ConnCount atomic.Int64 OpenConnCount atomic.Int32 // contains filtered or unexported fields }
func NewServer ¶
func NewServer(remoteHost, remoteUser, remotePass string, opts ...ServerOption) *Server
NewServer creates a new SOCKS5 server if the remoteHost is empty the server will try to find a server using the serverFinder function specified in the WithServerFinder option (default is FindNordVpnServer) if the remoteUser and remotePass are empty the server will not authenticate with the remote server, so it is just a simple SOCKS5 proxy, no auth.
type ServerOption ¶
type ServerOption func(*Server)
func WithAddr ¶
func WithAddr(addr string) ServerOption
WithAddr sets the address the server will listen on Default is ":1080"
func WithOnConnect ¶
func WithOnConnect(fn func(id int64, conn net.Conn)) ServerOption
WithOnConnect sets the onConnect callback which is called when a new connection is accepted To not block the server the callback is called in a new goroutine
func WithOnDisconnect ¶
func WithOnDisconnect(fn func(id int64, conn net.Conn)) ServerOption
WithOnDisconnect sets the onDisconnect callback which is called when a connection is closed To not block the server the callback is called in a new goroutine
func WithOnError ¶
func WithOnError(fn func(id int64, conn net.Conn, err error)) ServerOption
WithOnError sets the onError callback which is called when an error occurs on a connection. If the error occurs while accepting a connection the id is 0 and the conn argument will be nil To not block the server the callback is called in a new goroutine
func WithServerFinder ¶
func WithServerFinder(fn func(context.Context) (string, error)) ServerOption
WithServerFinder sets the function to find a SOCKS5 server if no remoteHost is provided Default will find a NordVPN server and try to authenticate with it