38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
/**
|
|
* 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);
|
|
});
|