ipn/ipnserver: remove IPN protocol server

Unused in this repo as of the earlier #6450 (300aba61a6)
and unused in the Windows GUI as of tailscale/corp#8065.

With this ipn.BackendServer is no longer used and could also be
removed from this repo. The macOS and iOS clients still temporarily
depend on it, but I can move it to that repo instead while and let its
migration proceed on its own schedule while we clean this repo up.

Updates #6417
Updates tailscale/corp#8051

Change-Id: Ie13f82af3eb9f96b3a21c56cdda51be31ddebdcf
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-11-25 07:54:57 -08:00
committed by Brad Fitzpatrick
parent 624d9c759b
commit 7e016c1d90
7 changed files with 32 additions and 759 deletions

View File

@@ -1,86 +0,0 @@
// Copyright (c) 2020 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 ipnserver_test
import (
"context"
"fmt"
"path/filepath"
"strings"
"testing"
"tailscale.com/ipn"
"tailscale.com/ipn/ipnserver"
"tailscale.com/ipn/store/mem"
"tailscale.com/net/tsdial"
"tailscale.com/safesocket"
"tailscale.com/wgengine"
"tailscale.com/wgengine/netstack"
)
func TestRunMultipleAccepts(t *testing.T) {
t.Skipf("TODO(bradfitz): finish this test, once other fires are out")
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
td := t.TempDir()
socketPath := filepath.Join(td, "tailscale.sock")
logf := func(format string, args ...any) {
format = strings.TrimRight(format, "\n")
println(fmt.Sprintf(format, args...))
t.Logf(format, args...)
}
s := safesocket.DefaultConnectionStrategy(socketPath)
connect := func() {
for i := 1; i <= 2; i++ {
logf("connect %d ...", i)
c, err := safesocket.Connect(s)
if err != nil {
t.Fatalf("safesocket.Connect: %v\n", err)
}
clientToServer := func(b []byte) {
ipn.WriteMsg(c, b)
}
bc := ipn.NewBackendClient(logf, clientToServer)
prefs := ipn.NewPrefs()
bc.SetPrefs(prefs)
c.Close()
}
}
logTriggerTestf := func(format string, args ...any) {
logf(format, args...)
if strings.HasPrefix(format, "Listening on ") {
connect()
}
}
eng, err := wgengine.NewFakeUserspaceEngine(logf, 0)
if err != nil {
t.Fatal(err)
}
t.Cleanup(eng.Close)
opts := ipnserver.Options{}
t.Logf("pre-Run")
store := new(mem.Store)
ln, _, err := safesocket.Listen(socketPath, 0)
if err != nil {
t.Fatal(err)
}
defer ln.Close()
err = ipnserver.Run(ctx, logTriggerTestf, ln, store, nil /* mon */, new(tsdial.Dialer), "dummy_logid", FixedEngine(eng), opts)
t.Logf("ipnserver.Run = %v", err)
}
// FixedEngine returns a func that returns eng and a nil error.
func FixedEngine(eng wgengine.Engine) func() (wgengine.Engine, *netstack.Impl, error) {
return func() (wgengine.Engine, *netstack.Impl, error) { return eng, nil, nil }
}