Add LAN sharing toggle for the local proxy port#95
Conversation
Adds an "allow LAN connections" toggle to the edit-local-port dialog that switches the local socks/http inbound to listen on 0.0.0.0 instead of 127.0.0.1, so other devices on the LAN can use this machine as a proxy (mirrors v2rayN's LAN sharing). The dialog shows and lets you copy the resulting LAN address (best-effort NIC detection reusing TunService's existing adapter-selection helpers), and the change reapplies live via the existing ReapplyRoutingAsync mechanism when xray is already running (no-op under TUN mode, same as routing/DNS changes today). No authentication is added on the inbound in this pass — it was explicitly scoped out for now, so enabling LAN sharing exposes an unauthenticated proxy to the local network. Worth a second look before shipping broadly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f7b0183ec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ["tag"] = XrayConfigConstants.MixedInboundTag, | ||
| ["protocol"] = "socks", | ||
| ["listen"] = "127.0.0.1", | ||
| ["listen"] = settings.AllowLanConnections ? "0.0.0.0" : "127.0.0.1", |
There was a problem hiding this comment.
Avoid binding LAN sharing to every interface
When Allow LAN is enabled on a host where Windows Firewall allows xray.exe and the machine also has a VPN/public adapter, 0.0.0.0 publishes the no-auth inbound on those interfaces as well, not just the LAN address shown in the dialog. That lets peers outside the intended local subnet use the proxy. Please bind a separate LAN inbound to the selected local address while keeping loopback for local use, or make the all-interface exposure explicit.
Useful? React with 👍 / 👎.
Summary
0.0.0.0instead of127.0.0.1, so other devices on the LAN can point their proxy settings at this machine — the same idea as v2rayN's LAN sharing.ip:portand lets you copy it (reuses the existingCopyButtoncontrol). LAN address detection reusesTunService's existing adapter-selection helpers (IsTunLikeInterface,HasIPv4Gateway) rather than re-deriving NIC selection logic.ReapplyRoutingAsyncmechanism when xray is already running, matching how routing-mode and DNS changes already behave (no-op under TUN mode — takes effect on the next connect there).Notes for reviewers
xray.exethrough on first LAN-bound listen; no explicit firewall-rule handling was added, relying on the standard OS prompt.Test plan
dotnet buildsucceeds (viaBuildAndRun.ps1 -SkipRun)