diff --git a/management/server/loginfilter.go b/management/server/loginfilter.go index b8ac99010..da7656c09 100644 --- a/management/server/loginfilter.go +++ b/management/server/loginfilter.go @@ -11,14 +11,14 @@ import ( const ( filterTimeout = 5 * time.Minute // Duration to secure the previous login information in the filter - reconnTreshold = 5 * time.Minute + reconnThreshold = 5 * time.Minute blockDuration = 10 * 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 ) type config struct { filterTimeout time.Duration - reconnTreshold time.Duration + reconnThreshold time.Duration blockDuration time.Duration reconnLimitForBan int } @@ -40,7 +40,7 @@ type metahash struct { func initCfg() *config { return &config{ filterTimeout: filterTimeout, - reconnTreshold: reconnTreshold, + reconnThreshold: reconnThreshold, blockDuration: blockDuration, reconnLimitForBan: reconnLimitForBan, } @@ -70,7 +70,7 @@ func (l *loginFilter) addLogin(wgPubKey string, metaHash uint64) { mh.counter++ mh.hash = metaHash mh.lastSeen = time.Now() - if mh.counter > l.cfg.reconnLimitForBan && mh.lastSeen.Sub(mh.firstLogin) < l.cfg.reconnTreshold { + if mh.counter > l.cfg.reconnLimitForBan && mh.lastSeen.Sub(mh.firstLogin) < l.cfg.reconnThreshold { mh.banned = true } l.logged[wgPubKey] = mh diff --git a/management/server/loginfilter_test.go b/management/server/loginfilter_test.go index a3a95c50b..21a2673aa 100644 --- a/management/server/loginfilter_test.go +++ b/management/server/loginfilter_test.go @@ -15,7 +15,7 @@ import ( func testCfg() *config { return &config{ filterTimeout: 20 * time.Millisecond, - reconnTreshold: 50 * time.Millisecond, + reconnThreshold: 50 * time.Millisecond, blockDuration: 100 * time.Millisecond, reconnLimitForBan: 3, } diff --git a/management/server/mock_server/account_mock.go b/management/server/mock_server/account_mock.go index e6b4a9899..2ce14b0a0 100644 --- a/management/server/mock_server/account_mock.go +++ b/management/server/mock_server/account_mock.go @@ -893,6 +893,9 @@ func (am *MockAccountManager) GetCurrentUserInfo(ctx context.Context, userAuth n return nil, status.Errorf(codes.Unimplemented, "method GetCurrentUserInfo is not implemented") } -func (am *MockAccountManager) AllowSync(_ string, _ uint64) bool { +func (am *MockAccountManager) AllowSync(key string, hash uint64) bool { + if am.AllowSyncFunc != nil { + return am.AllowSyncFunc(key, hash) + } return true }