mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-24 20:27:51 +00:00
sockstats: switch label to enum
Makes it cheaper/simpler to persist values, and encourages reuse of labels as opposed to generating an arbitrary number. Updates tailscale/corp#9230 Updates #3363 Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:

committed by
Mihai Parparita

parent
9687f3700d
commit
6ac6ddbb47
@@ -3050,7 +3050,12 @@ func (c *Conn) ReSTUN(why string) {
|
||||
// listenPacket opens a packet listener.
|
||||
// The network must be "udp4" or "udp6".
|
||||
func (c *Conn) listenPacket(network string, port uint16) (nettype.PacketConn, error) {
|
||||
ctx := sockstats.WithSockStats(context.Background(), fmt.Sprintf("magicsock.Conn:%s", network)) // unused without DNS name to resolve
|
||||
ctx := context.Background() // unused without DNS name to resolve
|
||||
if network == "udp4" {
|
||||
ctx = sockstats.WithSockStats(ctx, sockstats.LabelMagicsockConnUDP4)
|
||||
} else {
|
||||
ctx = sockstats.WithSockStats(ctx, sockstats.LabelMagicsockConnUDP6)
|
||||
}
|
||||
addr := net.JoinHostPort("", fmt.Sprint(port))
|
||||
if c.testOnlyPacketListener != nil {
|
||||
return nettype.MakePacketListenerWithNetIP(c.testOnlyPacketListener).ListenPacket(ctx, network, addr)
|
||||
|
Reference in New Issue
Block a user