MCPcopy Index your code
hub / github.com/tailscale/tailscale / NewFakeUserspaceEngine

Function NewFakeUserspaceEngine

wgengine/userspace.go:288–317  ·  view source on GitHub ↗

NewFakeUserspaceEngine returns a new userspace engine for testing. The opts may contain the following types: - int or uint16: to set the ListenPort.

(logf logger.Logf, opts ...any)

Source from the content-addressed store, hash-verified

286//
287// - int or uint16: to set the ListenPort.
288func NewFakeUserspaceEngine(logf logger.Logf, opts ...any) (Engine, error) {
289 conf := Config{
290 RespondToPing: true,
291 }
292 for _, o := range opts {
293 switch v := o.(type) {
294 case uint16:
295 conf.ListenPort = v
296 case int:
297 if v < 0 || v > math.MaxUint16 {
298 return nil, fmt.Errorf("invalid ListenPort: %d", v)
299 }
300 conf.ListenPort = uint16(v)
301 case func(any):
302 conf.SetSubsystem = v
303 case *controlknobs.Knobs:
304 conf.ControlKnobs = v
305 case *health.Tracker:
306 conf.HealthTracker = v
307 case *usermetric.Registry:
308 conf.Metrics = v
309 case *eventbus.Bus:
310 conf.EventBus = v
311 default:
312 return nil, fmt.Errorf("unknown option type %T", v)
313 }
314 }
315 logf("Starting userspace WireGuard engine (with fake TUN device)")
316 return NewUserspaceEngine(logf, conf)
317}
318
319// NewUserspaceEngine creates the named tun device and returns a
320// Tailscale Engine running on it.

Callers 15

TestSSHFunction · 0.92
newTestLocalBackendFunction · 0.92
TestLocalLogLinesFunction · 0.92
TestStateMachineFunction · 0.92
TestEditPrefsHasNoKeysFunction · 0.92
TestWGEngineStatusRaceFunction · 0.92
TestLoadCachedNetMapFunction · 0.92
TestUpdateNetMapCacheFunction · 0.92

Calls 2

NewUserspaceEngineFunction · 0.85
ErrorfMethod · 0.65

Tested by 15

TestSSHFunction · 0.74
newTestLocalBackendFunction · 0.74
TestLocalLogLinesFunction · 0.74
TestStateMachineFunction · 0.74
TestEditPrefsHasNoKeysFunction · 0.74
TestWGEngineStatusRaceFunction · 0.74
TestLoadCachedNetMapFunction · 0.74
TestUpdateNetMapCacheFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…