Skip to content

Per-purpose proxy helper: purpose_proxy() builds credentialed SOCKS URLs #4320

Closed

Description

@pithead-architect

What's the problem

Part of pithead#4209 (child of #4146). Every dashboard outbound client passes the validated TOR_SOCKS_PROXY verbatim, so all purposes share one Tor circuit. dashboard/mining_dashboard/service/health/tor_heal.py:125 and service/notify/healthchecks.py:118 already show the mechanism (base.replace("://", f\"://{label}:isolate@", 1)) but it is duplicated inline and no purpose-level label exists. Siblings #4206 (validated setting + fail-closed helper/http.py guard) and #4207 (caller sweep, all callers now on proxy_map(...)) are merged on develop-v2.0.5.

What it impacts

Foundation for forensic isolation of appliance/DIY egress: nothing can carry per-purpose credentials until one shared builder exists.

How I found it

Split of pithead#4209 after re-reading the merged siblings on origin/develop-v2.0.5 (ad76587).

How important is it

Blocking: the three caller-wiring children and the live tier4 child consume this helper.

Acceptance criteria

  • In dashboard/mining_dashboard/helper/http.py (no comments/docstrings), exactly: constants PROXY_PURPOSE_UPDATES = "updates", PROXY_PURPOSE_HEALTH = "health", PROXY_PURPOSE_DASHBOARD = "dashboard", PROXY_PURPOSE_NOTIFY = "notify", and def purpose_proxy(base, label) returning base.replace("://", f\"://{label}:isolate@", 1).
  • Raises ValueError when base contains no :// or label is empty; the label is inserted verbatim (callers pass purpose constants or uuid.uuid4().hex).
  • A requests/PySocks shape note is NOT written as a code comment; the existing PySocks non-empty-fields explanation stays only where it already is outside the edited hunk or moves to docs.
  • Unit tests added to dashboard/tests/helper/test_http.py: two different purposes construct different URLs; same label is stable; the userinfo label:isolate@ is visible in the returned string before the first @; ValueError branches; refuse_direct_public still passes a credentialed proxy as usable.
  • No caller changes; docs that describe outbound egress as one shared circuit are corrected if any say so explicitly (check docs/dev/manual-qa/diy/09-privacy-tor.md, docs/monitoring.md).

Possible solutions

The pinned one-function helper beside proxy_map; parameters-only, never reaching into config (the #4206 parameter-driven rule).

Parent: #4209

Worker brief: Test tier: GitHub tiers 1-3 (dashboard-logic row; name it in the PR body) — no bench job by itself. Add purpose_proxy(base, label) and the four PROXY_PURPOSE_* constants to dashboard/mining_dashboard/helper/http.py exactly as pinned in the Acceptance criteria; unit-test in dashboard/tests/helper/test_http.py (different purposes differ, userinfo present, ValueError branches, guard still passes credentialed proxies). Do not touch any caller module. ruff check + format; no comments/docstrings; local proof is uv run --extra test on the touched pytest modules plus make lint-py shape.

Activity

  1. added this to the v2.0.5 milestone on Nov 20, 2026
  2. added
    dashboard
    security
    appliance
    needs-triage
    size:S
    on Nov 20, 2026
  3. pithead-developer commented on Nov 22, 2026

    @pithead-developer
    Contributor

    Merged in #4347.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appliancedashboardneeds-triagesecuritysize:S

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions