mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-27 03:55:36 +00:00
71029cea2d
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
98 lines
1.9 KiB
Go
98 lines
1.9 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Program testcontrol runs a simple test control server.
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"tailscale.com/tstest/integration"
|
|
"tailscale.com/tstest/integration/testcontrol"
|
|
"tailscale.com/types/logger"
|
|
)
|
|
|
|
var (
|
|
flagNFake = flag.Int("nfake", 0, "number of fake nodes to add to network")
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
var t fakeTB
|
|
derpMap := integration.RunDERPAndSTUN(t, logger.Discard, "127.0.0.1")
|
|
|
|
control := &testcontrol.Server{
|
|
DERPMap: derpMap,
|
|
ExplicitBaseURL: "http://127.0.0.1:9911",
|
|
}
|
|
for i := 0; i < *flagNFake; i++ {
|
|
control.AddFakeNode()
|
|
}
|
|
mux := http.NewServeMux()
|
|
mux.Handle("/", control)
|
|
addr := "127.0.0.1:9911"
|
|
log.Printf("listening on %s", addr)
|
|
err := http.ListenAndServe(addr, mux)
|
|
log.Fatal(err)
|
|
}
|
|
|
|
type fakeTB struct {
|
|
*testing.T
|
|
}
|
|
|
|
func (t fakeTB) Cleanup(_ func()) {}
|
|
func (t fakeTB) Error(args ...any) {
|
|
t.Fatal(args...)
|
|
}
|
|
func (t fakeTB) Errorf(format string, args ...any) {
|
|
t.Fatalf(format, args...)
|
|
}
|
|
func (t fakeTB) Fail() {
|
|
t.Fatal("failed")
|
|
}
|
|
func (t fakeTB) FailNow() {
|
|
t.Fatal("failed")
|
|
}
|
|
func (t fakeTB) Failed() bool {
|
|
return false
|
|
}
|
|
func (t fakeTB) Fatal(args ...any) {
|
|
log.Fatal(args...)
|
|
}
|
|
func (t fakeTB) Fatalf(format string, args ...any) {
|
|
log.Fatalf(format, args...)
|
|
}
|
|
func (t fakeTB) Helper() {}
|
|
func (t fakeTB) Log(args ...any) {
|
|
log.Print(args...)
|
|
}
|
|
func (t fakeTB) Logf(format string, args ...any) {
|
|
log.Printf(format, args...)
|
|
}
|
|
func (t fakeTB) Name() string {
|
|
return "faketest"
|
|
}
|
|
func (t fakeTB) Setenv(key string, value string) {
|
|
panic("not implemented")
|
|
}
|
|
func (t fakeTB) Skip(args ...any) {
|
|
t.Fatal("skipped")
|
|
}
|
|
func (t fakeTB) SkipNow() {
|
|
t.Fatal("skipnow")
|
|
}
|
|
func (t fakeTB) Skipf(format string, args ...any) {
|
|
t.Logf(format, args...)
|
|
t.Fatal("skipped")
|
|
}
|
|
func (t fakeTB) Skipped() bool {
|
|
return false
|
|
}
|
|
func (t fakeTB) TempDir() string {
|
|
panic("not implemented")
|
|
}
|