From 27c4dd9a974476ce68deed0d7602f9f578a1a53e Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 16 Mar 2021 12:33:13 -0700 Subject: [PATCH] Revert "cmd/tailscaled, ipn/{ipnlocal,ipnserver}: let netstack get access to LocalBackend" This reverts commit 2bc518dcb248abb0a84f0ebf7a2d12203d106c66. @namansood didn't end up needing it in his 770aa71ffbfbb01f7c8bfc65ce5e0505c783efde. --- cmd/tailscaled/tailscaled.go | 4 ---- ipn/ipnlocal/future.go | 28 ---------------------------- ipn/ipnserver/server.go | 8 -------- 3 files changed, 40 deletions(-) delete mode 100644 ipn/ipnlocal/future.go diff --git a/cmd/tailscaled/tailscaled.go b/cmd/tailscaled/tailscaled.go index 5c2f0f9cc..a760db708 100644 --- a/cmd/tailscaled/tailscaled.go +++ b/cmd/tailscaled/tailscaled.go @@ -29,7 +29,6 @@ import ( "time" "github.com/go-multierror/multierror" - "tailscale.com/ipn/ipnlocal" "tailscale.com/ipn/ipnserver" "tailscale.com/logpolicy" "tailscale.com/net/socks5" @@ -228,8 +227,6 @@ func run() error { return err } - localBEFuture := ipnlocal.NewLocalBackendFuture() - var ns *netstack.Impl if useNetstack { tunDev, magicConn := e.(wgengine.InternalsGetter).GetInternals() @@ -301,7 +298,6 @@ func run() error { LegacyConfigPath: paths.LegacyConfigPath(), SurviveDisconnects: true, DebugMux: debugMux, - OnBackendCreated: localBEFuture.Set, } err = ipnserver.Run(ctx, logf, pol.PublicID.String(), ipnserver.FixedEngine(e), opts) // Cancelation is not an error: it is the only way to stop ipnserver. diff --git a/ipn/ipnlocal/future.go b/ipn/ipnlocal/future.go deleted file mode 100644 index bcefe8edd..000000000 --- a/ipn/ipnlocal/future.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipnlocal - -import "sync" - -// LocalBackendFuture is a Future that returns a *LocalBackend. -type LocalBackendFuture struct { - getOnce sync.Once - ch chan *LocalBackend - v *LocalBackend -} - -func (f *LocalBackendFuture) Get() *LocalBackend { - f.getOnce.Do(f.get) - return f.v -} - -func (f *LocalBackendFuture) get() { f.v = <-f.ch } -func (f *LocalBackendFuture) Set(v *LocalBackend) { f.ch <- v } - -func NewLocalBackendFuture() *LocalBackendFuture { - return &LocalBackendFuture{ - ch: make(chan *LocalBackend, 1), - } -} diff --git a/ipn/ipnserver/server.go b/ipn/ipnserver/server.go index 2b74035ee..50b848506 100644 --- a/ipn/ipnserver/server.go +++ b/ipn/ipnserver/server.go @@ -92,10 +92,6 @@ type Options struct { // DebugMux, if non-nil, specifies an HTTP ServeMux in which // to register a debug handler. DebugMux *http.ServeMux - - // OnBackendCreated, if non-nil, is called once when the LocalBackend - // is created. - OnBackendCreated func(*ipnlocal.LocalBackend) } // server is an IPN backend and its set of 0 or more active connections @@ -743,10 +739,6 @@ func Run(ctx context.Context, logf logger.Logf, logid string, getEngine func() ( return smallzstd.NewDecoder(nil) }) - if opts.OnBackendCreated != nil { - opts.OnBackendCreated(b) - } - if opts.DebugMux != nil { opts.DebugMux.HandleFunc("/debug/ipn", func(w http.ResponseWriter, r *http.Request) { serveHTMLStatus(w, b)