ipn: set BackendServer's notify earlier; don't require Start

We've been slowly making Start less special and making IPN a
multi-connection "watch" bus of changes, but this Start specialness
had remained.

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2021-04-12 10:33:50 -07:00
parent 8e4d1e3f2c
commit d9ee9a0d3f

View File

@ -94,11 +94,13 @@ type BackendServer struct {
}
func NewBackendServer(logf logger.Logf, b Backend, sendNotifyMsg func(b []byte)) *BackendServer {
return &BackendServer{
bs := &BackendServer{
logf: logf,
b: b,
sendNotifyMsg: sendNotifyMsg,
}
b.SetNotifyCallback(bs.send)
return bs
}
func (bs *BackendServer) send(n Notify) {
@ -188,7 +190,6 @@ func (bs *BackendServer) GotCommand(ctx context.Context, cmd *Command) error {
bs.GotQuit = true
return errors.New("Quit command received")
} else if c := cmd.Start; c != nil {
bs.b.SetNotifyCallback(bs.send)
opts := c.Opts
return bs.b.Start(opts)
} else if c := cmd.StartLoginInteractive; c != nil {