diff --git a/management/server/account.go b/management/server/account.go index e00a31b73..d6c14afc3 100644 --- a/management/server/account.go +++ b/management/server/account.go @@ -462,6 +462,12 @@ func (a *Account) GetExpiredPeers() []*nbpeer.Peer { // If there is no peer that expires this function returns false and a duration of 0. // This function only considers peers that haven't been expired yet and that are connected. func (a *Account) GetNextPeerExpiration() (time.Duration, bool) { + startTime := time.Now() + defer func() { + duration := time.Since(startTime) + log.Debugf("GetNextPeerExpiration took %s", duration) + }() + peersWithExpiry := a.GetPeersWithExpiration() if len(peersWithExpiry) == 0 { return 0, false @@ -518,6 +524,11 @@ func (a *Account) UpdateSettings(update *Settings) *Account { // UpdatePeer saves new or replaces existing peer func (a *Account) UpdatePeer(update *nbpeer.Peer) { + startTime := time.Now() + defer func() { + duration := time.Since(startTime) + log.Debugf("UpdatePeer took %s", duration) + }() a.Peers[update.ID] = update } @@ -547,6 +558,12 @@ func (a *Account) DeletePeer(peerID string) { // FindPeerByPubKey looks for a Peer by provided WireGuard public key in the Account or returns error if it wasn't found. // It will return an object copy of the peer. func (a *Account) FindPeerByPubKey(peerPubKey string) (*nbpeer.Peer, error) { + startTime := time.Now() + defer func() { + duration := time.Since(startTime) + log.Debugf("FindPeerByPubKey took %s", duration) + }() + for _, peer := range a.Peers { if peer.Key == peerPubKey { return peer.Copy(), nil @@ -1042,6 +1059,12 @@ func (am *DefaultAccountManager) peerLoginExpirationJob(accountID string) func() } func (am *DefaultAccountManager) checkAndSchedulePeerLoginExpiration(account *Account) { + startTime := time.Now() + defer func() { + duration := time.Since(startTime) + log.Debugf("checkAndSchedulePeerLoginExpiration took %s", duration) + }() + am.peerLoginExpiry.Cancel([]string{account.Id}) if nextRun, ok := account.GetNextPeerExpiration(); ok { go am.peerLoginExpiry.Schedule(nextRun, account.Id, am.peerLoginExpirationJob(account.Id)) diff --git a/management/server/geolocation/geolocation.go b/management/server/geolocation/geolocation.go index 88cdfcb9f..d10bbac37 100644 --- a/management/server/geolocation/geolocation.go +++ b/management/server/geolocation/geolocation.go @@ -106,6 +106,12 @@ func openDB(mmdbPath string) (*maxminddb.Reader, error) { } func (gl *Geolocation) Lookup(ip net.IP) (*Record, error) { + startTime := time.Now() + defer func() { + duration := time.Since(startTime) + log.Debugf("(GeoLocation) Lookup took %s", duration) + }() + gl.mux.RLock() defer gl.mux.RUnlock()