Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/internal/engine/trusttunnel_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type ttOutbound struct {
asking atomic.Bool // one _check at a time decides what a refused stream meant
}

// ttDialTimeout is how long a TCP connect to a TrustTunnel endpoint may take.
const ttDialTimeout = 5 * time.Second

func startTT(ctx context.Context, p *profile.TrustTunnel, endpoints []netip.AddrPort) (*ttOutbound, error) {
if p == nil || len(endpoints) == 0 {
return nil, ttclient.ErrConfig
Expand All @@ -72,6 +75,11 @@ func startTT(ctx context.Context, p *profile.TrustTunnel, endpoints []netip.Addr
if err != nil {
return nil, ttclient.ErrEndpoint
}
// Windows gives a lost SYN 21 s before it says so. Seen live: a first attempt hung that long on a node whose
// network drops packets now and then, and the retry a second later connected at once. Two retransmissions
// fit in ttDialTimeout; after it the attempt fails and the session's own retry takes over.
ctx, cancel := context.WithTimeout(ctx, ttDialTimeout)
defer cancel()
return (directOutbound{}).DialTCP(ctx, endpoint)
},
ListenPacket: directPacketConn,
Expand Down
Loading