A client that restarts with the same node key takes about 5 s to connect

Aperta
#199 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@cnupy ci sta già lavorando.

Dal 23/11/2026.

  • #201 di @cnupy — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
24/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
networking

Direzione di ricerca

Read onMeow in tailcat.go (around line 1821 on v0.8.0 and main) and the early return for an already-known client key, then follow discoPrivateForNode to see how the client's disco key is derived from its node key. On the magicsock side, trace what happens to the cached endpoint when the netmap's DiscoKey changes, since that is the path trust the fix relies on. The author has a working fix and test and intends to open a PR, so confirm with them before starting; done means a restarted client connects in a few hundred ms and repeated Ping() within one client keeps its disco key.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I use tailcat as a library with a saved client key, so the server can allowlist it. Each request starts a new client process. When a new process connects soon after the previous one, the connect takes over 5 s instead of a few hundred ms.

Measured with v0.8.0 against one long-running server through a DERP relay, 5 connects back to back and then one after 20 s idle: 416 ms, 10.7 s, then 5.4 to 5.7 s, and 5.6 s after the idle gap. In-process with a local DERP and STUN server: 3.1 s for the first, then 5.07 to 5.36 s for each restart.

What I see in the logs:

  1. The client's disco key is derived from its node key (discoPrivateForNode), so every process with the same key file has the same disco key.
  2. On the server, onMeow returns early for a client key it already knows (tailcat.go:1821 in v0.8.0, the same on main), before the AllowClient hook. The netmap and the magicsock endpoint stay as they were.
  3. magicsock still trusts the old process's direct UDP address. The server sends its WireGuard handshake response there and it is lost.
  4. The client retries after WireGuard's 5 s handshake timeout, and by then the server has found the new path.

The fix that works for me:

  • A client gets a fresh disco key for each Client. The server keeps deriving its disco key from its node key, since that key is part of its address.
  • When a known client sends a meow with a different disco key, onMeow updates DiscoKey on a clone of the node and pushes the new netmap. magicsock then drops its trust in the old path, and replies go through DERP until the new direct path is found. A known client was already admitted, so this path doesn't call AllowClient again, the same as today.

With that change the same relay sequence gives 489 ms, 1.3 s, then 335 to 383 ms, and 371 ms after 20 s idle. In-process: 3.1 s for the first, then 109 to 125 ms. Repeated Ping() calls inside one client keep the same disco key, so they don't reset a good path.

A fix with a test is ready; I'll open a PR that references this issue.

Lingua principale
Go
Stelle
10.1k
Fork
470
Merge medio
1g 14h
PR unite (30g)
19

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tailscale/tailcat

Tutte le issue di tailscale/tailcat

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.