Skip to content

feat(wireguard): support WireGuard as an Xray inbound#672

Open
bitwiresys wants to merge 1 commit into
PasarGuard:devfrom
bitwiresys:pr-wg-panel
Open

feat(wireguard): support WireGuard as an Xray inbound#672
bitwiresys wants to merge 1 commit into
PasarGuard:devfrom
bitwiresys:pr-wg-panel

Conversation

@bitwiresys

Copy link
Copy Markdown

What

Lets the panel treat a wireguard inbound inside an Xray core as a first-class inbound: its tag is exposed (so users can be assigned and subscriptions generated for it), and its per-user traffic / online state are recorded. Purely additive — the standalone WireGuard backend (CoreType.wg) is untouched.

Why

Xray now ships a first-class WireGuard inbound with a UserManager (XTLS/Xray-core#6360, in v26.6.27). That makes it possible to serve WireGuard through the same Xray core as VLESS/VMess/Trojan/Shadowsocks — gaining Xray routing, sniffing, unified stats, and transport obfuscation (finalmask) for WG clients — as an alternative to the kernel WG backend. For the panel to use it, the Xray config reader must recognize a wireguard inbound, and usage recording must map WG stats back to panel users.

How

  • app/core/xray.py — add _read_wireguard_inbound, dispatched from _read_inbound when protocol == "wireguard". Surfaces the inbound tag (appears in /api/inbounds) and captures public params (listen port, address, mtu, derived public key).
  • app/jobs/record_usages.py — Xray's WG inbound reports per-user stats keyed by the peer's hex public key (user>>>{hex_pubkey}>>>traffic) rather than the numeric {id}. Add a cached {hex_public_key -> user_id} map and translate those stat names before recording, so WG traffic and the online indicator attribute to the right user. Non-WG stats unaffected (the map is only consulted for non-numeric stat names).

Compatibility / notes

Testing

  • ruff check passes on the changed files; py_compile clean.
  • WG-in-Xray verified end-to-end against a live node: user connects, used_traffic climbs and online_at updates each cycle; 15-minute soak, no disconnects, no client/server errors.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 866a2b72-cb90-4e57-a780-e3b383b9216b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Recognize a `wireguard` protocol inbound inside an Xray core so its tag is
exposed (via /api/inbounds) and users can be assigned to it, and attribute
its per-user traffic/online state.

Xray now ships a first-class WireGuard inbound with a UserManager
(XTLS/Xray-core#6360), so WireGuard can be served through the same Xray
core as the other protocols — in addition to the existing standalone WG
backend (CoreType.wg). This is purely additive.

- app/core/xray.py: `_read_wireguard_inbound` registers a WG-in-Xray
  inbound (interface/listen_port/address/mtu/public key) alongside the
  vmess/vless/trojan/shadowsocks/hysteria readers.
- app/jobs/record_usages.py: the Xray WG inbound reports per-user stats
  keyed by the peer's hex public key; map that back to the panel user id
  so WG traffic and online state are recorded like any other protocol.
@ImMohammad20000

Copy link
Copy Markdown
Contributor

is ther any changes require in https://github.com/PasarGuard/node_bridge_py ?

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.

2 participants