[PR #6751] [MERGED] fix(service): overlay WireGuard peer public key from the inbound #6439

Closed
opened 2026-11-02 04:08:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6751
Author: @mvanhorn
Created: 10/6/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @MHSanaei

Base: main ← Head: fix/6731-wireguard-inbound-public-key


📝 Commits (2)

  • 2a6a9d5 web: overlay WireGuard peer public key from the inbound
  • 7a490c4 Merge branch 'main' into fix/6731-wireguard-inbound-public-key

📊 Changes

2 files changed (+46 additions, -6 deletions)

View changed files

📝 internal/web/service/xray.go (+8 -0)
📝 internal/web/service/xray_wireguard_config_test.go (+38 -6)

📄 Description

Summary

The WireGuard branch now copies PublicKey from the matching inbound settings client. When that entry's KeepAlive is nil the peer keepalive is cleared, and when it is set the integer is copied into a new pointer. The dual-tunnel test seeds different keys and keepalives, checks that the shared row still has the AmneziaWG identity, and expects the emitted WireGuard peer to use the WireGuard public key and keepalive, including a case where the WireGuard settings entry has no keepalive and the peer omits it.

Closes #6731

Why

A client attached to both a WireGuard inbound and an AmneziaWG inbound gets a WireGuard peer in the generated Xray config whose public key is the AmneziaWG identity, and the peer can also keep the other tunnel's keepalive. The subscription still gives that client the WireGuard inbound's private key, so the WireGuard handshake is never answered. GetXrayConfig builds the WireGuard peer from the shared clients row and only overwrites AllowedIPs and PreSharedKey from the inbound settings entry for that email. PublicKey and KeepAlive stay as stored on the shared row, which holds the tunnel identity of whichever WireGuard or AmneziaWG inbound was synced last, and WireguardPeerFromClient emits those leftover fields. A keepalive missing from this inbound's settings therefore also leaves the other tunnel's interval in place.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

gofmt -l on the changed WireGuard config files printed nothing.
go vet ./internal/web/service/... printed no diagnostics.
go test ./internal/web/service/... passed.

Screenshots / recordings

No user-visible surface changes in this PR, so there is nothing to show.

Breaking changes

Covered in the summary above.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
    Not claimed: go build ./... is a different command from the local runs that passed, gofmt, go vet and go test.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
    Not claimed: npm run lint is a different command from the local runs that passed, gofmt, go vet and go test.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

AI disclosure

AI was used for assistance.

  • Tools: an AI coding assistant.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6751 **Author:** [@mvanhorn](https://github.com/mvanhorn) **Created:** 10/6/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/6731-wireguard-inbound-public-key` --- ### 📝 Commits (2) - [`2a6a9d5`](https://github.com/MHSanaei/3x-ui/commit/2a6a9d5191e927d6d091c0798cd3cc186b3715e2) web: overlay WireGuard peer public key from the inbound - [`7a490c4`](https://github.com/MHSanaei/3x-ui/commit/7a490c454a4819234d03c9b23c98e85775305125) Merge branch 'main' into fix/6731-wireguard-inbound-public-key ### 📊 Changes **2 files changed** (+46 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/xray.go` (+8 -0) 📝 `internal/web/service/xray_wireguard_config_test.go` (+38 -6) </details> ### 📄 Description ## Summary The WireGuard branch now copies PublicKey from the matching inbound settings client. When that entry's KeepAlive is nil the peer keepalive is cleared, and when it is set the integer is copied into a new pointer. The dual-tunnel test seeds different keys and keepalives, checks that the shared row still has the AmneziaWG identity, and expects the emitted WireGuard peer to use the WireGuard public key and keepalive, including a case where the WireGuard settings entry has no keepalive and the peer omits it. Closes #6731 ## Why A client attached to both a WireGuard inbound and an AmneziaWG inbound gets a WireGuard peer in the generated Xray config whose public key is the AmneziaWG identity, and the peer can also keep the other tunnel's keepalive. The subscription still gives that client the WireGuard inbound's private key, so the WireGuard handshake is never answered. GetXrayConfig builds the WireGuard peer from the shared clients row and only overwrites AllowedIPs and PreSharedKey from the inbound settings entry for that email. PublicKey and KeepAlive stay as stored on the shared row, which holds the tunnel identity of whichever WireGuard or AmneziaWG inbound was synced last, and WireguardPeerFromClient emits those leftover fields. A keepalive missing from this inbound's settings therefore also leaves the other tunnel's interval in place. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? gofmt -l on the changed WireGuard config files printed nothing. go vet ./internal/web/service/... printed no diagnostics. go test ./internal/web/service/... passed. ## Screenshots / recordings No user-visible surface changes in this PR, so there is nothing to show. ## Breaking changes Covered in the summary above. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. Not claimed: `go build ./...` is a different command from the local runs that passed, `gofmt`, `go vet` and `go test`. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. Not claimed: `npm run lint` is a different command from the local runs that passed, `gofmt`, `go vet` and `go test`. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [ ] My commits follow the project's existing message style. - [ ] I have no unrelated changes mixed into this PR. **AI disclosure** AI was used for assistance. - Tools: an AI coding assistant. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:08:46 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6439
No description provided.