first commit

This commit is contained in:
Mathieu BOURBON
2026-04-18 16:24:44 +02:00
commit fbb6138c28
72 changed files with 3509 additions and 0 deletions

37
scripts/run-discovery.ts Normal file
View File

@@ -0,0 +1,37 @@
/**
* CLI pour lancer une découverte sans passer par l'UI.
* Utilisation : `pnpm discovery:run -- --cidr 192.168.1.0/24`
*/
import { discoveryService } from '../src/modules/discovery';
function arg(name: string, fallback?: string): string | undefined {
const idx = process.argv.indexOf(`--${name}`);
return idx > -1 ? process.argv[idx + 1] : fallback;
}
async function main() {
const kind = (arg('kind', 'full') as 'full' | 'ping' | 'port' | 'arp' | 'mdns');
const cidr = arg('cidr', '192.168.1.0/24');
const ip = arg('ip');
const portsRaw = arg('ports');
const ports = portsRaw ? portsRaw.split(',').map(Number) : undefined;
console.log(`▶ Discovery ${kind} sur ${cidr ?? ip}`);
const scan =
kind === 'full'
? await discoveryService.runFull(cidr!, ports)
: await discoveryService.runSingle(kind, { cidr, ip, ports });
console.log('✅ Scan terminé', {
id: scan.id,
status: scan.status,
hostsFound: scan.hostsFound,
portsFound: scan.portsFound,
});
}
main().catch((e) => {
console.error(e);
process.exit(1);
});