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

オープン
#199 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@cnupy がすでに取り組んでいます。

2026年11月23日 から。

  • #201 @cnupy による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
24/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
networking

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Go
スター
10.1k
フォーク
470
平均マージ
1日 14時間
マージ済み PR(30日)
19

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tailscale/tailcat のほかの issue

tailscale/tailcat の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。