Restrict Active Connections to Those Found in the Last Week
This commit is contained in:
parent
7de9c21f7b
commit
bfe8b1e51f
|
@ -177,11 +177,17 @@ func (cr *contactRetry) run() {
|
|||
connectingCount := cr.connectingCount()
|
||||
log.Debugf("checking queue (len: %v) of total conns watched: %v, with current connecingCount: %v", len(cr.pendingQueue.queue), cr.connCount, connectingCount)
|
||||
for connectingCount < cr.maxTorCircuitsPending() && len(cr.pendingQueue.queue) > 0 {
|
||||
contact := cr.pendingQueue.dequeue()
|
||||
// could have received incoming connection while in queue, make sure still disconnected before trying
|
||||
if contact.state == connections.DISCONNECTED {
|
||||
cr.publishConnectionRequest(contact)
|
||||
connectingCount++
|
||||
for {
|
||||
contact := cr.pendingQueue.dequeue()
|
||||
if contact == nil {
|
||||
break
|
||||
}
|
||||
// could have received incoming connection while in queue, make sure still disconnected before trying
|
||||
if contact.state == connections.DISCONNECTED {
|
||||
cr.publishConnectionRequest(contact)
|
||||
connectingCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
cr.lastCheck = time.Now()
|
||||
|
@ -304,6 +310,11 @@ func (cr *contactRetry) addConnection(id string, state connections.ConnectionSta
|
|||
return
|
||||
}
|
||||
|
||||
// if it's been more than a week then don't add
|
||||
if time.Now().Sub(lastSeen).Hours() > 168 {
|
||||
return
|
||||
}
|
||||
|
||||
if _, exists := cr.connections.Load(id); !exists {
|
||||
p := &contact{id: id, state: state, failedCount: 0, lastAttempt: event.CwtchEpoch, ctype: ctype, lastSeen: lastSeen, queued: false}
|
||||
cr.connections.Store(id, p)
|
||||
|
|
Loading…
Reference in New Issue