derp, wgengine: let clients advertise an opaque app name to DERP servers
Add an AppName field to the DERP ClientInfo so DERP servers can attribute connections to the application making them, primarily for best effort stats purposes. The value is plumbed per engine instance rather than via a process global, so a process hosting multiple stacks can attribute each one's DERP connections separately: wgengine.Config.DERPAppName flows through magicsock.Options and derphttp.Client into the naclbox-sealed ClientInfo JSON. Old servers ignore the unknown field. There are no callers in the tree yet setting the name. Updates tailscale/corp#24454 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Change-Id: Ia7d3e9c2b6f8140e5a9d7c3b2e6f1a8d4c0b5e9f
This commit is contained in:
committed by
Brad Fitzpatrick
parent
37e175a032
commit
246c82a658
@@ -60,6 +60,7 @@ type Client struct {
|
||||
DNSCache *dnscache.Resolver // optional; nil means no caching
|
||||
MeshKey key.DERPMesh // optional; for trusted clients
|
||||
IsProber bool // optional; for probers to optional declare themselves as such
|
||||
AppName string // optional; opaque app name to advertise to the server for stats
|
||||
|
||||
// WatchConnectionChanges is whether the client wishes to subscribe to
|
||||
// notifications about clients connecting & disconnecting.
|
||||
@@ -413,6 +414,7 @@ func (c *Client) connect(ctx context.Context, caller string) (client *derp.Clien
|
||||
derp.MeshKey(c.MeshKey),
|
||||
derp.CanAckPings(c.canAckPings),
|
||||
derp.IsProber(c.IsProber),
|
||||
derp.AppName(c.AppName),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -558,6 +560,7 @@ func (c *Client) connect(ctx context.Context, caller string) (client *derp.Clien
|
||||
derp.ServerPublicKey(serverPub),
|
||||
derp.CanAckPings(c.canAckPings),
|
||||
derp.IsProber(c.IsProber),
|
||||
derp.AppName(c.AppName),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
|
||||
Reference in New Issue
Block a user