Show both sign-ins on the first screen and find servers automatically

This commit is contained in:
Ian Gulliver
2026-10-20 14:08:35 -07:00
parent a728cb2c96
commit da7f952855
7 changed files with 130 additions and 48 deletions
+18 -3
View File
@@ -14,6 +14,7 @@ import (
"os/signal"
"path/filepath"
"strings"
"sync"
"syscall"
"time"
@@ -52,9 +53,7 @@ func serveCmd(args []string) {
ts := &tsnet.Server{
Dir: filepath.Join(*dataDir, "tsnet"),
Hostname: *hostname,
UserLogf: func(format string, args ...any) {
slog.Info("tsnet", "msg", fmt.Sprintf(format, args...))
},
UserLogf: tsnetLogf(),
}
err = ts.Start()
if err != nil {
@@ -124,6 +123,22 @@ func serveTailnet(ctx context.Context, ts *tsnet.Server, hs *http.Server) {
}
}
func tsnetLogf() func(string, ...any) {
mu := sync.Mutex{}
last := ""
return func(format string, args ...any) {
msg := fmt.Sprintf(format, args...)
mu.Lock()
repeat := msg == last
last = msg
mu.Unlock()
if repeat {
return
}
slog.Info("tsnet", "msg", msg)
}
}
func macSlug() string {
out, err := exec.Command("scutil", "--get", "ComputerName").Output()
if err != nil {