Help us shape the future of Go! Take the 2026 Go Developer Survey

client

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

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

Connector is an interface for establishing connections to the server.

func NewConnector

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

func (ctl *Control) Close() error

func (*Control) Done

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

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

func (*Control) GracefulClose

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

func (*Control) Run

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

func (*Control) SetInWorkConnCallback

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

func (*Control) UpdateAllConfigurer

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

type GeneralResponse

type GeneralResponse struct {
	Code int
	Msg  string
}

type ProxyStatusResp

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

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

func (svr *Service) Close()

func (*Service) GracefulClose

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

func (*Service) Run

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

func (*Service) StatusExporter

func (svr *Service) StatusExporter() StatusExporter

func (*Service) UpdateAllConfigurer

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

type ServiceOptions

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

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

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

type StatusResp

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