Documentation
¶
Index ¶
- Constants
- func NewControlHandler(server *Server, opts ControlHandlerOptions) http.Handler
- type AllowConfig
- type Client
- type ClientConfig
- type ClientSnapshot
- type ConfigCheckItem
- type ConfigCheckResult
- type ControlHandlerOptions
- type Message
- type ReloadResult
- type Server
- func (server *Server) Clients() []ClientSnapshot
- func (server *Server) Collector() *engine.Collector
- func (server *Server) Config() ServerConfig
- func (server *Server) PrecheckConfig(next ServerConfig) ConfigCheckResult
- func (server *Server) ReloadConfig(next ServerConfig) (ReloadResult, error)
- func (server *Server) Run(ctx context.Context) error
- func (server *Server) RunningClients() int
- func (server *Server) RunningTunnels() int
- func (server *Server) Stats() []engine.TrafficSnapshot
- func (server *Server) Tunnels() []TunnelSnapshot
- type ServerClientACL
- type ServerConfig
- type TLSConfig
- type TunnelClientConfig
- type TunnelServerConfig
- type TunnelSnapshot
- type TunnelSpec
Constants ¶
View Source
const ( DefaultServerListenAddr = "0.0.0.0:18080" DefaultTunnelControlListenAddr = "127.0.0.1:19091" DefaultDialTimeout = "10s" DefaultOpenTimeout = "10s" DefaultReconnectMin = "1s" DefaultReconnectMax = "30s" )
View Source
const ( MessageHello = "hello" MessageAccept = "accept" MessageOpen = "open" MessageData = "data" MessageUDP = "udp" MessageClose = "close" MessagePing = "ping" MessagePong = "pong" MessageError = "error" )
View Source
const ProtocolVersion = 1
Variables ¶
This section is empty.
Functions ¶
func NewControlHandler ¶ added in v0.3.0
func NewControlHandler(server *Server, opts ControlHandlerOptions) http.Handler
Types ¶
type AllowConfig ¶
type ClientConfig ¶
type ClientConfig struct {
Version int `json:"version" yaml:"version"`
Log config.LogConfig `json:"log,omitempty" yaml:"log,omitempty"`
TunnelClient TunnelClientConfig `json:"tunnel_client" yaml:"tunnel_client"`
}
func LoadClientConfig ¶
func LoadClientConfig(path string) (ClientConfig, error)
type ClientSnapshot ¶
type ConfigCheckItem ¶
type ConfigCheckResult ¶
type ConfigCheckResult struct {
OK bool `json:"ok"`
ErrorCount int `json:"error_count"`
WarningCount int `json:"warning_count"`
Items []ConfigCheckItem `json:"items"`
}
type ControlHandlerOptions ¶ added in v0.3.0
type ControlHandlerOptions struct {
ConfigPath string
Auth *controlapi.Authenticator
Logger *slog.Logger
}
type Message ¶
type Message struct {
Type string `json:"type"`
Version int `json:"version,omitempty"`
ClientID string `json:"client_id,omitempty"`
Token string `json:"token,omitempty"`
SessionID string `json:"session_id,omitempty"`
TunnelID string `json:"tunnel_id,omitempty"`
ConnID string `json:"conn_id,omitempty"`
Tunnels []TunnelSpec `json:"tunnels,omitempty"`
OK bool `json:"ok,omitempty"`
Error string `json:"error,omitempty"`
Time int64 `json:"time,omitempty"`
}
type ReloadResult ¶
type ReloadResult struct {
OK bool `json:"ok"`
ClientCount int `json:"client_count"`
DisconnectedClients []string `json:"disconnected_clients,omitempty"`
Check ConfigCheckResult `json:"check"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Clients ¶
func (server *Server) Clients() []ClientSnapshot
func (*Server) Config ¶
func (server *Server) Config() ServerConfig
func (*Server) PrecheckConfig ¶
func (server *Server) PrecheckConfig(next ServerConfig) ConfigCheckResult
func (*Server) ReloadConfig ¶
func (server *Server) ReloadConfig(next ServerConfig) (ReloadResult, error)
func (*Server) RunningClients ¶
func (*Server) RunningTunnels ¶
func (*Server) Stats ¶
func (server *Server) Stats() []engine.TrafficSnapshot
func (*Server) Tunnels ¶
func (server *Server) Tunnels() []TunnelSnapshot
type ServerClientACL ¶
type ServerClientACL struct {
ClientID string `json:"client_id" yaml:"client_id"`
Token string `json:"token" yaml:"token"`
Allow AllowConfig `json:"allow,omitempty" yaml:"allow,omitempty"`
}
type ServerConfig ¶
type ServerConfig struct {
Version int `json:"version" yaml:"version"`
ControlListenAddr string `json:"control_listen_addr,omitempty" yaml:"control_listen_addr,omitempty"`
Log config.LogConfig `json:"log,omitempty" yaml:"log,omitempty"`
Auth config.AuthConfig `json:"auth,omitempty" yaml:"auth,omitempty"`
TunnelServer TunnelServerConfig `json:"tunnel_server" yaml:"tunnel_server"`
}
func LoadServerConfig ¶
func LoadServerConfig(path string) (ServerConfig, error)
type TLSConfig ¶
type TLSConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
CertFile string `json:"cert_file,omitempty" yaml:"cert_file,omitempty"`
KeyFile string `json:"key_file,omitempty" yaml:"key_file,omitempty"`
ServerName string `json:"server_name,omitempty" yaml:"server_name,omitempty"`
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty" yaml:"insecure_skip_verify,omitempty"`
}
type TunnelClientConfig ¶
type TunnelClientConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
ServerAddr string `json:"server_addr" yaml:"server_addr"`
TLS TLSConfig `json:"tls,omitempty" yaml:"tls,omitempty"`
ClientID string `json:"client_id" yaml:"client_id"`
Token string `json:"token" yaml:"token"`
DialTimeout string `json:"dial_timeout,omitempty" yaml:"dial_timeout,omitempty"`
ReconnectMin string `json:"reconnect_min,omitempty" yaml:"reconnect_min,omitempty"`
ReconnectMax string `json:"reconnect_max,omitempty" yaml:"reconnect_max,omitempty"`
Tunnels []TunnelSpec `json:"tunnels" yaml:"tunnels"`
}
type TunnelServerConfig ¶
type TunnelServerConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
ListenAddr string `json:"listen_addr" yaml:"listen_addr"`
TLS TLSConfig `json:"tls,omitempty" yaml:"tls,omitempty"`
OpenTimeout string `json:"open_timeout,omitempty" yaml:"open_timeout,omitempty"`
Clients []ServerClientACL `json:"clients" yaml:"clients"`
}
type TunnelSnapshot ¶
type TunnelSnapshot struct {
ClientID string `json:"client_id"`
TunnelID string `json:"tunnel_id"`
Protocol string `json:"protocol"`
RemoteListenAddr string `json:"remote_listen_addr"`
RemoteListenPort int `json:"remote_listen_port"`
LocalAddr string `json:"local_addr"`
LocalPort int `json:"local_port"`
ActiveConns int64 `json:"active_conns"`
MaxConn int `json:"max_conn,omitempty"`
Remark string `json:"remark,omitempty"`
}
type TunnelSpec ¶
type TunnelSpec struct {
TunnelID string `json:"tunnel_id" yaml:"tunnel_id"`
Protocol string `json:"protocol" yaml:"protocol"`
RemoteListenAddr string `json:"remote_listen_addr" yaml:"remote_listen_addr"`
RemoteListenPort int `json:"remote_listen_port" yaml:"remote_listen_port"`
LocalAddr string `json:"local_addr" yaml:"local_addr"`
LocalPort int `json:"local_port" yaml:"local_port"`
MaxConn int `json:"max_conn,omitempty" yaml:"max_conn,omitempty"`
SpeedLimit int64 `json:"speed_limit,omitempty" yaml:"speed_limit,omitempty"`
Remark string `json:"remark,omitempty" yaml:"remark,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.