mirror of
https://github.com/tailscale/tailscale.git
synced 2025-07-31 00:03:47 +00:00
WIP: Testing Netmaps + client packet filter end to end
This commit is contained in:
parent
138a83efe1
commit
39a4dfb85c
@ -201,6 +201,21 @@ func NewNoStart(opts Options) (_ *Auto, err error) {
|
||||
|
||||
}
|
||||
|
||||
func NewForTest(direct *Direct, observer Observer, ctx context.Context) *Auto {
|
||||
c := &Auto{
|
||||
direct: direct,
|
||||
logf: func(fmt string, args ...any) {},
|
||||
updateCh: make(chan struct{}, 1),
|
||||
authDone: make(chan struct{}),
|
||||
mapDone: make(chan struct{}),
|
||||
updateDone: make(chan struct{}),
|
||||
observer: observer,
|
||||
mapCtx: ctx,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
// SetPaused controls whether HTTP activity should be paused.
|
||||
//
|
||||
// The client can be paused and unpaused repeatedly, unlike Start and Shutdown, which can only be used once.
|
||||
@ -468,6 +483,10 @@ func (mrs mapRoutineState) UpdateNetmapDelta(muts []netmap.NodeMutation) bool {
|
||||
return err == nil && ok
|
||||
}
|
||||
|
||||
func (c *Auto) MapRoutineForTest() {
|
||||
c.mapRoutine()
|
||||
}
|
||||
|
||||
// mapRoutine is responsible for keeping a read-only streaming connection to the
|
||||
// control server, and keeping the netmap up to date.
|
||||
func (c *Auto) mapRoutine() {
|
||||
|
@ -1044,6 +1044,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap
|
||||
vlogf("netmap: decode error: %v", err)
|
||||
return err
|
||||
}
|
||||
vlogf("raw netmap: %+v", resp)
|
||||
watchdogTimer.Stop()
|
||||
|
||||
metricMapResponseMessages.Add(1)
|
||||
|
@ -117,6 +117,10 @@ func newMapSession(privateNodeKey key.NodePrivate, nu NetmapUpdater, controlKnob
|
||||
return ms
|
||||
}
|
||||
|
||||
func NewMapSessionForTestOnlyDoNotUse(privateNodeKey key.NodePrivate, nu NetmapUpdater, controlKnobs *controlknobs.Knobs) *mapSession {
|
||||
return newMapSession(privateNodeKey, nu, controlKnobs)
|
||||
}
|
||||
|
||||
// occasionallyPrintSummary logs summary at most once very 5 minutes. The
|
||||
// summary is the Netmap.VeryConcise result from the last received map response.
|
||||
func (ms *mapSession) occasionallyPrintSummary(summary string) {
|
||||
|
@ -1417,6 +1417,10 @@ func (b *LocalBackend) peerCapsLocked(src netip.Addr) tailcfg.PeerCapMap {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *LocalBackend) GetFilterForTest() *filter.Filter {
|
||||
return b.filterAtomic.Load()
|
||||
}
|
||||
|
||||
// SetControlClientStatus is the callback invoked by the control client whenever it posts a new status.
|
||||
// Among other things, this is where we update the netmap, packet filters, DNS and DERP maps.
|
||||
func (b *LocalBackend) SetControlClientStatus(c controlclient.Client, st controlclient.Status) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user