mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
Add packet capture to debug bundle and CLI
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user