Downstream worker connections are tracked by worker id (#2949)

When possible downstream workers will include their worker id information in
the connections they establish with the upstream using the nodeenrollment
library.  The tracking listener now tracks connections that are connected in
this same way instead of just connections of type *tls.Conn.
This commit is contained in:
Todd committed 2023-02-10 15:27:42 -08:00
1 parent 5e3244a2e5
commit 1e89be1b1a
17 files changed
+951 -215

No files matched your search

+9 -3
View File
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/observability/event"
nodee "github.com/hashicorp/nodeenrollment"
"github.com/hashicorp/nodeenrollment/protocol"
)
// EventingListener simply sends an event when a worker has connected
@@ -41,9 +42,14 @@ func (e *eventingListener) Accept() (net.Conn, error) {
return conn, err
}
tlsConn, ok := conn.(*tls.Conn)
if !ok {
return conn, err
var tlsConn *tls.Conn
switch c := conn.(type) {
case *tls.Conn:
tlsConn = c
case *protocol.Conn:
tlsConn = c.Conn
default:
return conn, nil
}
if tlsConn != nil && len(tlsConn.ConnectionState().PeerCertificates) > 0 {