@ -178,9 +178,10 @@ type Conn struct {
// A publisher for synchronization points to ensure correct ordering of
// config changes between magicsock and wireguard.
syncPub * eventbus . Publisher [ syncPoint ]
allocRelayEndpointPub * eventbus . Publisher [ UDPRelayAllocReq ]
portUpdatePub * eventbus . Publisher [ router . PortUpdate ]
syncPub * eventbus . Publisher [ syncPoint ]
allocRelayEndpointPub * eventbus . Publisher [ UDPRelayAllocReq ]
portUpdatePub * eventbus . Publisher [ router . PortUpdate ]
tsmpDiscoKeyAvailablePub * eventbus . Publisher [ NewDiscoKeyAvailable ]
// pconn4 and pconn6 are the underlying UDP sockets used to
// send/receive packets for wireguard and other magicsock
@ -691,6 +692,7 @@ func NewConn(opts Options) (*Conn, error) {
c . syncPub = eventbus . Publish [ syncPoint ] ( ec )
c . allocRelayEndpointPub = eventbus . Publish [ UDPRelayAllocReq ] ( ec )
c . portUpdatePub = eventbus . Publish [ router . PortUpdate ] ( ec )
c . tsmpDiscoKeyAvailablePub = eventbus . Publish [ NewDiscoKeyAvailable ] ( ec )
eventbus . SubscribeFunc ( ec , c . onPortMapChanged )
eventbus . SubscribeFunc ( ec , c . onFilterUpdate )
eventbus . SubscribeFunc ( ec , c . onNodeViewsUpdate )
@ -2239,6 +2241,7 @@ func (c *Conn) handleDiscoMessage(msg []byte, src epAddr, shouldBeRelayHandshake
if debugDisco ( ) {
c . logf ( "magicsock: disco: failed to open naclbox from %v (wrong rcpt?) via %s" , sender , via )
}
metricRecvDiscoBadKey . Add ( 1 )
return
}
@ -2646,6 +2649,8 @@ func (c *Conn) enqueueCallMeMaybe(derpAddr netip.AddrPort, de *endpoint) {
return
}
c . maybeSendTSMPDiscoAdvert ( de )
eps := make ( [ ] netip . AddrPort , 0 , len ( c . lastEndpoints ) )
for _ , ep := range c . lastEndpoints {
eps = append ( eps , ep . Addr )
@ -4306,3 +4311,16 @@ func (c *Conn) HandleDiscoKeyAdvertisement(node tailcfg.NodeView, update packet.
c . logf ( "magicsock: updated disco key for peer %v to %v" , nodeKey . ShortString ( ) , discoKey . ShortString ( ) )
metricTSMPDiscoKeyAdvertisementApplied . Add ( 1 )
}
type NewDiscoKeyAvailable struct {
EpAddr netip . Addr
}
func ( c * Conn ) maybeSendTSMPDiscoAdvert ( de * endpoint ) {
if de . lastTSMPDiscoAdvertisement == 0 {
de . lastTSMPDiscoAdvertisement = mono . Now ( )
c . tsmpDiscoKeyAvailablePub . Publish ( NewDiscoKeyAvailable {
EpAddr : de . nodeAddr ,
} )
}
}