Show both sign-ins on the first screen and find servers automatically
This commit is contained in:
+18
-3
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user