mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-10-30 01:26:32 +00:00
temp ban count and exceed add to permaban list is working
This commit is contained in:
parent
2bf7b3d2f8
commit
784b22ccf4
@ -115,7 +115,6 @@ func AddToTemporaryBlacklist(pubkey string) error {
|
|||||||
tempBannedPubkeys[pubkey] = entry
|
tempBannedPubkeys[pubkey] = entry
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Updating existing temporary ban entry for pubkey %s. Current count: %d", pubkey, entry.count)
|
log.Printf("Updating existing temporary ban entry for pubkey %s. Current count: %d", pubkey, entry.count)
|
||||||
// If the ban has expired, we don't reset the count, just update the unban time
|
|
||||||
if time.Now().After(entry.unbanTime) {
|
if time.Now().After(entry.unbanTime) {
|
||||||
log.Printf("Previous ban for pubkey %s has expired. Keeping count at %d", pubkey, entry.count)
|
log.Printf("Previous ban for pubkey %s has expired. Keeping count at %d", pubkey, entry.count)
|
||||||
}
|
}
|
||||||
@ -130,7 +129,12 @@ func AddToTemporaryBlacklist(pubkey string) error {
|
|||||||
if entry.count > cfg.MaxTempBans {
|
if entry.count > cfg.MaxTempBans {
|
||||||
log.Printf("Attempting to move pubkey %s to permanent blacklist", pubkey)
|
log.Printf("Attempting to move pubkey %s to permanent blacklist", pubkey)
|
||||||
delete(tempBannedPubkeys, pubkey)
|
delete(tempBannedPubkeys, pubkey)
|
||||||
|
|
||||||
|
// Release the lock before calling AddToPermanentBlacklist
|
||||||
|
mu.Unlock()
|
||||||
err := AddToPermanentBlacklist(pubkey)
|
err := AddToPermanentBlacklist(pubkey)
|
||||||
|
mu.Lock() // Re-acquire the lock
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error adding pubkey %s to permanent blacklist: %v", pubkey, err)
|
log.Printf("Error adding pubkey %s to permanent blacklist: %v", pubkey, err)
|
||||||
return err
|
return err
|
||||||
@ -172,9 +176,7 @@ func isPubKeyPermanentlyBlacklisted(pubKey string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func AddToPermanentBlacklist(pubkey string) error {
|
func AddToPermanentBlacklist(pubkey string) error {
|
||||||
mu.Lock()
|
// Remove the mutex lock from here
|
||||||
defer mu.Unlock()
|
|
||||||
|
|
||||||
cfg := config.GetConfig().Blacklist
|
cfg := config.GetConfig().Blacklist
|
||||||
|
|
||||||
// Check if already blacklisted
|
// Check if already blacklisted
|
||||||
|
Loading…
Reference in New Issue
Block a user