Add packet capture to debug bundle and CLI

This commit is contained in:
Viktor Liu
2026-04-15 07:26:13 +02:00
parent e804a705b7
commit e58c29d4f9
44 changed files with 4327 additions and 238 deletions

View File

@@ -24,6 +24,7 @@ import (
"github.com/netbirdio/netbird/client/system"
"github.com/netbirdio/netbird/shared/management/domain"
mgmProto "github.com/netbirdio/netbird/shared/management/proto"
"github.com/netbirdio/netbird/util/capture"
)
var (
@@ -489,6 +490,22 @@ func (c *Client) getEngine() (*internal.Engine, error) {
return engine, nil
}
// SetCapture sets or clears packet capture on this client's WireGuard device.
// Pass nil to disable capture.
func (c *Client) SetCapture(sess *capture.Session) error {
engine, err := c.getEngine()
if err != nil {
return err
}
// Explicit nil check to avoid wrapping a nil *Session in the
// device.PacketCapture interface, which would appear non-nil to
// FilteredDevice and cause a nil-pointer dereference in Offer.
if sess == nil {
return engine.SetCapture(nil)
}
return engine.SetCapture(sess)
}
func (c *Client) getNet() (*wgnetstack.Net, netip.Addr, error) {
engine, err := c.getEngine()
if err != nil {