Documentation
¶
Index ¶
- Variables
- func BackupDatabase(dbPath string) (string, error)
- func ClearMessages(db *sql.DB) error
- func ConvertPluginMessage(pluginMsg sdk.Message) shared.Message
- func CreateSchema(db *sql.DB)
- func GetDatabaseStats(db *sql.DB) (string, error)
- func GetMessagesAfter(db *sql.DB, lastMessageID int64, limit int) []shared.Message
- func GetRecentMessages(db *sql.DB) []shared.Message
- func GetRecentMessagesForUser(db *sql.DB, username string, defaultLimit int, banGapsHistory bool) ([]shared.Message, int64)
- func InitDB(filepath string) *sql.DB
- func InsertEncryptedMessage(db *sql.DB, encryptedMsg *shared.EncryptedMessage)
- func InsertMessage(db *sql.DB, msg shared.Message)
- func LogToFile(filename string) error
- func RunAdminPanel(hub *Hub, db *sql.DB, pluginManager *manager.PluginManager, ...) error
- func ServeWs(hub *Hub, db *sql.DB, adminList []string, adminKey string, banGapsHistory bool, ...) http.HandlerFunc
- func SetLogLevel(level LogLevel)
- type AdminPanel
- type Client
- type ComponentHealth
- type Config
- type HealthCheck
- type HealthChecker
- type HealthStatus
- type Hub
- func (h *Hub) AllowUser(username string, adminUsername string) bool
- func (h *Hub) BanUser(username string, adminUsername string)
- func (h *Hub) CleanupExpiredBans()
- func (h *Hub) CleanupStaleConnections()
- func (h *Hub) ForceDisconnectUser(username string, adminUsername string) bool
- func (h *Hub) GetPluginManager() *manager.PluginManager
- func (h *Hub) IsUserBanned(username string) bool
- func (h *Hub) KickUser(username string, adminUsername string)
- func (h *Hub) Run()
- func (h *Hub) UnbanUser(username string, adminUsername string) bool
- type LogEntry
- type LogLevel
- type Logger
- func (l *Logger) Debug(message string, data ...map[string]interface{})
- func (l *Logger) Error(message string, err error, data ...map[string]interface{})
- func (l *Logger) Info(message string, data ...map[string]interface{})
- func (l *Logger) Warn(message string, data ...map[string]interface{})
- func (l *Logger) WithUser(userID string) *Logger
- type PluginCommandHandler
- func (h *PluginCommandHandler) GetPluginMessageChannel() <-chan sdk.Message
- func (h *PluginCommandHandler) HandlePluginCommand(cmd string, args []string, isAdmin bool) (string, error)
- func (h *PluginCommandHandler) SendMessageToPlugins(msg shared.Message)
- func (h *PluginCommandHandler) UpdateUserListForPlugins(users []string)
- type ServerConfig
- type ServerConfigModel
- type SystemMetrics
- type UserList
- type WSMessage
- type WebAdminServer
Constants ¶
This section is empty.
Variables ¶
var ( ServerLogger = NewLogger("Server") ClientLogger = NewLogger("Client") HubLogger = NewLogger("Hub") AdminLogger = NewLogger("Admin") PluginLogger = NewLogger("Plugin") DatabaseLogger = NewLogger("Database") SecurityLogger = NewLogger("Security") FilterLogger = NewLogger("Filter") )
Global logger instances for different components
Functions ¶
func BackupDatabase ¶
BackupDatabase creates a backup of the current database
func ClearMessages ¶
func ConvertPluginMessage ¶
ConvertPluginMessage converts a plugin message to a shared message
func CreateSchema ¶
func GetDatabaseStats ¶
GetDatabaseStats returns statistics about the database
func GetMessagesAfter ¶
GetMessagesAfter retrieves messages with ID > lastMessageID
func GetRecentMessagesForUser ¶
func GetRecentMessagesForUser(db *sql.DB, username string, defaultLimit int, banGapsHistory bool) ([]shared.Message, int64)
GetRecentMessagesForUser returns personalized message history for a specific user
func InsertEncryptedMessage ¶
func InsertEncryptedMessage(db *sql.DB, encryptedMsg *shared.EncryptedMessage)
InsertEncryptedMessage stores an encrypted message in the database
func RunAdminPanel ¶
func RunAdminPanel(hub *Hub, db *sql.DB, pluginManager *manager.PluginManager, liveConfig *config.Config) error
RunAdminPanel starts the admin panel TUI
func SetLogLevel ¶
func SetLogLevel(level LogLevel)
SetLogLevel sets the minimum log level (currently not implemented but ready for future use)
Types ¶
type AdminPanel ¶
type AdminPanel struct {
// contains filtered or unexported fields
}
AdminPanel represents the main admin panel state
func NewAdminPanel ¶
func NewAdminPanel(hub *Hub, db *sql.DB, pluginManager *manager.PluginManager, liveConfig *config.Config) *AdminPanel
NewAdminPanel creates a new admin panel instance
func (*AdminPanel) View ¶
func (ap *AdminPanel) View() string
type ComponentHealth ¶
type ComponentHealth struct {
Status HealthStatus `json:"status"`
Message string `json:"message,omitempty"`
LastCheck time.Time `json:"last_check"`
}
ComponentHealth represents the health of a specific component
type Config ¶
type Config struct {
Port int `json:"port"`
Admins []string `json:"admins"`
AdminKey string `json:"admin_key"`
}
func LoadConfig ¶
LoadConfig loads configuration from a JSON file (for backward compatibility)
func LoadConfigFromDir ¶
LoadConfigFromDir loads configuration from a directory, checking for JSON config files
type HealthCheck ¶
type HealthCheck struct {
Status HealthStatus `json:"status"`
Timestamp time.Time `json:"timestamp"`
Version string `json:"version"`
Uptime string `json:"uptime"`
Components map[string]ComponentHealth `json:"components"`
Metrics SystemMetrics `json:"metrics"`
}
HealthCheck represents a health check response
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker manages health check functionality
func NewHealthChecker ¶
func NewHealthChecker(hub *Hub, db *sql.DB, version string) *HealthChecker
NewHealthChecker creates a new health checker
func (*HealthChecker) CheckHealth ¶
func (hc *HealthChecker) CheckHealth() *HealthCheck
CheckHealth performs a comprehensive health check
func (*HealthChecker) HealthCheckHandler ¶
func (hc *HealthChecker) HealthCheckHandler(w http.ResponseWriter, r *http.Request)
HealthCheckHandler handles HTTP health check requests
func (*HealthChecker) SimpleHealthHandler ¶
func (hc *HealthChecker) SimpleHealthHandler(w http.ResponseWriter, r *http.Request)
SimpleHealthHandler provides a simple health check endpoint
type HealthStatus ¶
type HealthStatus string
HealthStatus represents the overall health status
const ( HealthStatusHealthy HealthStatus = "healthy" HealthStatusDegraded HealthStatus = "degraded" HealthStatusUnhealthy HealthStatus = "unhealthy" )
func (HealthStatus) String ¶
func (hs HealthStatus) String() string
String returns the string representation of HealthStatus
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func (*Hub) CleanupExpiredBans ¶
func (h *Hub) CleanupExpiredBans()
CleanupExpiredBans removes expired bans and kicks from the lists
func (*Hub) CleanupStaleConnections ¶
func (h *Hub) CleanupStaleConnections()
CleanupStaleConnections removes clients with broken connections
func (*Hub) ForceDisconnectUser ¶
ForceDisconnectUser forcibly removes a user from the clients map (admin command for stale connections)
func (*Hub) GetPluginManager ¶
func (h *Hub) GetPluginManager() *manager.PluginManager
GetPluginManager returns the plugin manager reference
func (*Hub) IsUserBanned ¶
IsUserBanned checks if a user is currently banned or kicked
type LogEntry ¶
type LogEntry struct {
Level LogLevel `json:"level"`
Timestamp time.Time `json:"timestamp"`
Component string `json:"component"`
UserID string `json:"user_id,omitempty"`
Message string `json:"message"`
Error string `json:"error,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}
LogEntry represents a structured log entry
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides structured logging functionality
type PluginCommandHandler ¶
type PluginCommandHandler struct {
// contains filtered or unexported fields
}
PluginCommandHandler handles plugin-related commands
func NewPluginCommandHandler ¶
func NewPluginCommandHandler(pluginManager *manager.PluginManager) *PluginCommandHandler
NewPluginCommandHandler creates a new plugin command handler
func (*PluginCommandHandler) GetPluginMessageChannel ¶
func (h *PluginCommandHandler) GetPluginMessageChannel() <-chan sdk.Message
GetPluginMessageChannel returns the channel for receiving messages from plugins
func (*PluginCommandHandler) HandlePluginCommand ¶
func (h *PluginCommandHandler) HandlePluginCommand(cmd string, args []string, isAdmin bool) (string, error)
HandlePluginCommand handles plugin-related commands
func (*PluginCommandHandler) SendMessageToPlugins ¶
func (h *PluginCommandHandler) SendMessageToPlugins(msg shared.Message)
SendMessageToPlugins sends a message to all enabled plugins
func (*PluginCommandHandler) UpdateUserListForPlugins ¶
func (h *PluginCommandHandler) UpdateUserListForPlugins(users []string)
UpdateUserListForPlugins updates the user list for plugins
type ServerConfig ¶
func RunServerConfig ¶
func RunServerConfig() (*ServerConfig, error)
RunServerConfig runs the interactive server configuration UI
type ServerConfigModel ¶
type ServerConfigModel struct {
// contains filtered or unexported fields
}
func NewServerConfigUI ¶
func NewServerConfigUI() ServerConfigModel
func (ServerConfigModel) GetConfig ¶
func (m ServerConfigModel) GetConfig() *ServerConfig
GetConfig returns the built configuration
func (ServerConfigModel) Init ¶
func (m ServerConfigModel) Init() tea.Cmd
func (ServerConfigModel) IsCancelled ¶
func (m ServerConfigModel) IsCancelled() bool
IsCancelled returns true if the user cancelled the configuration
func (ServerConfigModel) IsFinished ¶
func (m ServerConfigModel) IsFinished() bool
IsFinished returns true if the user completed the configuration
func (ServerConfigModel) View ¶
func (m ServerConfigModel) View() string
type SystemMetrics ¶
type SystemMetrics struct {
MemoryUsage float64 `json:"memory_usage_mb"`
Goroutines int `json:"goroutines"`
ActiveUsers int `json:"active_users"`
TotalMessages int `json:"total_messages"`
DatabaseStatus string `json:"database_status"`
}
SystemMetrics represents system performance metrics
type WSMessage ¶
type WSMessage struct {
Type string `json:"type"`
Data json.RawMessage `json:"data"`
}
type WebAdminServer ¶
type WebAdminServer struct {
// contains filtered or unexported fields
}
func NewWebAdminServer ¶
NewWebAdminServer creates a new web admin server with full functionality
func (*WebAdminServer) RegisterRoutes ¶
func (w *WebAdminServer) RegisterRoutes(mux *http.ServeMux)
RegisterRoutes attaches all web admin routes to mux