Merge remote-tracking branch 'origin/test/add-stopwatch' into test/add-stopwatch

This commit is contained in:
Pascal Fischer
2024-04-30 11:29:08 +02:00
4 changed files with 5 additions and 39 deletions

View File

@@ -11,6 +11,7 @@ import (
"net/netip"
"reflect"
"regexp"
"runtime/debug"
"strings"
"sync"
"time"
@@ -388,6 +389,8 @@ func (a *Account) GetGroup(groupID string) *nbgroup.Group {
// GetPeerNetworkMap returns a group by ID if exists, nil otherwise
func (a *Account) GetPeerNetworkMap(peerID, dnsDomain string, validatedPeersMap map[string]struct{}) *NetworkMap {
log.Debugf("GetNetworkMap with trace: %s", string(debug.Stack()))
peer := a.Peers[peerID]
if peer == nil {
return &NetworkMap{

View File

@@ -3,6 +3,7 @@ package server
import (
"fmt"
"net"
"runtime/debug"
"strings"
"time"
@@ -289,6 +290,7 @@ func (am *DefaultAccountManager) DeletePeer(accountID, peerID, userID string) er
// GetNetworkMap returns Network map for a given peer (omits original peer from the Peers result)
func (am *DefaultAccountManager) GetNetworkMap(peerID string) (*NetworkMap, error) {
log.Debugf("GetNetworkMap with trace: %s", string(debug.Stack()))
account, err := am.Store.GetAccountByPeerID(peerID)
if err != nil {
return nil, err
@@ -541,12 +543,6 @@ func (am *DefaultAccountManager) SyncPeer(sync PeerSync, account *Account) (*nbp
// LoginPeer logs in or registers a peer.
// If peer doesn't exist the function checks whether a setup key or a user is present and registers a new peer if so.
func (am *DefaultAccountManager) LoginPeer(login PeerLogin) (*nbpeer.Peer, *NetworkMap, error) {
startTime := time.Now()
defer func() {
duration := time.Since(startTime)
log.Debugf("LoginPeer took %s", duration)
}()
account, err := am.Store.GetAccountByPeerPubKey(login.WireGuardPubKey)
if err != nil {
if errStatus, ok := status.FromError(err); ok && errStatus.Type() == status.NotFound {

View File

@@ -5,8 +5,6 @@ import (
"net"
"net/netip"
"time"
log "github.com/sirupsen/logrus"
)
// Peer represents a machine connected to the network.
@@ -175,8 +173,6 @@ func (p *Peer) UpdateMetaIfNew(meta PeerSystemMeta) bool {
meta.UIVersion = p.Meta.UIVersion
}
log.Infof("Check if meta is equal: %v", p.Meta.isEqual(meta))
if p.Meta.isEqual(meta) {
return false
}

View File

@@ -479,12 +479,6 @@ func (s *SqliteStore) GetAccount(accountID string) (*Account, error) {
}
func (s *SqliteStore) GetAccountByUser(userID string) (*Account, error) {
startTime := time.Now()
defer func() {
duration := time.Since(startTime)
log.Debugf("GetAccountByUser took %s", duration)
}()
var user User
result := s.db.Select("account_id").First(&user, "id = ?", userID)
if result.Error != nil {
@@ -503,11 +497,6 @@ func (s *SqliteStore) GetAccountByUser(userID string) (*Account, error) {
}
func (s *SqliteStore) GetAccountByPeerID(peerID string) (*Account, error) {
startTime := time.Now()
defer func() {
duration := time.Since(startTime)
log.Debugf("GetAccountByPeerID took %s", duration)
}()
var peer nbpeer.Peer
result := s.db.Select("account_id").First(&peer, "id = ?", peerID)
if result.Error != nil {
@@ -526,12 +515,6 @@ func (s *SqliteStore) GetAccountByPeerID(peerID string) (*Account, error) {
}
func (s *SqliteStore) GetAccountByPeerPubKey(peerKey string) (*Account, error) {
startTime := time.Now()
defer func() {
duration := time.Since(startTime)
log.Debugf("GetAccountByPubKey took %s", duration)
}()
var peer nbpeer.Peer
result := s.db.Select("account_id").First(&peer, "key = ?", peerKey)
@@ -551,12 +534,6 @@ func (s *SqliteStore) GetAccountByPeerPubKey(peerKey string) (*Account, error) {
}
func (s *SqliteStore) GetAccountIDByPeerPubKey(peerKey string) (string, error) {
startTime := time.Now()
defer func() {
duration := time.Since(startTime)
log.Debugf("GetAccountByPubKey took %s", duration)
}()
var peer nbpeer.Peer
var accountID string
result := s.db.Model(&peer).Select("account_id").Where("key = ?", peerKey).First(&accountID)
@@ -573,12 +550,6 @@ func (s *SqliteStore) GetAccountIDByPeerPubKey(peerKey string) (string, error) {
// SaveUserLastLogin stores the last login time for a user in DB.
func (s *SqliteStore) SaveUserLastLogin(accountID, userID string, lastLogin time.Time) error {
startTime := time.Now()
defer func() {
duration := time.Since(startTime)
log.Debugf("SaveUserLastLogin took %s", duration)
}()
var user User
result := s.db.First(&user, "account_id = ? and id = ?", accountID, userID)