Skip to content

[client] Add output similar to wg show to the debug package #3922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 5, 2025

Conversation

pappz
Copy link
Contributor

@pappz pappz commented Jun 4, 2025

Describe your changes

Add output similar to wg show to the debug package.

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

@pappz pappz changed the title Add output of wg show to the debug pkg [client] Add output of wg show to the debug pkg Jun 4, 2025
- add interface to status recorder
- fix usp parse
@pappz pappz marked this pull request as ready for review June 4, 2025 12:45
@Copilot Copilot AI review requested due to automatic review settings June 4, 2025 12:45
@pappz pappz changed the title [client] Add output of wg show to the debug pkg [client] Add output similar to wg show to the debug package Jun 4, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds WireGuard interface statistics to the debug bundle by introducing a FullStats method across the interface layers and wiring its output into the debug generator.

  • Define a new WGIfaceStatus interface and expose it via Status.PeersStatus()
  • Implement FullStats() for all WireGuard backends (kernel, userspace, configurer)
  • Generate and include a wg show–style output in the debug archive

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
client/internal/peer/status.go Introduce WGIfaceStatus, SetWgIface, and PeersStatus
client/internal/iface_common.go Add FullStats() to wgIfaceBase interface
client/internal/engine.go Call statusRecorder.SetWgIface(...) on interface start/stop
client/internal/debug/wgshow.go Generate WireGuard stats in toWGShowFormat and add to bundle
client/internal/debug/debug.go Hook addWgShow() into bundle creation
client/iface/iface.go Implement FullStats() proxy on WGIface
client/iface/device/interface.go Add FullStats() to WGConfigurer interface
client/iface/configurer/wgshow.go Define Stats and Peer types for WG stats
client/iface/configurer/usp.go Implement FullStats() and parseStatus() for userspace configurer
client/iface/configurer/kernel_unix.go Implement FullStats() using wgctrl for kernel configurer
Comments suppressed due to low confidence (3)

client/iface/configurer/usp.go:22

  • [nitpick] This constant lacks the ipcKey prefix used by other IPC-related keys, which may confuse readers. Consider renaming to ipcKeyPrivateKey.
privateKey                  = "private_key"

client/internal/peer/status.go:1050

  • [nitpick] The error message references the internal variable name wgInterface. It would be clearer to say something like "WireGuard interface not set".
return nil, fmt.Errorf("wgInterface is nil, cannot retrieve peers status")

client/internal/peer/status.go:35

  • [nitpick] The name WGIfaceStatus mixes abbreviations and may be unclear; consider WireGuardInterfaceStatus or WGInterfaceStatsProvider for clarity.
type WGIfaceStatus interface {

pappz added 3 commits June 4, 2025 17:22
Introduced a mechanism to anonymize peer endpoint addresses in wgshow debug output when anonymization is enabled. Added a new method, AnonymizeUDPAddr, to handle UDP address anonymization in the Anonymizer module.
lixmal
lixmal previously approved these changes Jun 5, 2025
pappz added 2 commits June 5, 2025 11:30
Replaces IP-only endpoint formatting with full endpoint string for improved clarity. This ensures the debug output provides more comprehensive information about peer endpoints.
Updated the debug output of the fwmark field to display in hexadecimal format instead of decimal. This improves readability and consistency with common representations of such values.
Copy link

sonarqubecloud bot commented Jun 5, 2025

@pappz pappz merged commit 9424b88 into main Jun 5, 2025
32 checks passed
@pappz pappz deleted the feature/wgshow-bundle branch June 5, 2025 09:51
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