Documentation
¶
Index ¶
- Constants
- func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
- func NewTLSConfig(certFile, keyFile, caFile string) (*tls.Config, error)
- func RecordConnection(duration float64)
- func RecordError(code string)
- func RecordHeartbeat(latency float64)
- func RecordMissedHeartbeat()
- func SetActiveTunnels(count int)
- func UpdateHealthStatus(status string)
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(host string, port int) error
- func (c *Client) CreateTunnel(localPort int, remoteHost string, remotePort int) (string, error)
- func (c *Client) GetFeatures() []string
- func (c *Client) GetTenantID() string
- func (c *Client) GetVersion() string
- func (c *Client) Handshake(token string) error
- func (c *Client) IsConnected() bool
- func (c *Client) ReadMessage() (map[string]interface{}, error)
- func (c *Client) SendMessage(msg interface{}) error
- func (c *Client) SetTenantID(tenantID string)
- type Config
- type HealthStatus
- type Tunnel
Constants ¶
const ( MessageTypeHello = "hello" MessageTypeAuth = "auth" MessageTypeAuthResponse = "auth_response" MessageTypeTunnelInfo = "tunnel_info" MessageTypeTunnelResponse = "tunnel_response" MessageTypeHeartbeat = "heartbeat" MessageTypeHeartbeatResponse = "heartbeat_response" MessageTypeError = "error" MaxMessageSize = 1024 * 1024 // 1MB ConnectTimeout = 10 * time.Second ReadWriteTimeout = 30 * time.Second HeartbeatInterval = 30 * time.Second HeartbeatTimeout = 5 * time.Second MaxMissedHeartbeats = 3 )
Message types
Variables ¶
This section is empty.
Functions ¶
func HealthCheckHandler ¶
func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
HealthCheckHandler обрабатывает запросы к /health
func NewTLSConfig ¶
NewTLSConfig creates a new TLS configuration
func RecordConnection ¶
func RecordConnection(duration float64)
RecordConnection records a new connection
func RecordMissedHeartbeat ¶
func RecordMissedHeartbeat()
RecordMissedHeartbeat records a missed heartbeat
func SetActiveTunnels ¶
func SetActiveTunnels(count int)
SetActiveTunnels sets the number of active tunnels
func UpdateHealthStatus ¶
func UpdateHealthStatus(status string)
UpdateHealthStatus обновляет статус здоровья
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a CloudBridge Relay client
func NewClientFromConfig ¶
NewClientFromConfig creates a new client from config
func NewClientV1 ¶
NewClientV1 creates a new CloudBridge Relay client for v1.0.0 (backward compatibility)
func (*Client) CreateTunnel ¶
CreateTunnel creates a new tunnel
func (*Client) GetFeatures ¶
GetFeatures returns the supported features
func (*Client) GetTenantID ¶
GetTenantID returns the current tenant ID
func (*Client) GetVersion ¶
GetVersion returns the protocol version
func (*Client) IsConnected ¶
IsConnected returns true if the client is connected
func (*Client) ReadMessage ¶
ReadMessage читает строку, парсит JSON, ограничивает размер
func (*Client) SendMessage ¶
SendMessage отправляет JSON-сообщение с \n
func (*Client) SetTenantID ¶
SetTenantID sets the tenant ID for multi-tenancy support
type Config ¶
type Config struct {
UseTLS bool
TLSCertFile string
TLSKeyFile string
TLSCAFile string
ServerHost string
ServerPort int
JWTToken string
LocalPort int
ReconnectDelay int
MaxRetries int
}
Config represents the client configuration
type HealthStatus ¶
type HealthStatus struct {
Status string `json:"status"`
Version string `json:"version"`
Uptime string `json:"uptime"`
ConnectionsTotal float64 `json:"connections_total"`
ActiveTunnels float64 `json:"active_tunnels"`
ErrorsTotal float64 `json:"errors_total"`
MissedHeartbeats float64 `json:"missed_heartbeats"`
LastUpdate time.Time `json:"last_update"`
}
HealthStatus представляет текущее состояние сервера
func GetHealthStatus ¶
func GetHealthStatus() HealthStatus
GetHealthStatus возвращает текущий статус здоровья