mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-20 09:47:49 +02:00
added logging for blocked peers, removed map size
This commit is contained in:
parent
7890cb4f32
commit
2f73b7a35f
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@ -48,6 +49,8 @@ type GRPCServer struct {
|
||||
ephemeralManager *EphemeralManager
|
||||
peerLocks sync.Map
|
||||
authManager auth.Manager
|
||||
|
||||
logBlockedPeers bool
|
||||
}
|
||||
|
||||
// NewServer creates a new Management server
|
||||
@ -77,6 +80,8 @@ func NewServer(
|
||||
}
|
||||
}
|
||||
|
||||
logBlockedPeers := os.Getenv("NB_LOG_BLOCKED_PEERS") == "true"
|
||||
|
||||
return &GRPCServer{
|
||||
wgKey: key,
|
||||
// peerKey -> event channel
|
||||
@ -88,6 +93,7 @@ func NewServer(
|
||||
authManager: authManager,
|
||||
appMetrics: appMetrics,
|
||||
ephemeralManager: ephemeralManager,
|
||||
logBlockedPeers: logBlockedPeers,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -146,6 +152,9 @@ func (s *GRPCServer) Sync(req *proto.EncryptedMessage, srv proto.ManagementServi
|
||||
if s.appMetrics != nil {
|
||||
s.appMetrics.GRPCMetrics().CountSyncRequestBlocked()
|
||||
}
|
||||
if s.logBlockedPeers {
|
||||
log.WithContext(ctx).Warnf("peer %s with meta hash %d is blocked from syncing", peerKey.String(), metahashed)
|
||||
}
|
||||
return internalStatus.ErrPeerAlreadyLoggedIn
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
loginFilterSize = 100_000 // Size of the login filter map, making it large enough for a future
|
||||
filterTimeout = 5 * time.Minute // Duration to secure the previous login information in the filter
|
||||
|
||||
reconnTreshold = 5 * time.Minute
|
||||
@ -18,7 +17,6 @@ const (
|
||||
)
|
||||
|
||||
type config struct {
|
||||
loginFilterSize int
|
||||
filterTimeout time.Duration
|
||||
reconnTreshold time.Duration
|
||||
blockDuration time.Duration
|
||||
@ -41,7 +39,6 @@ type metahash struct {
|
||||
|
||||
func initCfg() *config {
|
||||
return &config{
|
||||
loginFilterSize: loginFilterSize,
|
||||
filterTimeout: filterTimeout,
|
||||
reconnTreshold: reconnTreshold,
|
||||
blockDuration: blockDuration,
|
||||
@ -55,7 +52,7 @@ func newLoginFilter() *loginFilter {
|
||||
|
||||
func newLoginFilterWithCfg(cfg *config) *loginFilter {
|
||||
return &loginFilter{
|
||||
logged: make(map[string]metahash, cfg.loginFilterSize),
|
||||
logged: make(map[string]metahash),
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
@ -118,5 +115,4 @@ func metaHash(meta nbpeer.PeerSystemMeta, pubip string) uint64 {
|
||||
h.Write([]byte(pubip))
|
||||
|
||||
return h.Sum64()
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user