cmd/tailscaled: add -state=mem: to support creation of an ephemeral node.

RELNOTE=`tailscaled --state=mem:` registers as an ephemeral node and
does not store state to disk.

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2022-02-18 12:55:22 -08:00
committed by Maisem Ali
parent 823d970d60
commit f9a50779e2
12 changed files with 46 additions and 18 deletions

View File

@@ -54,6 +54,10 @@ type Server struct {
// log.Printf is used.
Logf logger.Logf
// Ephemeral, if true, specifies that the instance should register
// as an Ephemeral node (https://tailscale.com/kb/1111/ephemeral-nodes/).
Emphemeral bool
initOnce sync.Once
initErr error
lb *ipnlocal.LocalBackend
@@ -173,7 +177,11 @@ func (s *Server) start() error {
}
logid := "tslib-TODO"
lb, err := ipnlocal.NewLocalBackend(logf, logid, store, s.dialer, eng)
loginFlags := controlclient.LoginDefault
if s.Emphemeral {
loginFlags = controlclient.LoginEphemeral
}
lb, err := ipnlocal.NewLocalBackend(logf, logid, store, s.dialer, eng, loginFlags)
if err != nil {
return fmt.Errorf("NewLocalBackend: %v", err)
}