client

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 16 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPluginOccupied = errors.New("the plugin is occupied by another plugin")

Functions

func AddPluginOption added in v0.5.0

func AddPluginOption(opPlugin OptionPlugin) error

add an option plugin

func AddPluginRequest added in v0.5.0

func AddPluginRequest(redirect RequestPlugin) error

add a request plugin

func AddPluginVersion added in v0.3.0

func AddPluginVersion(verPlugin VersionPlugin) error

add a version plugin

func NewHttpClient added in v0.5.0

func NewHttpClient() (*http.Client, *http.Transport)

Types

type Handles added in v0.3.1

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

func NewClientHandles added in v0.5.0

func NewClientHandles() *Handles

func (*Handles) CliWait added in v0.6.0

func (hdl *Handles) CliWait(once *sync.Once)

CliWait can be used in cli env to wait service to finish. similar to Wait, but CliWait is usually used in cli.

func (*Handles) CreateServerConn added in v0.5.0

func (hdl *Handles) CreateServerConn(c *Options, ctx context.Context) (*wss.WebSocketClient, error)

CreateServerConn create a server websocket connection based on user options.

func (*Handles) NegotiateVersion added in v0.5.0

func (hdl *Handles) NegotiateVersion(ctx context.Context, remoteUrl string) error

func (*Handles) NotifyClose added in v0.5.0

func (hdl *Handles) NotifyClose(once *sync.Once, wait bool)

NotifyClose send closing message to all running tasks

func (*Handles) StartClient added in v0.5.0

func (hdl *Handles) StartClient(c *Options, once *sync.Once)

func (*Handles) Wait added in v0.5.0

func (hdl *Handles) Wait() error

Wait waits an error in client connection. If the connection lost or any other connection error happens, Wait will return an error.

type OptionPlugin added in v0.5.0

type OptionPlugin interface {
	OnOptionSet(options Options) error
}

pass read-only connection option to OnOptionSet when options are set. we can check connection options by returning an error and may set RemoteUrl here.

type Options added in v0.5.0

type Options struct {
	LocalSocks5Addr string      // local listening address
	HttpEnabled     bool        // enable http and https proxy
	LocalHttpAddr   string      // listen address of http and https(if it is enabled)
	RemoteUrl       *url.URL    // url of server
	RemoteHeaders   http.Header // parsed websocket headers (not presented in flag).
	ConnectionKey   string      // connection key for authentication
	SkipTLSVerify   bool        // skip TSL verify
}

type Plugins added in v0.5.0

type Plugins struct {
	OptionPlugin  OptionPlugin
	RequestPlugin RequestPlugin
	VersionPlugin VersionPlugin
}

Plugins is a collection of all possible plugins on client

func (*Plugins) HasOptionPlugin added in v0.5.0

func (plugin *Plugins) HasOptionPlugin() bool

check whether the option plugin has been added. this plugin can only be at most one instance.

func (*Plugins) HasRequestPlugin added in v0.5.0

func (plugin *Plugins) HasRequestPlugin() bool

check whether the request plugin has been added. this plugin can only be at most one instance.

func (*Plugins) HasVersionPlugin added in v0.5.0

func (plugin *Plugins) HasVersionPlugin() bool

type RequestPlugin added in v0.5.0

type RequestPlugin interface {
	BeforeRequest(hc *http.Client, transport *http.Transport, url *url.URL, header *http.Header) error
}

in the plugin, we may add http header and modify remote address.

type VersionPlugin added in v0.3.0

type VersionPlugin interface {
	OnServerVersion(ver wss.VersionNeg) error
}

Jump to

Keyboard shortcuts

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