client

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 36 Imported by: 44

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector added in v0.53.0

type Connector interface {
	Open() error
	Connect() (net.Conn, error)
	Close() error
}

Connector is an interface for establishing connections to the server.

func NewConnector added in v0.53.0

func NewConnector(ctx context.Context, cfg *v1.ClientCommonConfig) Connector

type Control

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

func NewControl

func NewControl(ctx context.Context, sessionCtx *SessionContext) (*Control, error)

func (*Control) Close added in v0.13.0

func (ctl *Control) Close() error

func (*Control) Done added in v0.53.0

func (ctl *Control) Done() <-chan struct{}

Done returns a channel that will be closed after all resources are released

func (*Control) GracefulClose added in v0.38.0

func (ctl *Control) GracefulClose(d time.Duration) error

func (*Control) Run

func (ctl *Control) Run(proxyCfgs []v1.ProxyConfigurer, visitorCfgs []v1.VisitorConfigurer)

func (*Control) SetInWorkConnCallback added in v0.53.0

func (ctl *Control) SetInWorkConnCallback(cb func(*v1.ProxyBaseConfig, net.Conn, *msg.StartWorkConn) bool)

func (*Control) UpdateAllConfigurer added in v0.53.0

func (ctl *Control) UpdateAllConfigurer(proxyCfgs []v1.ProxyConfigurer, visitorCfgs []v1.VisitorConfigurer) error

type GeneralResponse added in v0.13.0

type GeneralResponse struct {
	Code int
	Msg  string
}

type ProxyStatusResp added in v0.15.0

type ProxyStatusResp struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	Status     string `json:"status"`
	Err        string `json:"err"`
	LocalAddr  string `json:"local_addr"`
	Plugin     string `json:"plugin"`
	RemoteAddr string `json:"remote_addr"`
}

func NewProxyStatusResp added in v0.15.0

func NewProxyStatusResp(status *proxy.WorkingStatus, serverAddr string) ProxyStatusResp

type Service

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

Service is the client service that connects to frps and provides proxy services.

func NewService

func NewService(options ServiceOptions) (*Service, error)

func (*Service) Close added in v0.13.0

func (svr *Service) Close()

func (*Service) GracefulClose added in v0.38.0

func (svr *Service) GracefulClose(d time.Duration)

func (*Service) Run

func (svr *Service) Run(ctx context.Context) error

func (*Service) StatusExporter added in v0.58.0

func (svr *Service) StatusExporter() StatusExporter

func (*Service) UpdateAllConfigurer added in v0.53.0

func (svr *Service) UpdateAllConfigurer(proxyCfgs []v1.ProxyConfigurer, visitorCfgs []v1.VisitorConfigurer) error

type ServiceOptions added in v0.53.0

type ServiceOptions struct {
	Common      *v1.ClientCommonConfig
	ProxyCfgs   []v1.ProxyConfigurer
	VisitorCfgs []v1.VisitorConfigurer

	// ConfigFilePath is the path to the configuration file used to initialize.
	// If it is empty, it means that the configuration file is not used for initialization.
	// It may be initialized using command line parameters or called directly.
	ConfigFilePath string

	// ClientSpec is the client specification that control the client behavior.
	ClientSpec *msg.ClientSpec

	// ConnectorCreator is a function that creates a new connector to make connections to the server.
	// The Connector shields the underlying connection details, whether it is through TCP or QUIC connection,
	// and regardless of whether multiplexing is used.
	//
	// If it is not set, the default frpc connector will be used.
	// By using a custom Connector, it can be used to implement a VirtualClient, which connects to frps
	// through a pipe instead of a real physical connection.
	ConnectorCreator func(context.Context, *v1.ClientCommonConfig) Connector

	// HandleWorkConnCb is a callback function that is called when a new work connection is created.
	//
	// If it is not set, the default frpc implementation will be used.
	HandleWorkConnCb func(*v1.ProxyBaseConfig, net.Conn, *msg.StartWorkConn) bool
}

ServiceOptions contains options for creating a new client service.

type SessionContext added in v0.53.0

type SessionContext struct {
	// The client common configuration.
	Common *v1.ClientCommonConfig

	// Unique ID obtained from frps.
	// It should be attached to the login message when reconnecting.
	RunID string
	// Underlying control connection. Once conn is closed, the msgDispatcher and the entire Control will exit.
	Conn net.Conn
	// Indicates whether the connection is encrypted.
	ConnEncrypted bool
	// Sets authentication based on selected method
	AuthSetter auth.Setter
	// Connector is used to create new connections, which could be real TCP connections or virtual streams.
	Connector Connector
}

type StatusExporter added in v0.58.0

type StatusExporter interface {
	GetProxyStatus(name string) (*proxy.WorkingStatus, bool)
}

type StatusResp added in v0.15.0

type StatusResp map[string][]ProxyStatusResp

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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