server: Check max peers before connecting
This commit is contained in:
parent
d8a6de461f
commit
b320129e9b
1 changed files with 5 additions and 0 deletions
|
@ -1437,6 +1437,11 @@ func (s *server) handleQuery(state *peerState, querymsg interface{}) {
|
||||||
|
|
||||||
case connectNodeMsg:
|
case connectNodeMsg:
|
||||||
// XXX(oga) duplicate oneshots?
|
// 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 {
|
for _, peer := range state.persistentPeers {
|
||||||
if peer.Addr() == msg.addr {
|
if peer.Addr() == msg.addr {
|
||||||
if msg.permanent {
|
if msg.permanent {
|
||||||
|
|
Loading…
Reference in a new issue