Introduce a state store to LocalBackend.

The store is passed-in by callers of NewLocalBackend and
ipnserver.Run, but currently all callers are hardcoded to
an in-memory store. The store is unused.

Signed-Off-By: David Anderson <dave@natulte.net>
This commit is contained in:
David Anderson
2020-02-03 10:35:52 -08:00
committed by Dave Anderson
parent 21280ca2d1
commit 5bc632271b
9 changed files with 382 additions and 25 deletions
+12 -1
View File
@@ -29,6 +29,7 @@ import (
)
type Options struct {
StatePath string
SurviveDisconnects bool
AllowQuit bool
}
@@ -58,7 +59,17 @@ func Run(rctx context.Context, logf logger.Logf, logid string, opts Options, e w
return fmt.Errorf("safesocket.Listen: %v", err)
}
b, err := ipn.NewLocalBackend(logf, logid, e)
var store ipn.StateStore
if opts.StatePath != "" {
store, err = ipn.NewFileStore(opts.StatePath)
if err != nil {
return fmt.Errorf("ipn.NewFileStore(%q): %v", opts.StatePath, err)
}
} else {
store = &ipn.MemoryStore{}
}
b, err := ipn.NewLocalBackend(logf, logid, store, e)
if err != nil {
return fmt.Errorf("NewLocalBackend: %v", err)
}