92 lines
2.5 KiB
Markdown
92 lines
2.5 KiB
Markdown
# IPAM Homelab
|
|
|
|
Application web **TypeScript / Next.js 15** pour gérer l'inventaire IP d'un homelab : hôtes, ports, applications, avec **découverte réseau automatique** (ping sweep, scan de ports, ARP, mDNS).
|
|
|
|
## Stack
|
|
|
|
- **Next.js 15** (App Router) + **React 18** + **TypeScript**
|
|
- **Prisma** ORM avec support **SQLite _ou_ PostgreSQL** (via variable d'env)
|
|
- **TailwindCSS** + design system inspiré shadcn/ui
|
|
- **Zod** pour la validation
|
|
- **Pino** pour les logs
|
|
- **Docker / Docker Compose** pour le déploiement
|
|
|
|
## Démarrage rapide
|
|
|
|
```bash
|
|
# 1. Installer les dépendances
|
|
npm install
|
|
|
|
# 2. Copier la configuration d'exemple
|
|
cp .env.example .env
|
|
|
|
# 3. Générer le client Prisma et créer la DB
|
|
npm run db:generate
|
|
npm run db:migrate
|
|
|
|
# 4. (Optionnel) Charger des données d'exemple
|
|
npm run db:seed
|
|
|
|
# 5. Lancer en développement
|
|
npm run dev
|
|
```
|
|
|
|
Accès : http://localhost:3000
|
|
|
|
## Passer de SQLite à PostgreSQL
|
|
|
|
Dans `.env` :
|
|
|
|
```env
|
|
DATABASE_PROVIDER=postgresql
|
|
DATABASE_URL="postgresql://ipam:ipam@localhost:5432/ipam?schema=public"
|
|
```
|
|
|
|
Puis :
|
|
|
|
```bash
|
|
npm run db:generate
|
|
npm run db:migrate
|
|
```
|
|
|
|
## Déploiement Docker
|
|
|
|
```bash
|
|
# Avec SQLite (simple, fichier local persisté dans un volume)
|
|
docker compose --profile sqlite -f docker/docker-compose.yml up -d
|
|
|
|
# Avec PostgreSQL
|
|
docker compose --profile postgres -f docker/docker-compose.yml up -d
|
|
```
|
|
|
|
> Le conteneur utilise `network_mode: host` pour permettre les scans ARP / mDNS /
|
|
> ping sur le LAN. À désactiver si non nécessaire.
|
|
|
|
## Découverte réseau
|
|
|
|
| Scanner | Description | Requiert |
|
|
| ------- | ---------------------------------------------------- | ---------------------------------- |
|
|
| `ping` | Ping sweep ICMP sur un CIDR | `cap_net_raw` ou bin `ping` |
|
|
| `port` | Scan TCP connect sur une IP | — |
|
|
| `arp` | Lit la table ARP locale (`ip neigh` / `arp -a`) | Accès au LAN (host network) |
|
|
| `mdns` | Écoute Bonjour / DNS-SD | Multicast sur le LAN |
|
|
|
|
Lancer un scan complet via CLI :
|
|
|
|
```bash
|
|
npm run discovery:run -- --kind full --cidr 192.168.1.0/24
|
|
```
|
|
|
|
Via l'API :
|
|
|
|
```bash
|
|
curl -X POST http://localhost:3000/api/discovery \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"kind":"full","cidr":"192.168.1.0/24"}'
|
|
```
|
|
|
|
## Architecture
|
|
|
|
Voir [`ARCHITECTURE.md`](./ARCHITECTURE.md) pour le détail des couches et la
|
|
procédure d'ajout d'un nouveau module métier ou d'un nouveau scanner.
|