Zum Hauptinhalt springen
Y

dsh-net-hub

yangdw2024/dsh-net-hub

Cross-platform network diagnostics and local port sharing in the sidebar and via the net_hub tool: multi-DNS and direct-vs-proxy X-Ray, listening port radar, built-in Bearer-token L7 reverse proxy with offline SVG QR, Cloudflare Quick Tunnel, Caddy v2 config/reload, SSH tunnel snippets, AI endpoint TTFT benchmarking, Git/npm/pnpm/pip proxy sync, and auto-discovered Mihomo/Clash and Tailscale controls. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.

Installation

dsh plugin --profile web add github:yangdw2024/dsh-net-hub

README

dsh-net-hub

Cross-platform Network X-Ray, Multi-Line Local Port Sharer, AI Endpoint TTFT Lab & Live Proxy Cockpit for DeepSeek Harness (DSH).

npm License: MIT Platform

English | 简体中文


Why dsh-net-hub?

Every DSH user runs into host-level network friction:

  • "Why does GitHub / PyPI / my university HPC portal fail with ERR_CONNECTION_CLOSED under TUN?"
  • "The browser works, why do git clone, npm install, and pip install time out in the terminal?"
  • "How do I share my local 127.0.0.1 AI gateway / Ollama / Vite server with my phone, dorm PC, or home PC safely?"
  • "Which OpenAI/Anthropic endpoint has the lowest TTFT and fastest tok/s right now?"

dsh-net-hub works out of the box with zero external dependencies and zero hardcoded paths. On top of 4 universal core tools, it automatically discovers ecosystem tools installed on your machine (Clash Verge / Mihomo, Tailscale, Caddy v2, cloudflared, v2rayN, LoomGate, Antigravity Tools, CC Switch) and dynamically unlocks live controls — hiding whatever you don't have installed.


Features

1. Universal Core (Works on any Windows / macOS / Linux PC, 0 dependencies)

  • URL / API Connectivity X-Ray: Parallel multi-DNS comparison (auto-detects Split-Horizon campus/corporate DNS & Fake-IP 198.18.x), Direct vs Local Proxy race (real HTTPS CONNECT + TLSv1.3 handshake), TLS certificate check, and actionable recommendations.
  • Dev Tool Proxy Alignment: Inspect and one-click sync/clear proxy settings across Git, npm, pnpm, pip (pip.ini/pip.conf), plus ready-to-copy PowerShell / Bash / Zsh / Fish env snippets.
  • Cross-Platform Port Radar + Multi-Line Port Sharing:
    • Scans active listening ports with process names and bind scope (Loopback vs LAN) on Windows, macOS (lsof), and Linux (ss).
    • Line 1 (Built-in L7 Reverse Proxy — 0 dependencies): Expose any 127.0.0.1 port to LAN/Tailscale with zero-buffer SSE streaming, immediate upstream abort on client disconnect, optional generated Bearer token (nh_...), live request log, and offline SVG QR code modal.
    • Line 2 (Cloudflare Quick Tunnel): Auto-discovers cloudflared and fronts local ports with the token-protected Built-in Proxy before publishing an instant https://*.trycloudflare.com URL.
    • Line 3 (Caddy v2 Studio): Generates multi-route Caddyfile (flush_interval -1), runs caddy validate, and supports zero-downtime caddy reload over :2019.
    • Line 4 (SSH Reverse Tunnel): One-click ssh -N -R and ProxyJump snippet generation.
  • AI Endpoint Lab & Streaming TTFT Benchmark: Auto-discovers local Ollama (:11434), LM Studio (:1234), vLLM (:8000), LoomGate (:8787), and Antigravity (:8045), probes /v1/models, runs explicit lightweight streaming benchmarks (max_tokens=32) measuring TTFT (ms) & throughput (tok/s), and copies configs for OpenAI / Claude Code / Codex / Gemini CLI / cURL.

2. Auto-Discovered Ecosystem Controls (Hidden when not installed)

  • Mihomo / Clash Verge Live Cockpit: Connects directly to Windows Named Pipe (\\.\pipe\verge-mihomo-*), macOS/Linux Unix Socket (/tmp/verge/verge-mihomo.sock), or HTTP controller (:9097/:9090) for live upload/download speed, 1-click Rule / Global / Direct switching, node selector + ping test, and active connection tracker with 1-click Add DIRECT & Kill.
  • Tailscale Mesh & Gateways: Live Tailnet coordinates, peer status, SSH ProxyJump generator, Antigravity allow_lan_access toggle, v2rayN core inventory, and CC Switch overview.

