mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-25 22:09:08 +01:00
less strict metaHash when blocking peers
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
reconnThreshold = 5 * time.Minute
|
reconnThreshold = 5 * time.Minute
|
||||||
baseBlockDuration = 10 * time.Minute // Duration for which a peer is banned after exceeding the reconnection limit
|
baseBlockDuration = 30 * time.Minute // Duration for which a peer is banned after exceeding the reconnection limit
|
||||||
reconnLimitForBan = 30 // Number of reconnections within the reconnTreshold that triggers a ban
|
reconnLimitForBan = 30 // Number of reconnections within the reconnTreshold that triggers a ban
|
||||||
metaChangeLimit = 3 // Number of reconnections with different metadata that triggers a ban of one peer
|
metaChangeLimit = 3 // Number of reconnections with different metadata that triggers a ban of one peer
|
||||||
)
|
)
|
||||||
@@ -139,22 +139,13 @@ func (l *loginFilter) addLogin(wgPubKey string, metaHash uint64) {
|
|||||||
state.lastSeen = now
|
state.lastSeen = now
|
||||||
}
|
}
|
||||||
|
|
||||||
func metaHash(meta nbpeer.PeerSystemMeta, pubip string) uint64 {
|
func metaHash(meta nbpeer.PeerSystemMeta) uint64 {
|
||||||
h := fnv.New64a()
|
h := fnv.New64a()
|
||||||
|
|
||||||
h.Write([]byte(meta.WtVersion))
|
|
||||||
h.Write([]byte(meta.OSVersion))
|
h.Write([]byte(meta.OSVersion))
|
||||||
h.Write([]byte(meta.KernelVersion))
|
h.Write([]byte(meta.KernelVersion))
|
||||||
h.Write([]byte(meta.Hostname))
|
h.Write([]byte(meta.Hostname))
|
||||||
h.Write([]byte(meta.SystemSerialNumber))
|
h.Write([]byte(meta.SystemSerialNumber))
|
||||||
h.Write([]byte(pubip))
|
|
||||||
|
|
||||||
macs := uint64(0)
|
return h.Sum64()
|
||||||
for _, na := range meta.NetworkAddresses {
|
|
||||||
for _, r := range na.Mac {
|
|
||||||
macs += uint64(r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return h.Sum64() + macs
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user