mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-08-27 21:00:28 +02:00
Harden mesh bootstrap defaults
This commit is contained in:
@@ -39,7 +39,10 @@ class Settings(BaseSettings):
|
||||
MESH_PUBLIC_PEER_URL: str = ""
|
||||
# Bootstrap seeds are discovery hints, not authoritative network roots.
|
||||
# Nodes promote healthy discovered peers from the store/manifest over time.
|
||||
MESH_BOOTSTRAP_SEED_PEERS: str = "http://gqpbunqbgtkcqilvclm3xrkt3zowjyl3s62kkktvojgvxzizamvbrqid.onion:8000"
|
||||
MESH_BOOTSTRAP_SEED_PEERS: str = ""
|
||||
# Optional comma-separated override for the public fleet's bundled onion seeds.
|
||||
# This lets seed rotation/addition ship as env/config without weakening private sync.
|
||||
MESH_FLEET_SEED_PEERS: str = ""
|
||||
# Legacy name kept for older compose/.env files.
|
||||
MESH_DEFAULT_SYNC_PEERS: str = ""
|
||||
# Infonet/Wormhole must fail closed to private transports by default.
|
||||
|
||||
@@ -10,6 +10,9 @@ FLEET_NETWORK_ID = "sb-testnet-0"
|
||||
FLEET_SEED_ONION_URL = (
|
||||
"http://gqpbunqbgtkcqilvclm3xrkt3zowjyl3s62kkktvojgvxzizamvbrqid.onion:8000"
|
||||
)
|
||||
FLEET_SEED_ONION_URLS = (
|
||||
FLEET_SEED_ONION_URL,
|
||||
)
|
||||
FLEET_BOOTSTRAP_SIGNER_PUBLIC_KEY_B64 = (
|
||||
"ul1d0kj/ODPIp0OhHzX8eLAVXzJ3CVvzW1vn2IC6q3I="
|
||||
)
|
||||
@@ -56,9 +59,35 @@ def effective_peer_push_secret() -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def _dedupe_peer_urls(peers: list[str]) -> list[str]:
|
||||
from services.mesh.mesh_router import parse_configured_relay_peers
|
||||
|
||||
seen: set[str] = set()
|
||||
normalized: list[str] = []
|
||||
for peer in parse_configured_relay_peers(",".join(str(item or "") for item in peers)):
|
||||
if peer in seen:
|
||||
continue
|
||||
seen.add(peer)
|
||||
normalized.append(peer)
|
||||
return normalized
|
||||
|
||||
|
||||
def effective_fleet_seed_peers() -> list[str]:
|
||||
try:
|
||||
from services.config import get_settings
|
||||
|
||||
configured = str(getattr(get_settings(), "MESH_FLEET_SEED_PEERS", "") or "").strip()
|
||||
if configured:
|
||||
return _dedupe_peer_urls([configured])
|
||||
except Exception:
|
||||
pass
|
||||
return _dedupe_peer_urls(list(FLEET_SEED_ONION_URLS))
|
||||
|
||||
|
||||
def configured_bootstrap_seed_peers_with_fleet_default(peers: list[str]) -> list[str]:
|
||||
if peers:
|
||||
return peers
|
||||
normalized_peers = _dedupe_peer_urls(peers)
|
||||
if normalized_peers:
|
||||
return normalized_peers
|
||||
if infonet_fleet_join_enabled():
|
||||
return [FLEET_SEED_ONION_URL]
|
||||
return effective_fleet_seed_peers()
|
||||
return []
|
||||
|
||||
@@ -301,8 +301,9 @@ def refresh_swarm_manifest_from_seeds(*, now: float | None = None, force: bool =
|
||||
if not _signer_public_key_b64():
|
||||
return {"ok": False, "detail": "MESH_BOOTSTRAP_SIGNER_PUBLIC_KEY is not configured"}
|
||||
|
||||
last_error = "manifest fetch failed"
|
||||
for seed_url in _configured_seed_peer_urls():
|
||||
seed_urls = _configured_seed_peer_urls()
|
||||
last_error = "bootstrap seeds unreachable; local node will retry"
|
||||
for seed_url in seed_urls:
|
||||
manifest = fetch_remote_bootstrap_manifest(seed_url, now=timestamp)
|
||||
if manifest is None:
|
||||
continue
|
||||
@@ -311,12 +312,18 @@ def refresh_swarm_manifest_from_seeds(*, now: float | None = None, force: bool =
|
||||
return {
|
||||
"ok": True,
|
||||
"seed_peer_url": seed_url,
|
||||
"tried_seed_count": len(seed_urls),
|
||||
"peer_count": len(manifest.peers),
|
||||
"merged_peer_count": merged,
|
||||
}
|
||||
except Exception as exc:
|
||||
last_error = str(exc or type(exc).__name__)
|
||||
return {"ok": False, "detail": last_error}
|
||||
return {
|
||||
"ok": False,
|
||||
"detail": last_error,
|
||||
"tried_seed_count": len(seed_urls),
|
||||
"retrying": bool(seed_urls),
|
||||
}
|
||||
|
||||
|
||||
def announce_local_peer_to_seeds(*, now: float | None = None, force: bool = False) -> dict[str, Any]:
|
||||
|
||||
@@ -103,11 +103,12 @@ def _invite_lookup_request_timeout(peer_url: str) -> tuple[int, int]:
|
||||
def _bootstrap_seed_peer_urls() -> set[str]:
|
||||
try:
|
||||
from services.config import get_settings
|
||||
from services.mesh.mesh_fleet_defaults import configured_bootstrap_seed_peers_with_fleet_default
|
||||
from services.mesh.mesh_router import parse_configured_relay_peers
|
||||
|
||||
seeds: set[str] = set()
|
||||
raw = str(getattr(get_settings(), "MESH_BOOTSTRAP_SEED_PEERS", "") or "")
|
||||
for peer in parse_configured_relay_peers(raw):
|
||||
for peer in configured_bootstrap_seed_peers_with_fleet_default(parse_configured_relay_peers(raw)):
|
||||
normalized = str(peer or "").strip().rstrip("/")
|
||||
if normalized:
|
||||
seeds.add(normalized)
|
||||
@@ -318,6 +319,8 @@ def _configured_public_lookup_peer_urls() -> list[str]:
|
||||
from services.mesh.mesh_router import active_sync_peer_urls, parse_configured_relay_peers
|
||||
|
||||
settings = get_settings()
|
||||
from services.mesh.mesh_fleet_defaults import configured_bootstrap_seed_peers_with_fleet_default
|
||||
|
||||
candidates: list[str] = []
|
||||
# Operator-configured peers first, then recently active fleet nodes.
|
||||
# Invite handles are minted on a specific node; cold bootstrap seeds
|
||||
@@ -330,7 +333,11 @@ def _configured_public_lookup_peer_urls() -> list[str]:
|
||||
for raw in (
|
||||
getattr(settings, "MESH_BOOTSTRAP_SEED_PEERS", ""),
|
||||
):
|
||||
candidates.extend(parse_configured_relay_peers(str(raw or "")))
|
||||
candidates.extend(
|
||||
configured_bootstrap_seed_peers_with_fleet_default(
|
||||
parse_configured_relay_peers(str(raw or ""))
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user