cmd/derper: treat self-connection connection watch as no-op

Updates #388
reviewable/pr440/r1
Brad Fitzpatrick 2020-06-04 08:26:05 -07:00
parent 5798826990
commit b663ab4685
2 changed files with 8 additions and 1 deletions

View File

@ -44,7 +44,7 @@ var (
logCollection = flag.String("logcollection", "", "If non-empty, logtail collection to log to")
runSTUN = flag.Bool("stun", false, "also run a STUN server")
meshPSKFile = flag.String("mesh-psk-file", defaultMeshPSKFile(), "if non-empty, path to file containing the mesh pre-shared key file. It should contain some hex string; whitespace is trimmed.")
meshWith = flag.String("mesh-with", "", "optional comma-separated list of hostnames to mesh with; the server's own hostname can be in the list, in which case it's ignored if its DNS resolves to an IP on the machine")
meshWith = flag.String("mesh-with", "", "optional comma-separated list of hostnames to mesh with; the server's own hostname can be in the list")
)
type config struct {

View File

@ -259,6 +259,13 @@ func (s *Server) addWatcher(c *sclient) {
panic("invariant: addWatcher called without permissions")
}
if c.key == s.publicKey {
// We're connecting to ourself. Do nothing.
// TODO(bradfitz): have client notice and disconnect
// so an idle TCP connection isn't kept open.
return
}
s.mu.Lock()
defer s.mu.Unlock()