Documentation ¶
Index ¶
- Variables
- func AddPluginOption(opPlugin OptionPlugin) error
- func AddPluginRequest(redirect RequestPlugin) error
- func AddPluginVersion(verPlugin VersionPlugin) error
- func NewHttpClient() (*http.Client, *http.Transport)
- type Handles
- func (hdl *Handles) CliWait(once *sync.Once)
- func (hdl *Handles) CreateServerConn(c *Options, ctx context.Context) (*wss.WebSocketClient, error)
- func (hdl *Handles) NegotiateVersion(ctx context.Context, remoteUrl string) error
- func (hdl *Handles) NotifyClose(once *sync.Once, wait bool)
- func (hdl *Handles) StartClient(c *Options, once *sync.Once)
- func (hdl *Handles) Wait() error
- type OptionPlugin
- type Options
- type Plugins
- type RequestPlugin
- type VersionPlugin
Constants ¶
This section is empty.
Variables ¶
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
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
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
CreateServerConn create a server websocket connection based on user options.
func (*Handles) NegotiateVersion ¶ added in v0.5.0
func (*Handles) NotifyClose ¶ added in v0.5.0
NotifyClose send closing message to all running tasks
func (*Handles) StartClient ¶ added in v0.5.0
type OptionPlugin ¶ added in v0.5.0
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
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
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
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
}