mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 23:07:44 +00:00
73280595a8
A public key should only have max one connection to a given DERP node (or really: one connection to a node in a region). But if people clone their machine keys (e.g. clone their VM, Raspbery Pi SD card, etc), then we can get into a situation where a public key is connected multiple times. Originally, the DERP server handled this by just kicking out a prior connections whenever a new one came. But this led to reconnect fights where 2+ nodes were in hard loops trying to reconnect and kicking out their peer. Then a909d37a59f6e36f47209db4e6b16497715f8de9 tried to add rate limiting to how often that dup-kicking can happen, but empirically it just doesn't work and ~leaks a bunch of goroutines and TCP connections, tying them up for hour+ while more and more accumulate and waste memory. Mostly because we were doing a time.Sleep forever while not reading from their TCP connections. Instead, just accept multiple connections per public key but track which is the most recent. And if two both are writing back & forth, then optionally disable them both. That last part is only enabled in tests for now. The current default policy is just last-sender-wins while we gather the next round of stats. Updates #2751 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Code generated by "stringer -type=dropReason -trimprefix=dropReason"; DO NOT EDIT.
|
|
|
|
package derp
|
|
|
|
import "strconv"
|
|
|
|
func _() {
|
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
// Re-run the stringer command to generate them again.
|
|
var x [1]struct{}
|
|
_ = x[dropReasonUnknownDest-0]
|
|
_ = x[dropReasonUnknownDestOnFwd-1]
|
|
_ = x[dropReasonGone-2]
|
|
_ = x[dropReasonQueueHead-3]
|
|
_ = x[dropReasonQueueTail-4]
|
|
_ = x[dropReasonWriteError-5]
|
|
_ = x[dropReasonDupClient-6]
|
|
}
|
|
|
|
const _dropReason_name = "UnknownDestUnknownDestOnFwdGoneQueueHeadQueueTailWriteErrorDupClient"
|
|
|
|
var _dropReason_index = [...]uint8{0, 11, 27, 31, 40, 49, 59, 68}
|
|
|
|
func (i dropReason) String() string {
|
|
if i < 0 || i >= dropReason(len(_dropReason_index)-1) {
|
|
return "dropReason(" + strconv.FormatInt(int64(i), 10) + ")"
|
|
}
|
|
return _dropReason_name[_dropReason_index[i]:_dropReason_index[i+1]]
|
|
}
|