forked from admin/ansible
Replace tuple-of-strings with frozen Endpoint dataclass carrying optional (proxy_host, proxy_port) tuple. Add network_map.NETWORK_MAP populated from the live swarm endpoints discovered via the docker socket, and a separate PUBLIC_SERVICES list sourced from the squid allowlist plus well-known public hosts. Endpoints with proxy are checked via HTTP CONNECT through that proxy; endpoints without are probed directly via TCP after attaching to the relevant overlay network. Cross-validation rules cover leaks and missing expectations per round.
123 lines
3.7 KiB
Python
123 lines
3.7 KiB
Python
from dataclasses import dataclass
|
|
from typing import Dict, List, Optional, Tuple
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Endpoint:
|
|
name: str
|
|
port: int
|
|
proxy: Optional[Tuple[str, int]] = None
|
|
tls: bool = False
|
|
|
|
|
|
SWARM_NETWORKS = (
|
|
"hermes_infra_hermes_proxy",
|
|
"hermes_infra_squid_egress",
|
|
"hermes_infra_admin",
|
|
"hermes_infra_default",
|
|
"hermes_hermes",
|
|
"gitea_gitea",
|
|
"gmail_mcp_default",
|
|
"immich_default",
|
|
"torrserv_proxy_default",
|
|
"docker_socket_proxy_hermes_proxy",
|
|
"connectivity_tester_default",
|
|
"brencher_brencher-net",
|
|
"brencher2_brencher-net",
|
|
)
|
|
|
|
|
|
SQUID_PROXY: Tuple[str, int] = ("squid", 3128)
|
|
|
|
|
|
NETWORK_MAP: Dict[str, List[Endpoint]] = {
|
|
"hermes_infra_hermes_proxy": [
|
|
Endpoint("hermes-gateway", 8000),
|
|
Endpoint("hermes-ui", 8087),
|
|
Endpoint("squid", 3128),
|
|
Endpoint("docker_socket_proxy", 2375),
|
|
Endpoint("brencher-state-proxy", 80),
|
|
],
|
|
"hermes_infra_squid_egress": [
|
|
Endpoint("squid", 3128),
|
|
],
|
|
"hermes_infra_admin": [
|
|
Endpoint("sarg", 80),
|
|
],
|
|
"hermes_infra_default": [
|
|
Endpoint("hermes-ui", 8087),
|
|
],
|
|
"hermes_hermes": [
|
|
Endpoint("hermes-agent", 8000),
|
|
Endpoint("hermes-gateway", 8000),
|
|
],
|
|
"gitea_gitea": [
|
|
Endpoint("gitea-server", 3000),
|
|
Endpoint("act_runner", 8088),
|
|
Endpoint("cache_server", 37051),
|
|
],
|
|
"gmail_mcp_default": [
|
|
Endpoint("gmail-mcp-server", 8000),
|
|
Endpoint("telegram-mcp-server", 8000),
|
|
],
|
|
"immich_default": [
|
|
Endpoint("immich-server", 2283),
|
|
Endpoint("immich-database", 5432),
|
|
Endpoint("immich-redis", 6379),
|
|
Endpoint("immich-machine-learning", 8501),
|
|
],
|
|
"torrserv_proxy_default": [
|
|
Endpoint("fileserver", 8000),
|
|
Endpoint("reverseproxy", 8080),
|
|
],
|
|
"docker_socket_proxy_hermes_proxy": [
|
|
Endpoint("hermes-gateway", 8000),
|
|
],
|
|
"connectivity_tester_default": [
|
|
Endpoint("connectivity-tester", 8765),
|
|
],
|
|
"brencher_brencher-net": [
|
|
Endpoint("brencher-backend", 5000),
|
|
],
|
|
"brencher2_brencher-net": [
|
|
Endpoint("brencher-backend", 5000),
|
|
],
|
|
}
|
|
|
|
|
|
PUBLIC_SERVICES: List[Endpoint] = [
|
|
Endpoint("gitea.rudolf.keenetic.link", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("gitea.rudolf.keenetic.link", 80, proxy=SQUID_PROXY),
|
|
Endpoint("registry.rudolf.keenetic.link", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("registry.rudolf.keenetic.link", 5000, proxy=SQUID_PROXY),
|
|
Endpoint("deb.debian.org", 80, proxy=SQUID_PROXY),
|
|
Endpoint("deb.debian.org", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("github.com", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("githubusercontent.com", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("telegram.org", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("t.me", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("minimax.io", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("minimax.chat", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("minimax.com", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("pypi.org", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("google.com", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("cloudflare.com", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("wikipedia.org", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("mozilla.org", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("1.1.1.1", 443, proxy=SQUID_PROXY, tls=True),
|
|
Endpoint("8.8.8.8", 53),
|
|
Endpoint("8.8.4.4", 53),
|
|
]
|
|
|
|
|
|
GLOBAL_SERVICES: List[Endpoint] = sorted(
|
|
{ep for eps in NETWORK_MAP.values() for ep in eps} | set(PUBLIC_SERVICES),
|
|
key=lambda e: (e.name, e.port),
|
|
)
|
|
|
|
|
|
NEGATIVE: List[Endpoint] = [
|
|
Endpoint("169.254.169.254", 80),
|
|
Endpoint("metadata.google.internal", 80),
|
|
]
|