Documentation ¶
Index ¶
- Constants
- Variables
- func HandleUserTcpConnection(pxy Proxy, userConn frpNet.Conn)
- func RunDashboardServer(addr string, port int) (err error)
- func StatsAddTrafficIn(name string, trafficIn int64)
- func StatsAddTrafficOut(name string, trafficOut int64)
- func StatsClearUselessInfo()
- func StatsCloseClient()
- func StatsCloseConnection(name string)
- func StatsCloseProxy(proxyName string, proxyType string)
- func StatsNewClient()
- func StatsNewProxy(name string, proxyType string)
- func StatsOpenConnection(name string)
- type BaseProxy
- type Control
- func (ctl *Control) CloseProxy(closeMsg *msg.CloseProxy) (err error)
- func (ctl *Control) GetWorkConn() (workConn net.Conn, err error)
- func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy) (remoteAddr string, err error)
- func (ctl *Control) RegisterWorkConn(conn net.Conn)
- func (ctl *Control) Replaced(newCtl *Control)
- func (ctl *Control) Start()
- type ControlManager
- type GeneralResponse
- type GetProxyInfoResp
- type GetProxyStatsResp
- type GetProxyTrafficResp
- type HttpProxy
- type HttpsProxy
- type NatHoleClientCfg
- type NatHoleController
- func (nc *NatHoleController) CloseClient(name string)
- func (nc *NatHoleController) GenNatHoleResponse(session *NatHoleSession, errInfo string) []byte
- func (nc *NatHoleController) GenSid() string
- func (nc *NatHoleController) HandleClient(m *msg.NatHoleClient, raddr *net.UDPAddr)
- func (nc *NatHoleController) HandleVisitor(m *msg.NatHoleVisitor, raddr *net.UDPAddr)
- func (nc *NatHoleController) ListenClient(name string, sk string) (sidCh chan string)
- func (nc *NatHoleController) Run()
- type NatHoleSession
- type PortCtx
- type PortManager
- type Proxy
- type ProxyManager
- type ProxyStatistics
- type ProxyStats
- type ProxyStatsInfo
- type ProxyTrafficInfo
- type ServerInfoResp
- type ServerStatistics
- type ServerStats
- type Service
- func (svr *Service) DelProxy(name string)
- func (svr *Service) HandleListener(l frpNet.Listener)
- func (svr *Service) RegisterControl(ctlConn frpNet.Conn, loginMsg *msg.Login) (err error)
- func (svr *Service) RegisterProxy(name string, pxy Proxy) error
- func (svr *Service) RegisterVisitorConn(visitorConn frpNet.Conn, newMsg *msg.NewVisitorConn) error
- func (svr *Service) RegisterWorkConn(workConn frpNet.Conn, newMsg *msg.NewWorkConn)
- func (svr *Service) Run()
- type StcpProxy
- type TcpProxy
- type UdpProxy
- type VisitorManager
- type XtcpProxy
Constants ¶
View Source
const ( MinPort = 1 MaxPort = 65535 MaxPortReservedDuration = time.Duration(24) * time.Hour CleanReservedPortsInterval = time.Hour )
View Source
const (
ReserveDays = 7
)
Variables ¶
View Source
var ( ErrPortAlreadyUsed = errors.New("port already used") ErrPortNotAllowed = errors.New("port not allowed") ErrPortUnAvailable = errors.New("port unavailable") ErrNoAvailablePort = errors.New("no available port") )
View Source
var NatHoleTimeout int64 = 10
Timeout seconds.
Functions ¶
func HandleUserTcpConnection ¶
HandleUserTcpConnection is used for incoming tcp user connections. It can be used for tcp, http, https type.
func RunDashboardServer ¶
func StatsAddTrafficIn ¶
func StatsAddTrafficOut ¶
func StatsClearUselessInfo ¶
func StatsClearUselessInfo()
func StatsCloseClient ¶
func StatsCloseClient()
func StatsCloseConnection ¶
func StatsCloseConnection(name string)
func StatsCloseProxy ¶
func StatsNewClient ¶
func StatsNewClient()
func StatsNewProxy ¶
func StatsOpenConnection ¶
func StatsOpenConnection(name string)
Types ¶
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
func (*Control) CloseProxy ¶
func (ctl *Control) CloseProxy(closeMsg *msg.CloseProxy) (err error)
func (*Control) GetWorkConn ¶
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 (*Control) RegisterWorkConn ¶
type ControlManager ¶
type ControlManager struct {
// contains filtered or unexported fields
}
func NewControlManager ¶
func NewControlManager() *ControlManager
type GeneralResponse ¶
type GetProxyInfoResp ¶
type GetProxyInfoResp struct { GeneralResponse Proxies []*ProxyStatsInfo `json:"proxies"` }
type GetProxyStatsResp ¶
type GetProxyStatsResp struct { GeneralResponse Name string `json:"name"` Conf config.ProxyConf `json:"conf"` TodayTrafficIn int64 `json:"today_traffic_in"` TodayTrafficOut int64 `json:"today_traffic_out"` CurConns int64 `json:"cur_conns"` LastStartTime string `json:"last_start_time"` LastCloseTime string `json:"last_close_time"` Status string `json:"status"` }
Get proxy info by name.
type GetProxyTrafficResp ¶
type GetProxyTrafficResp struct { GeneralResponse Name string `json:"name"` TrafficIn []int64 `json:"traffic_in"` TrafficOut []int64 `json:"traffic_out"` }
api/proxy/traffic/:name
type HttpProxy ¶
type HttpProxy struct { BaseProxy // contains filtered or unexported fields }
func (*HttpProxy) GetRealConn ¶
type HttpsProxy ¶
type HttpsProxy struct { BaseProxy // contains filtered or unexported fields }
func (*HttpsProxy) Close ¶
func (pxy *HttpsProxy) Close()
func (*HttpsProxy) GetConf ¶
func (pxy *HttpsProxy) GetConf() config.ProxyConf
func (*HttpsProxy) Run ¶
func (pxy *HttpsProxy) Run() (remoteAddr string, err error)
type NatHoleClientCfg ¶
type NatHoleController ¶
type NatHoleController struct {
// contains filtered or unexported fields
}
func NewNatHoleController ¶
func NewNatHoleController(udpBindAddr string) (nc *NatHoleController, err error)
func (*NatHoleController) CloseClient ¶
func (nc *NatHoleController) CloseClient(name string)
func (*NatHoleController) GenNatHoleResponse ¶
func (nc *NatHoleController) GenNatHoleResponse(session *NatHoleSession, errInfo string) []byte
func (*NatHoleController) GenSid ¶
func (nc *NatHoleController) GenSid() string
func (*NatHoleController) HandleClient ¶
func (nc *NatHoleController) HandleClient(m *msg.NatHoleClient, raddr *net.UDPAddr)
func (*NatHoleController) HandleVisitor ¶
func (nc *NatHoleController) HandleVisitor(m *msg.NatHoleVisitor, raddr *net.UDPAddr)
func (*NatHoleController) ListenClient ¶
func (nc *NatHoleController) ListenClient(name string, sk string) (sidCh chan string)
func (*NatHoleController) Run ¶
func (nc *NatHoleController) Run()
type NatHoleSession ¶
type PortManager ¶
type PortManager struct {
// contains filtered or unexported fields
}
func NewPortManager ¶
func NewPortManager(netType string, bindAddr string, allowPorts map[int]struct{}) *PortManager
func (*PortManager) Acquire ¶
func (pm *PortManager) Acquire(name string, port int) (realPort int, err error)
func (*PortManager) Release ¶
func (pm *PortManager) Release(port int)
type Proxy ¶
type ProxyManager ¶
type ProxyManager struct {
// contains filtered or unexported fields
}
func NewProxyManager ¶
func NewProxyManager() *ProxyManager
func (*ProxyManager) Del ¶
func (pm *ProxyManager) Del(name string)
type ProxyStatistics ¶
type ProxyStats ¶
type ProxyStats struct { Name string Type string TodayTrafficIn int64 TodayTrafficOut int64 LastStartTime string LastCloseTime string CurConns int64 }
func StatsGetProxiesByType ¶
func StatsGetProxiesByType(proxyType string) []*ProxyStats
func StatsGetProxiesByTypeAndName ¶
func StatsGetProxiesByTypeAndName(proxyType string, proxyName string) (res *ProxyStats)
type ProxyStatsInfo ¶
type ProxyStatsInfo struct { Name string `json:"name"` Conf config.ProxyConf `json:"conf"` TodayTrafficIn int64 `json:"today_traffic_in"` TodayTrafficOut int64 `json:"today_traffic_out"` CurConns int64 `json:"cur_conns"` LastStartTime string `json:"last_start_time"` LastCloseTime string `json:"last_close_time"` Status string `json:"status"` }
Get proxy info.
type ProxyTrafficInfo ¶
func StatsGetProxyTraffic ¶
func StatsGetProxyTraffic(name string) (res *ProxyTrafficInfo)
type ServerInfoResp ¶
type ServerInfoResp struct { GeneralResponse Version string `json:"version"` BindPort int `json:"bind_port"` BindUdpPort int `json:"bind_udp_port"` VhostHttpPort int `json:"vhost_http_port"` VhostHttpsPort int `json:"vhost_https_port"` KcpBindPort int `json:"kcp_bind_port"` AuthTimeout int64 `json:"auth_timeout"` SubdomainHost string `json:"subdomain_host"` MaxPoolCount int64 `json:"max_pool_count"` MaxPortsPerClient int64 `json:"max_ports_per_client"` HeartBeatTimeout int64 `json:"heart_beat_timeout"` TotalTrafficIn int64 `json:"total_traffic_in"` TotalTrafficOut int64 `json:"total_traffic_out"` CurConns int64 `json:"cur_conns"` ClientCounts int64 `json:"client_counts"` ProxyTypeCounts map[string]int64 `json:"proxy_type_count"` }
api/serverinfo
type ServerStatistics ¶
type ServerStatistics struct { TotalTrafficIn metric.DateCounter TotalTrafficOut metric.DateCounter CurConns metric.Counter // counter for clients ClientCounts metric.Counter // counter for proxy types ProxyTypeCounts map[string]metric.Counter // statistics for different proxies // key is proxy name ProxyStatistics map[string]*ProxyStatistics // contains filtered or unexported fields }
type ServerStats ¶
type ServerStats struct { TotalTrafficIn int64 TotalTrafficOut int64 CurConns int64 ClientCounts int64 ProxyTypeCounts map[string]int64 }
Functions for getting server stats.
func StatsGetServer ¶
func StatsGetServer() *ServerStats
type Service ¶
type Service struct { // For https proxies, route requests to different clients by hostname and other infomation. VhostHttpsMuxer *vhost.HttpsMuxer // contains filtered or unexported fields }
Server service.
var ServerService *Service
func NewService ¶
func (*Service) HandleListener ¶
func (*Service) RegisterControl ¶
func (*Service) RegisterVisitorConn ¶
func (*Service) RegisterWorkConn ¶
func (svr *Service) RegisterWorkConn(workConn frpNet.Conn, newMsg *msg.NewWorkConn)
RegisterWorkConn register a new work connection to control and proxies need it.
type VisitorManager ¶
type VisitorManager struct {
// contains filtered or unexported fields
}
Manager for visitor listeners.
func NewVisitorManager ¶
func NewVisitorManager() *VisitorManager
func (*VisitorManager) CloseListener ¶
func (vm *VisitorManager) CloseListener(name string)
func (*VisitorManager) Listen ¶
func (vm *VisitorManager) Listen(name string, sk string) (l *frpNet.CustomListener, err error)
Click to show internal directories.
Click to hide internal directories.