Replace per-decky sniffer containers with a single host-side sniffer that monitors all traffic on the MACVLAN interface. Runs as a background task in the FastAPI lifespan alongside the collector, fully fault-isolated so failures never crash the API. - Add fleet_singleton flag to BaseService; sniffer marked as singleton - Composer skips fleet_singleton services in compose generation - Fleet builder excludes singletons from random service assignment - Extract TLS fingerprinting engine from templates/sniffer/server.py into decnet/sniffer/ package (parameterized for fleet-wide use) - Sniffer worker maps packets to deckies via IP→name state mapping - Original templates/sniffer/server.py preserved for future use
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
from abc import ABC, abstractmethod
|
|
from pathlib import Path
|
|
|
|
|
|
class BaseService(ABC):
|
|
"""
|
|
Contract every honeypot service plugin must implement.
|
|
|
|
To add a new service: subclass BaseService in a new file under decnet/services/.
|
|
The registry auto-discovers all subclasses at import time.
|
|
"""
|
|
|
|
name: str # unique slug, e.g. "ssh", "smb"
|
|
ports: list[int] # ports this service listens on inside the container
|
|
default_image: str # Docker image tag, or "build" if a Dockerfile is needed
|
|
fleet_singleton: bool = False # True = runs once fleet-wide, not per-decky
|
|
|
|
@abstractmethod
|
|
def compose_fragment(
|
|
self,
|
|
decky_name: str,
|
|
log_target: str | None = None,
|
|
service_cfg: dict | None = None,
|
|
) -> dict:
|
|
"""
|
|
Return the docker-compose service dict for this service on a given decky.
|
|
|
|
Networking keys (networks, ipv4_address) are injected by the composer —
|
|
do NOT include them here. Include: image/build, environment, volumes,
|
|
restart, and any service-specific options.
|
|
|
|
Args:
|
|
decky_name: unique identifier for the decky (e.g. "decky-01")
|
|
log_target: "ip:port" string if log forwarding is enabled, else None
|
|
service_cfg: optional per-service persona config from INI subsection
|
|
"""
|
|
|
|
def dockerfile_context(self) -> Path | None:
|
|
"""
|
|
Return path to the build context directory if this service needs a custom
|
|
image built. Return None if default_image is used directly.
|
|
"""
|
|
return None
|