Skip to content

Add LAN sharing toggle for the local proxy port#95

Merged
PhoenixNil merged 1 commit into
mainfrom
feat/lan-sharing-toggle
Jul 12, 2026
Merged

Add LAN sharing toggle for the local proxy port#95
PhoenixNil merged 1 commit into
mainfrom
feat/lan-sharing-toggle

Conversation

@PhoenixNil

@PhoenixNil PhoenixNil commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds an "allow LAN connections" toggle to the edit-local-port dialog. When on, the local socks/http inbound listens on 0.0.0.0 instead of 127.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.
  • The dialog shows the resulting ip:port and lets you copy it (reuses the existing CopyButton control). LAN address detection reuses TunService's existing adapter-selection helpers (IsTunLikeInterface, HasIPv4Gateway) rather than re-deriving NIC selection logic.
  • The port/LAN change reapplies live via the existing ReapplyRoutingAsync mechanism 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

  • No authentication is added on the inbound. This was explicitly scoped out for this pass. Enabling LAN sharing exposes an unauthenticated socks/http proxy to the local network — anyone on the same subnet can use it. Worth a deliberate decision on whether auth should land before this ships broadly.
  • Windows Firewall may prompt to allow xray.exe through on first LAN-bound listen; no explicit firewall-rule handling was added, relying on the standard OS prompt.

Test plan

  • dotnet build succeeds (via BuildAndRun.ps1 -SkipRun)
  • Manually toggled LAN sharing on/off in the edit-port dialog, verified the address line and copy button
  • Verify from a second LAN device that the proxy is reachable when enabled, and unreachable when disabled

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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@PhoenixNil PhoenixNil merged commit 96806c3 into main Jul 12, 2026
4 checks passed
@PhoenixNil PhoenixNil deleted the feat/lan-sharing-toggle branch July 12, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant