MCPcopy Index your code
hub / github.com/Tght1211/lan-proxy-gateway

github.com/Tght1211/lan-proxy-gateway @v3.4.13

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.4.13 ↗ · + Follow
709 symbols 2,091 edges 97 files 321 documented · 45%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

LAN Proxy Gateway

Release Go Platform License

Turn one computer into a LAN-wide proxy gateway. Configure proxies once on the gateway machine, and every device in your house (phone / Switch / PS5 / Apple TV / smart TV) uses them — no proxy app needed on each device.

Menu-driven CLI · one-line install · built-in Gateway web dashboard. Built on mihomo (Clash.Meta). 中文: README.md

flowchart LR
    subgraph LAN["🏠 Home LAN"]
        direction TB
        S[🎮 Switch / PS5 / Apple TV]
        M[📱 iPhone / Android / TV box]
        PC[💻 Other computers]
    end
    GW["🖥️ Gateway computer

mihomo · TUN · rule-based routing"]
    SRC["🌐 Proxy source

subscription / local config / single proxy"]
    LAN -- "Change gateway, or set proxy" --> GW --> SRC

    style LAN fill:#fff5e6,stroke:#ff9900
    style GW fill:#e6f3ff,stroke:#0066cc
    style SRC fill:#e6ffe6,stroke:#00aa00

⚡ 3-Minute Quick Start

1. Install

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/Tght1211/lan-proxy-gateway/main/install.sh | bash

# Windows (Administrator PowerShell)
irm https://raw.githubusercontent.com/Tght1211/lan-proxy-gateway/main/install.ps1 | iex

The script walks you through a setup wizard (proxy source → start → optional auto-start). If GitHub is slow from your network, set GITHUB_MIRROR=https://your-mirror/, or if you already have Clash running locally, export HTTP_PROXY=http://127.0.0.1:7897 first.

2. Start

sudo gateway start     # macOS / Linux
gateway start          # Windows (Administrator terminal, no sudo)

The console shows the LAN IP and proxy port — that's what your other devices will point at.

3. Connect devices

Your device Method What to fill in
🎮 Switch / PS5 / Apple TV / smart TV Change gateway (macOS / Linux only) Gateway + DNS = the gateway computer's LAN IP
📱 iPhone / Android / browser Set HTTP proxy HTTP proxy: gateway IP : 17890
💻 The gateway machine itself TUN Enable TUN in the menu; on macOS press L to switch local DNS

⚠️ Windows Home limitation: no RRAS, ICS is locked to 192.168.137/24, so "change gateway" mode does not work. All devices must use the "set HTTP proxy" path. Switch / PS5 / Apple TV / smart TVs that can only take a gateway (not a proxy) cannot be served from a Windows host — use Linux / macOS or a soft router instead.

Detailed walkthroughs (with screenshots): docs/en/ — phone / switch / ps5 / appletv / tv


✨ What it does

Capability What it gives you
🌐 LAN transparent gateway Devices join by changing gateway + DNS (macOS/Linux); devices that can't change gateway use HTTP proxy (all platforms)
🔗 Three proxy sources Clash/mihomo subscription URL · local .yaml · an already-running Clash port on the same machine (chaining); local single-proxy mode still supports both 17890 sharing and transparent gateway mode
🏠 Chains preset One-click "airport entry → residential exit" — AI sites see a residential ASN
🌐 Built-in web dashboard Open http://gatewayIP:19091/ to switch proxy sources, policy groups, nodes, run latency tests, inspect connected devices, and control TUN / proxy service independently
🔐 Proxy service auth The LAN HTTP/SOCKS5 mixed-port can be enabled/disabled independently and optionally protected with username/password while TUN stays available
Source supervisor Auto-fallbacks subscription/file sources to direct when broken; local single-proxy mode only monitors the port to avoid false switches
🎯 Rule system Built-in LAN-direct, China-direct, Apple, Nintendo, ad-blocking, AI-service rules; custom rules can target Proxy or any named policy group, for example AI domains through a residential exit while YouTube keeps using the normal proxy group
📊 Node latency probe Switch-node page concurrently measures latency and sorts by speed
🗒️ Readable log view mihomo's English logs rendered in a folded, deduplicated view

🎯 Who it's for

  • 🎮 You want proxies on Switch / PS5 / Apple TV / smart TV — these devices have no proxy app to install, only a gateway field. Common uses: Switch online play, eShop / PSN downloads, Steam / Epic / Xbox downloads
  • 📱 You don't want a VPN app on your phone — set the Wi-Fi proxy to your home gateway and you're done
  • 👨‍👩‍👧 One household subscription, all devices — keep the subscription on one machine, every other device joins with zero config
  • 🔁 Augment Clash Verge / V2RayN / Mihomo Party — reuse the running client's node pool; bolt on chains, LAN sharing, and TUN gateway without replacing it

Detailed scenarios + traffic-path diagrams: docs/scenarios.md (Chinese)


🆚 vs. Clash Verge's "LAN Access"

Item Clash Verge LAN Access LAN Proxy Gateway
Proxy layer Application-level HTTP proxy Network-level transparent proxy + TUN
Device setup Fill proxy IP:Port on every device Change gateway + DNS (only option for devices that don't take a proxy)
Switch / PS5 / TV Mostly no proxy field → unusable ✅ Works natively
App proxy awareness Often detectable Closer to a real router
Chains ✅ One-click preset

📚 Documentation

Device setup

Commands & config


🔄 Update / rollback

gateway update                 # latest release (recommended: do NOT pre-sudo)
gateway update latest          # same as above
gateway update v3.4.3          # specific tag (or rollback)

Since v3.4.9, don't pre-sudo: the command runs version lookup and asset download under your user identity (preserving HTTPS_PROXY etc.), then requests sudo only for the stop/replace/restart step. sudo gateway update still works, but macOS's default sudoers strips proxy variables, so GitHub becomes unreachable.

First time upgrading from a pre-v3.4.3 install (no gateway update subcommand yet), just re-run the install script — it overwrites in place and preserves your gateway.yaml:

curl -fsSL https://raw.githubusercontent.com/Tght1211/lan-proxy-gateway/main/install.sh | sudo bash

🛠️ Local Development

./dev.sh build        # writes .tmp/gateway-dev
./dev.sh test         # go test ./...
./dev.sh test-core    # smaller core package set
./dev.sh run -- --version
./dev.sh start        # builds locally, sudo only for the runtime step

The Go build cache defaults to .cache/go-build inside the repo to avoid global-cache permission issues.


📜 License

MIT © 2025-2026 Tght1211 Built on mihomo + metacubexd.

⭐ Star History

Star History Chart

Extension points exported contracts — how you extend this code

Platform (Interface)
Platform is the OS-specific runtime facade. [6 implementers]
internal/platform/platform.go

Core symbols most depended-on inside this repo

Close
called by 54
internal/geoip/geoip.go
Default
called by 34
internal/config/schema.go
ask
called by 25
internal/console/console.go
Running
called by 25
internal/engine/engine.go
run
called by 24
internal/platform/platform.go
Error
called by 23
internal/engine/preflight.go
New
called by 17
internal/app/app.go
banner
called by 16
internal/console/console.go

Shape

Function 399
Method 239
Struct 69
Interface 1
TypeAlias 1

Languages

Go99%
TypeScript1%

Modules by API surface

internal/gateway/gateway_test.go30 symbols
cmd/update.go30 symbols
internal/source/source.go27 symbols
internal/console/dashboard.go27 symbols
internal/config/schema.go24 symbols
internal/platform/platform.go23 symbols
internal/platform/platform_windows.go22 symbols
internal/platform/platform_darwin.go22 symbols
internal/app/app_test.go21 symbols
internal/platform/platform_linux.go20 symbols
internal/console/console_test.go20 symbols
internal/engine/preflight.go17 symbols

For agents

$ claude mcp add lan-proxy-gateway \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page