feat(wireguard): support WireGuard as an Xray inbound#672
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.
|
is ther any changes require in https://github.com/PasarGuard/node_bridge_py ? |
What
Lets the panel treat a
wireguardinbound 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
wireguardinbound, and usage recording must map WG stats back to panel users.How
app/core/xray.py— add_read_wireguard_inbound, dispatched from_read_inboundwhenprotocol == "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 checkpasses on the changed files;py_compileclean.used_trafficclimbs andonline_atupdates each cycle; 15-minute soak, no disconnects, no client/server errors.