a43f9fbf0d
P0 — Broken functionality: - Fix 12+ endpoints with wrong manager method signatures (email/calendar/file/routing) - Fix email_manager.delete_email_user() missing domain arg - Fix cell-link DNS forwarding wiped on every peer change (generate_corefile now accepts cell_links param; add/remove_cell_dns_forward no longer clobber the file) - Fix Flask SECRET_KEY regenerating on every restart (persisted to DATA_DIR) - Fix _next_peer_ip exhaustion returning 500 instead of 409 - Fix ConfigManager Caddyfile path (/app/config-caddy/) - Fix UI double-add and wrong-key peer bugs in Peers.jsx / WireGuard.jsx - Remove hardcoded credentials from Dashboard.jsx P1 — Security: - CSRF token validation on all POST/PUT/DELETE/PATCH to /api/* (double-submit pattern) - enforce_auth: 503 only when users file readable but empty; never bypass on IOError - WireGuard add_cell_peer: validate pubkey, name, endpoint against strict regexes - DNS add_cell_dns_forward: validate IP and domain; reject injection chars - DNS zone write: realpath containment + record content validation - iptables comment /32 suffix prevents substring match deleting wrong peer rules - is_local_request() trusts only loopback + 172.16.0.0/12 (Docker bridge) - POST /api/containers: volume allow-list prevents arbitrary host mounts - file_manager: bcrypt ($2b→$2y) for WebDAV; realpath containment in delete_user - email/calendar: stop persisting plaintext passwords in user records - routing_manager: validate IPs, networks, and interface names - peer_registry: write peers.json at mode 0o600 - vault_manager: Fernet key file at mode 0o600 - CORS: lock down to explicit origin list - domain/cell_name validation: reject newline, brace, semicolon injection chars P2 — Architecture: - Peer add: rollback registry entry if firewall rules fail post-add - restart_service(): base class now calls _restart_container(); email and calendar managers call cell-mail / cell-radicale respectively - email/calendar managers sync user list (no passwords) to cell_config.json - Pending-restart flag cleared only after helper subprocess exits with code 0 - docker-compose.yml: add config-caddy volume to API container P3 — Tests (854 → 1020): - Fill test_email_endpoints.py, test_calendar_endpoints.py, test_network_endpoints.py, test_routing_endpoints.py - New: test_peer_management_update.py, test_peer_management_edge_cases.py, test_input_validation.py, test_enforce_auth_configured.py, test_cell_link_dns.py, test_logs_endpoints.py, test_cells_endpoints.py, test_is_local_request_per_endpoint.py, test_caddy_routing.py - E2E conftest: skip WireGuard suite when wg-quick absent - Update existing tests to match fixed signatures and comment formats Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
281 lines
6.8 KiB
YAML
281 lines
6.8 KiB
YAML
version: '3.3'
|
|
|
|
services:
|
|
# Reverse Proxy - Caddy for routing all .cell traffic
|
|
caddy:
|
|
image: caddy:2-alpine
|
|
container_name: cell-caddy
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./config/caddy/Caddyfile:/etc/caddy/Caddyfile
|
|
- ./data/caddy:/data
|
|
- ./config/caddy/certs:/config/caddy/certs
|
|
restart: unless-stopped
|
|
cap_add:
|
|
- NET_ADMIN
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${CADDY_IP:-172.20.0.2}
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# DNS Server - CoreDNS for .cell TLD resolution
|
|
dns:
|
|
image: coredns/coredns:latest
|
|
container_name: cell-dns
|
|
command: ["-conf", "/etc/coredns/Corefile"]
|
|
ports:
|
|
- "${DNS_PORT:-53}:53/udp"
|
|
- "${DNS_PORT:-53}:53/tcp"
|
|
volumes:
|
|
- ./config/dns/Corefile:/etc/coredns/Corefile
|
|
- ./data/dns:/data
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${DNS_IP:-172.20.0.3}
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# DHCP Server - dnsmasq for IP leasing
|
|
dhcp:
|
|
image: alpine:latest
|
|
container_name: cell-dhcp
|
|
ports:
|
|
- "${DHCP_PORT:-67}:67/udp"
|
|
volumes:
|
|
- ./config/dhcp/dnsmasq.conf:/etc/dnsmasq.conf
|
|
- ./data/dhcp:/var/lib/misc
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${DHCP_IP:-172.20.0.4}
|
|
command: ["/bin/sh", "-c", "apk add --no-cache dnsmasq && dnsmasq -d -C /etc/dnsmasq.conf"]
|
|
cap_add:
|
|
- NET_ADMIN
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# NTP Server - chrony for time synchronization
|
|
ntp:
|
|
image: alpine:latest
|
|
container_name: cell-ntp
|
|
ports:
|
|
- "${NTP_PORT:-123}:123/udp"
|
|
volumes:
|
|
- ./config/ntp/chrony.conf:/etc/chrony/chrony.conf
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${NTP_IP:-172.20.0.5}
|
|
cap_add:
|
|
- SYS_TIME
|
|
command: ["/bin/sh", "-c", "apk add --no-cache chrony && rm -f /var/run/chrony/chronyd.pid && exec chronyd -d -f /etc/chrony/chrony.conf -n"]
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# Email Server - Postfix + Dovecot
|
|
mail:
|
|
image: mailserver/docker-mailserver:latest
|
|
container_name: cell-mail
|
|
hostname: mail
|
|
domainname: cell.local
|
|
env_file: ./config/mail/mailserver.env
|
|
ports:
|
|
- "${MAIL_SMTP_PORT:-25}:25"
|
|
- "${MAIL_SUBMISSION_PORT:-587}:587"
|
|
- "${MAIL_IMAP_PORT:-993}:993"
|
|
volumes:
|
|
- ./data/maildata:/var/mail
|
|
- ./data/mailstate:/var/mail-state
|
|
- ./data/maillogs:/var/log/mail
|
|
- ./config/mail/config:/tmp/docker-mailserver/
|
|
- ./config/mail/ssl:/etc/letsencrypt
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${MAIL_IP:-172.20.0.6}
|
|
cap_add:
|
|
- NET_ADMIN
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# Calendar & Contacts - Radicale
|
|
radicale:
|
|
image: tomsquest/docker-radicale:latest
|
|
container_name: cell-radicale
|
|
ports:
|
|
- "127.0.0.1:${RADICALE_PORT:-5232}:5232"
|
|
volumes:
|
|
- ./config/radicale:/etc/radicale
|
|
- ./data/radicale:/data
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${RADICALE_IP:-172.20.0.7}
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# File Storage - WebDAV
|
|
webdav:
|
|
image: bytemark/webdav:latest
|
|
container_name: cell-webdav
|
|
ports:
|
|
- "127.0.0.1:${WEBDAV_PORT:-8080}:80"
|
|
environment:
|
|
- AUTH_TYPE=Basic
|
|
- USERNAME=${WEBDAV_USER:-admin}
|
|
- PASSWORD=${WEBDAV_PASS}
|
|
volumes:
|
|
- ./data/files:/var/lib/dav
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${WEBDAV_IP:-172.20.0.8}
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# WireGuard VPN
|
|
wireguard:
|
|
image: linuxserver/wireguard:latest
|
|
container_name: cell-wireguard
|
|
environment:
|
|
- SERVERMODE=true
|
|
- PUID=${PUID:-1000}
|
|
- PGID=${PGID:-1000}
|
|
ports:
|
|
- "${WG_PORT:-51820}:${WG_PORT:-51820}/udp"
|
|
volumes:
|
|
- ./config/wireguard:/config
|
|
- /lib/modules:/lib/modules
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${WG_IP:-172.20.0.9}
|
|
cap_add:
|
|
- NET_ADMIN
|
|
- SYS_MODULE
|
|
privileged: true
|
|
sysctls:
|
|
- net.ipv4.conf.all.src_valid_mark=1
|
|
- net.ipv4.ip_forward=1
|
|
- net.ipv4.conf.all.rp_filter=0
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# API Server
|
|
api:
|
|
build: ./api
|
|
container_name: cell-api
|
|
ports:
|
|
- "127.0.0.1:${API_PORT:-3000}:3000"
|
|
volumes:
|
|
- ./data/api:/app/data
|
|
- ./data/dns:/app/data/dns
|
|
- ./config/api:/app/config
|
|
- ./config/caddy:/app/config-caddy
|
|
- ./config/wireguard:/app/config/wireguard
|
|
- ./config/dns:/app/config/dns
|
|
- ./data/logs:/app/api/data/logs
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
- ./.env:/app/.env.compose
|
|
- ./docker-compose.yml:/app/docker-compose.yml:ro
|
|
pid: host
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${API_IP:-172.20.0.10}
|
|
depends_on:
|
|
- wireguard
|
|
- dns
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# Web UI - React + Vite
|
|
webui:
|
|
build: ./webui
|
|
container_name: cell-webui
|
|
ports:
|
|
- "${WEBUI_PORT:-8081}:80"
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${WEBUI_IP:-172.20.0.11}
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# Webmail - RainLoop
|
|
rainloop:
|
|
image: hardware/rainloop
|
|
container_name: cell-rainloop
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${RAINLOOP_IP:-172.20.0.12}
|
|
ports:
|
|
- "127.0.0.1:${RAINLOOP_PORT:-8888}:8888"
|
|
volumes:
|
|
- ./data/rainloop:/rainloop/data
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
# File Manager - FileGator
|
|
filegator:
|
|
image: filegator/filegator
|
|
container_name: cell-filegator
|
|
restart: unless-stopped
|
|
networks:
|
|
cell-network:
|
|
ipv4_address: ${FILEGATOR_IP:-172.20.0.13}
|
|
ports:
|
|
- "127.0.0.1:${FILEGATOR_PORT:-8082}:8080"
|
|
volumes:
|
|
- ./data/filegator:/var/www/filegator/private
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "5"
|
|
|
|
networks:
|
|
cell-network:
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: ${CELL_NETWORK:-172.20.0.0/16}
|