server

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: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseOutConf

type BaseOutConf struct {
	v1.ProxyBaseConfig
}

type CloseUserResp

type CloseUserResp struct {
	Status int    `json:"status"`
	Msg    string `json:"message"`
}

POST /api/client/kick

type Control

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

func NewControl

func NewControl(
	ctx context.Context,
	rc *controller.ResourceController,
	pxyManager *proxy.Manager,
	pluginManager *plugin.Manager,
	authVerifier auth.Verifier,
	ctlConn net.Conn,
	ctlConnEncrypted bool,
	loginMsg *msg.Login,
	serverCfg *v1.ServerConfig,
) (*Control, error)

TODO(fatedier): Referencing the implementation of frpc, encapsulate the input parameters as SessionContext.

func (*Control) Close

func (ctl *Control) Close() error

func (*Control) CloseProxy

func (ctl *Control) CloseProxy(closeMsg *msg.CloseProxy) (err error)

func (*Control) GetWorkConn

func (ctl *Control) GetWorkConn() (workConn net.Conn, err error)

When frps get one user connection, we get one work connection from the pool and return it. If no workConn available in the pool, send message to frpc to get one or more and wait until it is available. return an error if wait timeout

func (*Control) RegisterProxy

func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy) (remoteAddr string, err error)

func (*Control) RegisterWorkConn

func (ctl *Control) RegisterWorkConn(conn net.Conn) error

func (*Control) Replaced

func (ctl *Control) Replaced(newCtl *Control)

func (*Control) Start

func (ctl *Control) Start()

Start send a login success message to client and start working.

func (*Control) WaitClosed

func (ctl *Control) WaitClosed()

block until Control closed

type ControlManager

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

func NewControlManager

func NewControlManager() *ControlManager

func (*ControlManager) Add

func (cm *ControlManager) Add(runID string, ctl *Control) (old *Control)

func (*ControlManager) Close

func (cm *ControlManager) Close() error

func (*ControlManager) Del

func (cm *ControlManager) Del(runID string, ctl *Control)

we should make sure if it's the same control to prevent delete a new one

func (*ControlManager) GetByID

func (cm *ControlManager) GetByID(runID string) (ctl *Control, ok bool)

type GeneralResponse

type GeneralResponse struct {
	Code int
	Msg  string
}

type GetProxyInfoResp

type GetProxyInfoResp struct {
	Proxies []*ProxyStatsInfo `json:"proxies"`
}

type GetProxyStatsResp

type GetProxyStatsResp struct {
	Name            string `json:"name"`
	RunID           string `json:"runId"`
	Conf            any    `json:"conf"`
	TodayTrafficIn  int64  `json:"todayTrafficIn"`
	TodayTrafficOut int64  `json:"todayTrafficOut"`
	CurConns        int64  `json:"curConns"`
	LastStartTime   string `json:"lastStartTime"`
	LastCloseTime   string `json:"lastCloseTime"`
	Status          string `json:"status"`
}

GET /api/proxy/{type}/{name}

type GetProxyTrafficResp

type GetProxyTrafficResp struct {
	Name       string  `json:"name"`
	TrafficIn  []int64 `json:"trafficIn"`
	TrafficOut []int64 `json:"trafficOut"`
}

GET /api/traffic/:name

type HTTPOutConf

type HTTPOutConf struct {
	BaseOutConf
	v1.DomainConfig
	Locations         []string `json:"locations"`
	HostHeaderRewrite string   `json:"hostHeaderRewrite"`
}

type HTTPSOutConf

type HTTPSOutConf struct {
	BaseOutConf
	v1.DomainConfig
}

type LoadData

type LoadData struct {
	IP                string  `json:"ip"`
	LoadScore         float64 `json:"load_score"`
	CurrentConns      int64   `json:"current_conns"`
	PeakConns         int64   `json:"peak_conns"`
	CurrentTraffic    int64   `json:"current_traffic"`
	PeakTraffic       int64   `json:"peak_traffic"`
	CPUUsage          float64 `json:"cpu_usage"`
	MemUsage          float64 `json:"mem_usage"`
	ConnGrowthRate    float64 `json:"conn_growth_rate"`
	TrafficGrowthRate float64 `json:"traffic_growth_rate"`
	Timestamp         int64   `json:"timestamp"`
}

LoadData 负载上报数据结构

type LoadMonitor

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

LoadMonitor 负载监控器

func NewLoadMonitor

func NewLoadMonitor() *LoadMonitor

NewLoadMonitor 创建新的负载监控器

func (*LoadMonitor) Start

func (lm *LoadMonitor) Start()

Start 启动负载监控

func (*LoadMonitor) Stop

func (lm *LoadMonitor) Stop()

Stop 停止负载监控

type ProxyStatsInfo

type ProxyStatsInfo struct {
	Name            string `json:"name"`
	RunID           string `json:"runId"`
	Conf            any    `json:"conf"`
	ClientVersion   string `json:"clientVersion,omitempty"`
	TodayTrafficIn  int64  `json:"todayTrafficIn"`
	TodayTrafficOut int64  `json:"todayTrafficOut"`
	CurConns        int64  `json:"curConns"`
	LastStartTime   string `json:"lastStartTime"`
	LastCloseTime   string `json:"lastCloseTime"`
	Status          string `json:"status"`
}

Get proxy info.

type STCPOutConf

type STCPOutConf struct {
	BaseOutConf
}

type Service

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

Server service

func NewService

func NewService(cfg *v1.ServerConfig) (*Service, error)

func (*Service) AddToBlacklist

func (svr *Service) AddToBlacklist(runID string, duration time.Duration)

添加客户端到黑名单

func (*Service) Close

func (svr *Service) Close() error

func (*Service) HandleListener

func (svr *Service) HandleListener(l net.Listener, internal bool)

HandleListener accepts connections from client and call handleConnection to handle them. If internal is true, it means that this listener is used for internal communication like ssh tunnel gateway. TODO(fatedier): Pass some parameters of listener/connection through context to avoid passing too many parameters.

func (*Service) HandleQUICListener

func (svr *Service) HandleQUICListener(l *quic.Listener)

func (*Service) IsInBlacklist

func (svr *Service) IsInBlacklist(runID string) bool

检查客户端是否在黑名单中

func (*Service) RegisterControl

func (svr *Service) RegisterControl(ctlConn net.Conn, loginMsg *msg.Login, internal bool) error

func (*Service) RegisterVisitorConn

func (svr *Service) RegisterVisitorConn(visitorConn net.Conn, newMsg *msg.NewVisitorConn) error

func (*Service) RegisterWorkConn

func (svr *Service) RegisterWorkConn(workConn net.Conn, newMsg *msg.NewWorkConn) error

RegisterWorkConn register a new work connection to control and proxies need it.

func (*Service) Run

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

type TCPMuxOutConf

type TCPMuxOutConf struct {
	BaseOutConf
	v1.DomainConfig
	Multiplexer     string `json:"multiplexer"`
	RouteByHTTPUser string `json:"routeByHTTPUser"`
}

type TCPOutConf

type TCPOutConf struct {
	BaseOutConf
	RemotePort int `json:"remotePort"`
}

type TrafficTrendResp

type TrafficTrendResp struct {
	Timestamps []string `json:"timestamps"`
	InData     []int64  `json:"inData"`
	OutData    []int64  `json:"outData"`
}

GET /api/traffic/trend 流量趋势数据

type UDPOutConf

type UDPOutConf struct {
	BaseOutConf
	RemotePort int `json:"remotePort"`
}

type XTCPOutConf

type XTCPOutConf struct {
	BaseOutConf
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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