[GH-ISSUE #5168] [Feature]: Peer Comments for WireGuard Inbounds #3632

Closed
opened 2026-10-31 20:33:50 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Ssentiago on GitHub (Jun 10, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5168

Summary

Add the ability to annotate WireGuard peers with human-readable comments directly in the 3x-ui panel.

Problem

When managing a WireGuard inbound with many peers, it's impossible to tell at a glance which peer belongs to which client or device. The only identifiers are the public key and allowed IP — neither of which is human-friendly. There's no way to label a peer as "Alice's laptop" or "office router" without keeping a separate external document.

Describe the solution you'd like

Since WireGuard peer config is passed directly to Xray and comments can't be stored inside the Xray JSON config, the panel itself should own this metadata.

Concretely: store a separate key-value map in the panel's own database, keyed by peer's allowed IP (or public key), with a comment string as the value.

{
  "10.0.0.2": "Alice — MacBook Pro",
  "10.0.0.3": "Office router",
  "10.0.0.4": "Bob — Android"
}

Lifecycle rules:

  • Comment is created/updated when the peer is created or edited
  • Comment is deleted automatically when the peer is deleted
  • If the peer IP changes, the comment key should follow

UI

  • Add a "Comment" text field in the peer add/edit dialog
  • Display the comment in the peers list as a secondary label under the public key
  • Optionally: allow filtering/searching peers by comment

Alternatives you've considered

No response

Concrete use case

Concrete Use Case

a WireGuard inbound with ~40 peers across multiple devices and users

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

Frontend (UI / panel pages)

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @Ssentiago on GitHub (Jun 10, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5168 ### Is your feature request related to a problem? **Summary** Add the ability to annotate WireGuard peers with human-readable comments directly in the 3x-ui panel. **Problem** When managing a WireGuard inbound with many peers, it's impossible to tell at a glance which peer belongs to which client or device. The only identifiers are the public key and allowed IP — neither of which is human-friendly. There's no way to label a peer as "Alice's laptop" or "office router" without keeping a separate external document. ### Describe the solution you'd like Since WireGuard peer config is passed directly to Xray and comments can't be stored inside the Xray JSON config, the panel itself should own this metadata. Concretely: store a separate key-value map in the panel's own database, keyed by peer's allowed IP (or public key), with a comment string as the value. ```json { "10.0.0.2": "Alice — MacBook Pro", "10.0.0.3": "Office router", "10.0.0.4": "Bob — Android" } ``` Lifecycle rules: - Comment is created/updated when the peer is created or edited - Comment is deleted automatically when the peer is deleted - If the peer IP changes, the comment key should follow **UI** - Add a "Comment" text field in the peer add/edit dialog - Display the comment in the peers list as a secondary label under the public key - Optionally: allow filtering/searching peers by comment ### Alternatives you've considered _No response_ ### Concrete use case **Concrete Use Case** a WireGuard inbound with ~40 peers across multiple devices and users ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? Frontend (UI / panel pages) ### Are you willing to help? - [x] I'd like to implement this feature myself and open a PR. - [x] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 10, 2026):

Thanks for the detailed request and for offering to implement it — this is a well-scoped feature.

Current state (confirmed in source)

In v3.3.0, a WireGuard peer object is a plain JSON blob stored inside Inbound.Settings with only these fields (internal/database/model/model.go, frontend/src/test/golden/fixtures/inbound-full/wireguard-server.json):

{
  "publicKey": "...",
  "privateKey": "...",
  "allowedIPs": ["10.0.0.2/32"],
  "keepAlive": 25
}

There is no comment, remark, or name field at the peer level. The per-inbound Remark field on the Inbound struct exists, but only labels the inbound as a whole. Two related issues (#3285, #4381) were previously filed and closed as completed, but this specific sub-feature was not included.

Key implementation constraint

The entire settings JSON string is passed verbatim to the Xray API as a json_util.RawMessage (internal/xray/inbound.go:15). Adding a comment key inside each peer object would send that field directly to Xray-core, which may reject unknown fields or behave unexpectedly. Your instinct to keep comments outside the Xray config is correct.

Recommended storage approach

Add a peerComments map at the top level of the settings JSON, sibling to the peers array (not nested inside each peer):

{
  "mtu": 1420,
  "secretKey": "...",
  "peers": [
    { "publicKey": "ABC...", "allowedIPs": ["10.0.0.2/32"], "keepAlive": 25 }
  ],
  "peerComments": {
    "ABC...": "Alice — MacBook Pro",
    "XYZ...": "Office router"
  },
  "noKernelTun": false
}

Using publicKey as the map key is more reliable than allowedIPs since keys are stable identifiers that don't change when the IP is reassigned. The peerComments key must then be stripped out in the Xray config-building path before the settings are handed off to Xray-core.

Touch points for the PR

  • internal/database/model/model.go — add a helper or document the peerComments convention if a typed struct is introduced
  • Xray config generation path — strip peerComments from the settings before dispatching to Xray (look at how internal/xray/inbound.go and internal/web/service/ build the config)
  • Frontend (frontend/src/lib/xray/) — add a comment field to the peer form adapter and the peer add/edit dialog; render it as a secondary label in the peers list
  • Lifecycle handling (rename key if publicKey changes, delete key on peer removal) — this will live in the frontend form adapter and/or the inbound service

Happy to review a draft PR when it's ready.

<!-- gh-comment-id:4670691791 --> @github-actions[bot] commented on GitHub (Jun 10, 2026): Thanks for the detailed request and for offering to implement it — this is a well-scoped feature. **Current state (confirmed in source)** In v3.3.0, a WireGuard peer object is a plain JSON blob stored inside `Inbound.Settings` with only these fields (`internal/database/model/model.go`, `frontend/src/test/golden/fixtures/inbound-full/wireguard-server.json`): ```json { "publicKey": "...", "privateKey": "...", "allowedIPs": ["10.0.0.2/32"], "keepAlive": 25 } ``` There is no `comment`, `remark`, or name field at the peer level. The per-inbound `Remark` field on the `Inbound` struct exists, but only labels the inbound as a whole. Two related issues (#3285, #4381) were previously filed and closed as completed, but this specific sub-feature was not included. **Key implementation constraint** The entire `settings` JSON string is passed verbatim to the Xray API as a `json_util.RawMessage` (`internal/xray/inbound.go:15`). Adding a `comment` key inside each peer object would send that field directly to Xray-core, which may reject unknown fields or behave unexpectedly. Your instinct to keep comments outside the Xray config is correct. **Recommended storage approach** Add a `peerComments` map at the top level of the settings JSON, sibling to the `peers` array (not nested inside each peer): ```json { "mtu": 1420, "secretKey": "...", "peers": [ { "publicKey": "ABC...", "allowedIPs": ["10.0.0.2/32"], "keepAlive": 25 } ], "peerComments": { "ABC...": "Alice — MacBook Pro", "XYZ...": "Office router" }, "noKernelTun": false } ``` Using `publicKey` as the map key is more reliable than `allowedIPs` since keys are stable identifiers that don't change when the IP is reassigned. The `peerComments` key must then be stripped out in the Xray config-building path before the settings are handed off to Xray-core. **Touch points for the PR** - `internal/database/model/model.go` — add a helper or document the `peerComments` convention if a typed struct is introduced - Xray config generation path — strip `peerComments` from the settings before dispatching to Xray (look at how `internal/xray/inbound.go` and `internal/web/service/` build the config) - Frontend (`frontend/src/lib/xray/`) — add a `comment` field to the peer form adapter and the peer add/edit dialog; render it as a secondary label in the peers list - Lifecycle handling (rename key if `publicKey` changes, delete key on peer removal) — this will live in the frontend form adapter and/or the inbound service Happy to review a draft PR when it's ready.
Author
Owner

@MHSanaei commented on GitHub (Jun 12, 2026):

Implemented in d04cb109. Each WireGuard peer now has an optional Comment field in the inbound form — it''s echoed next to the peer number in the form, stored as panel-side metadata in the peer JSON (xray-core ignores it), and when set it''s appended to the generated share link / .conf remark (e.g. "wg-1 (Alice''s laptop)") so the device is identifiable in client apps as well. Will be in the next release.

<!-- gh-comment-id:4688389171 --> @MHSanaei commented on GitHub (Jun 12, 2026): Implemented in d04cb109. Each WireGuard peer now has an optional Comment field in the inbound form — it''s echoed next to the peer number in the form, stored as panel-side metadata in the peer JSON (xray-core ignores it), and when set it''s appended to the generated share link / .conf remark (e.g. "wg-1 (Alice''s laptop)") so the device is identifiable in client apps as well. Will be in the next release.
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#3632
No description provided.