OSDN Git Service
(root)
/
bytom
/
bytom.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c4b5e1d
)
Del expired banned peers when add peer
security
author
Yahtoo Ma
<yahtoo.ma@gmail.com>
Mon, 5 Aug 2019 02:10:24 +0000
(10:10 +0800)
committer
Yahtoo Ma
<yahtoo.ma@gmail.com>
Mon, 5 Aug 2019 02:10:24 +0000
(10:10 +0800)
p2p/security/blacklist.go
patch
|
blob
|
history
diff --git
a/p2p/security/blacklist.go
b/p2p/security/blacklist.go
index
8f5682a
..
951d659
100644
(file)
--- a/
p2p/security/blacklist.go
+++ b/
p2p/security/blacklist.go
@@
-38,6
+38,13
@@
func (bl *Blacklist) AddPeer(ip string) error {
bl.mtx.Lock()
defer bl.mtx.Unlock()
+ // delete expired banned peers
+ for peer, banEnd := range bl.peers {
+ if time.Now().Before(banEnd) {
+ delete(bl.peers, peer)
+ }
+ }
+ // add banned peer
bl.peers[ip] = time.Now().Add(defaultBanDuration)
dataJSON, err := json.Marshal(bl.peers)
if err != nil {