3. One Operation, Two Callers (UI + Agent Tool)

Every capability in the sidebar Net hub panel is exposed to DSH agents via the unified net_hub tool so your AI assistant can self-diagnose network errors, probe endpoints, sync Git/npm proxies, or spin up a temporary share proxy on demand.


Installation

Open Settings → Plugins in DeepSeek Harness and install dsh-net-hub, or run:

dsh plugin add dsh-net-hub

From Local Directory

git clone https://github.com/yangdw2024/dsh-net-hub.git
# In DSH: Plugins -> Add plugin -> select the cloned directory

Security & Privacy Boundaries

  • Secret Redaction (src/redact.js): All config reads use explicit allowlists plus recursive redaction (api_key, token, secret, password, subscription URLs, inline sk-* / Bearer strings). Ephemeral keys entered in AI Lab are never persisted to disk.
  • Loopback-Only Host Fence: All /api/dsh-net-hub/* HTTP routes verify loopback socket + loopback Host header + reject X-Forwarded-For / CF-Connecting-IP (403 Forbidden), while honoring DSH's own paired-device session when present.
  • Backup-Before-Write: Every file mutation (Merge.yaml, config.yaml, gui_config.json, pip.ini, settings.json) creates a timestamped .bak backup and writes atomically.
  • Clean Teardown: Unloading or disabling the plugin stops all managed built-in share servers, cloudflared tunnels, and Caddy processes.

Repository Map (For Humans & AI Agents)

Start here instead of scanning the entire tree:

PathResponsibility
index.jsHost Cordis entry, mountOnce guard, Loopback-fenced /api/dsh-net-hub/* routes, and net_hub agent tool schema/dispatch.
client.jsZero-build browser UI (sidebar.panellist + main panel), 5 tabs, Settings modal, and offline SVG QR encoder.
src/service.jsNetHubService orchestrator — single source of truth shared by HTTP routes and the net_hub tool.
src/platform.jsCross-platform OS abstraction (Windows PowerShell, macOS lsof/scutil, Linux ss/resolv.conf, executable discovery).
src/settings.jsPersistent user settings store at ~/.dsh/net-hub/settings.json with universal zero-hardcode defaults.
src/redact.jsRecursive secret key/value scrubber.
src/utils.jsTCP/HTTP/Proxy probes, atomic file writer with .bak, Loopback request fence.
src/lines/Multi-line sharing layer: index.js (LineRegistry), cloudflared.js, ssh-tunnel.js (+ adapters/builtin-proxy.js, adapters/caddy.js). See docs/LINE_INTEGRATION.md.
src/adapters/xray.jsMulti-DNS + Direct vs Proxy HTTPS race + TLS certificate inspector.
src/adapters/port-radar.jsCross-platform listening socket radar & service classifier.
src/adapters/ai-lab.jsLocal AI discovery, /v1/models probe, streaming SSE TTFT & tok/s benchmark.
src/adapters/dev-proxy-sync.jsGit / npm / pnpm / pip proxy sync & clear + shell env snippets.
src/adapters/mihomo-live.jsLive Mihomo/Clash controller over Windows Named Pipe / Unix Socket / HTTP.
src/adapters/clash-verge.jsSafe Merge.yaml (preserving existing rules, never overwriting fake-ip-filter) & TUN exclusion updater.
src/adapters/tailscale.jsCross-platform tailscale status --json parser (filters funnel-ingress-node).
tests/net-hub.test.jsnode --test unit & live integration test suite.

Where to Look When Debugging

  • Mihomo tab does not appear: Check src/adapters/mihomo-live.js _discover() (Named Pipe on Windows, Unix Socket on macOS/Linux, HTTP :9097/:9090 fallback).
  • Port Radar shows wrong process or empty list: Check OS parser in src/platform.js (listRawListeningSockets, parseLsofListenOutput, parseSsListenOutput).
  • Share proxy returns 401 or 502: Check src/adapters/builtin-proxy.js token header stripping and clientRes.on('close') abort hook.
  • Caddy validation or start fails: Check src/adapters/caddy.js sanitizeListenAddr (bare IPs need http:// prefix in Caddy v2) and :2019 Origin header.

Development & Testing

npm test

License

MIT © yangdw2024

Ähnliche Plugins