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

Abierto
#199 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@cnupy ya está trabajando en esto.

Desde el 23/11/2026.

  • #201 de @cnupy — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
24/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
networking

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
10.1k
Forks
470
Merge medio
1 d 14 h
PR fusionados (30 d)
19

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de tailscale/tailcat

Todos los issues de tailscale/tailcat

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.