wgengine: make opts.Metrics mandatory

Fixes #13582

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
pull/13598/head
Kristoffer Dalby 2 months ago committed by Kristoffer Dalby
parent 7d1160ddaa
commit 5550a17391

@ -196,7 +196,8 @@ type Config struct {
// HealthTracker, if non-nil, is the health tracker to use.
HealthTracker *health.Tracker
// Metrics, if non-nil, is the usermetrics registry to use.
// Metrics is the usermetrics registry to use.
// Mandatory, if not set, an error is returned.
Metrics *usermetric.Registry
// Dialer is the dialer to use for outbound connections.
@ -273,6 +274,10 @@ func NewUserspaceEngine(logf logger.Logf, conf Config) (_ Engine, reterr error)
panic("NewUserspaceEngine called without HealthTracker (being strict in tests)")
}
if conf.Metrics == nil {
return nil, errors.New("NewUserspaceEngine: opts.Metrics is required, please pass a *usermetric.Registry")
}
if conf.Tun == nil {
logf("[v1] using fake (no-op) tun device")
conf.Tun = tstun.NewFake()

Loading…
Cancel
Save