// Package modules définit le contrat d'interface pour les modules ProxmoxPanel. package modules import ( "database/sql" "net/http" ) // Module est l'interface que chaque module doit implémenter. type Module interface { ID() string Register(registry Registry) error } // NavItemDef décrit l'entrée de navigation d'un module dans la sidebar. type NavItemDef struct { ID string `json:"id"` Href string `json:"href"` Icon string `json:"icon"` Color string `json:"color"` LabelKey string `json:"label_key"` } // Registry est l'interface exposée aux modules pour s'enregistrer dans le CORE. // Seuls des types de la bibliothèque standard sont exposés — aucun type internal. type Registry interface { // Enregistrement de routes HTTP (avec authentification) RegisterRoute(method, path string, handler http.HandlerFunc, requireAdmin bool) // Enregistrement d'une route publique (sans auth — pour les pages HTML) RegisterPublicRoute(method, path string, handler http.HandlerFunc) // Enregistrement du canal WebSocket RegisterWSChannel(channel string, handler WSHandler) // Widgets et onglets RegisterWidget(widget WidgetDef) RegisterSettingsTab(tab SettingsTabDef) // Traductions et migrations RegisterTranslations(lang string, keys map[string]string) RegisterMigration(version int, sql string, fn MigrationFn) // Entrée de navigation dans la sidebar RegisterNavItem(item NavItemDef) // Accès à la base SQLite (isolation par module possible via préfixe) DB() *sql.DB // Service SSH — exécute une commande sur la cible (host ou lxc:VMID) // La cible "host" exécute directement, "lxc:101" wrappe via pct exec RunOnTarget(target, command string) (string, error) // Service SSH — streaming de la sortie ligne par ligne // Le channel est fermé à la fin de la commande StreamOnTarget(target, command string, output chan<- string) error } // WSHandler est un handler WebSocket pour un channel nommé. type WSHandler func(userID int64, send chan<- []byte, recv <-chan []byte) // WidgetDef décrit un type de widget disponible pour le dashboard. type WidgetDef struct { Type string `json:"type"` Name string `json:"name"` Description string `json:"description"` DefaultW int `json:"default_width"` DefaultH int `json:"default_height"` } // SettingsTabDef décrit un onglet de paramètres fourni par un module. type SettingsTabDef struct { ID string `json:"id"` Label string `json:"label"` Icon string `json:"icon"` ComponentPath string `json:"component_path"` } // MigrationFn est une fonction de migration optionnelle. type MigrationFn func(db *sql.DB) error