mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
server: Check max peers before connecting
This commit is contained in:
parent
ea0238ec44
commit
56da31dec5
@ -1438,6 +1438,11 @@ func (s *server) handleQuery(state *peerState, querymsg interface{}) {
|
||||
|
||||
case connectNodeMsg:
|
||||
// XXX(oga) duplicate oneshots?
|
||||
// Limit max number of total peers.
|
||||
if state.Count() >= cfg.MaxPeers {
|
||||
msg.reply <- errors.New("max peers reached")
|
||||
return
|
||||
}
|
||||
for _, peer := range state.persistentPeers {
|
||||
if peer.Addr() == msg.addr {
|
||||
if msg.permanent {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user