Pseudo Commandes
Vue d'ensemble
Une pseudo-commande est un mot-clé intégré reconnu par la fonctionnalité Actions en Lots. Contrairement aux exécutables shell (par ex. ping ou dig qui invoquent des binaires systÚme via Runtime.exec), les pseudo-commandes déclenchent du code Kotlin personnalisé directement dans BulkActionsRepository. Il existe 9 pseudo-commandes :
| Mot-clé | Objectif |
|---|---|
ping | Ping ICMP |
dig | Résolution DNS (via dnsjava) |
ntp | RequĂȘte de temps NTP |
port-scan | Scan de ports TCP |
checkcert | Inspection de certificats HTTPS |
device-info | Infos d'identité de l'appareil |
tracert | Traceroute (sondage TTL) |
google-timesync | Google Time Sync |
lan-scan | Balayage de sous-réseau LAN |
Les mots-clés non reconnus passent par un fallback Runtime.exec() brut.
Comment ça fonctionne
Fichier de config JSON
"commands": {
"ping_google": "ping -c 5 google.com",
"dig_example": "dig example.com",
"checkcert_google": "checkcert https://google.com"
}
â
âŒ
BulkConfigParser.parse(json) â analyse JSON en BulkConfig(commands=Map<String, String>)
â
âŒ
BulkActionsViewModel.onLoadAndRun() â lit la config, stocke dans l'Ă©tat UI
â
âŒ
BulkActionsRepository.executeAllCommands(commands)
â
âââ Pour chaque paire (nom, cmd) :
â executeSingleCommand(nom, cmd, timeoutMs)
â â
â âââ Analyse du premier mot â dispatch via `when` :
â "ping" â executePing() â Runtime.exec("ping -c 5 google.com")
â "dig" â executeDig() â DigRepository.resolve()
â "ntp" â executeNtp() â NtpRepository.query()
â "port-scan" â executePortScan() â Socket.connect(port, timeout) Ă N
â "checkcert" â executeCheckcert() â HttpsCertRepository.fetchCertificate()
â "device-info" â executeDeviceInfo() â SystemInfoRepository.getDeviceInfo()
â "tracert" â executeTracert() â Runtime.exec("ping -c 1 -t TTL host")
â "google-timesync" â executeGoogleTimeSync() â GoogleTimeSyncRepository.fetchGoogleTime()
â "lan-scan" â executeLanScan() â LanScannerRepository.pingSweep()
â else â executeRaw() â Runtime.exec(full string)
â
âŒ
BulkCommandResult (hiérarchie scellée)
âââ BulkCommandSuccess â rĂ©ussi avec lignes de sortie
âââ BulkCommandError â Ă©chouĂ© avec message d'erreur
âââ BulkCommandTimeout â dĂ©lai d'attente dĂ©passĂ©
âââ BulkCommandClosed â arrĂȘtĂ© manuellement
âââ BulkCommandWarning â rĂ©ussi mais avec un avertissement (ex: cert expirĂ©)
â
ââââ BulkActionsViewModel.generateOutputContent() â rapport texte avec tableau rĂ©capitulatif
ââââ BulkActionsViewModel.generateCsvContent() â export CSV
ââââ BulkActionsScreen.ResultItem() â affichage UI Compose (icĂŽne + lignes)Classes ClĂ©s
| Classe | RĂŽle |
|---|---|
BulkConfigParser | Analyse JSON en BulkConfig data class |
BulkActionsRepository.executeSingleCommand() | Dispatche chaque mot-clé de commande vers l'exécuteur correct |
executePing() ⊠executeLanScan() | 9 exĂ©cuteurs privĂ©s â invoquent les dĂ©pĂŽts ou binaires systĂšme |
BulkCommandResult (+ sous-classes) | Hiérarchie scellée représentant les résultats d'exécution |
BulkActionsViewModel.generateOutputContent() | Formate les résultats en rapport texte avec tableau récapitulatif |
BulkActionsViewModel.generateCsvContent() | Formate les résultats en CSV |
BulkActionsScreen.ResultItem() | Affiche chaque résultat dans l'UI Compose (icÎne + statut + lignes de sortie) |