diff --git a/app/plugins/contactRetry.go b/app/plugins/contactRetry.go index 5bdc510..5379c8c 100644 --- a/app/plugins/contactRetry.go +++ b/app/plugins/contactRetry.go @@ -349,14 +349,17 @@ func (cr *contactRetry) processStatus() { // Loop through connections. Reset state, and requeue... cr.connections.Range(func(k, v interface{}) bool { p := v.(*contact) - p.queued = true - // prioritize connections made recently... - log.Debugf("adding %v to queue", p.id) - if time.Since(p.lastSeen).Hours() < PriorityQueueTimeSinceQualifierHours { - cr.priorityQueue.insert(p) - } else { - cr.pendingQueue.insert(p) + // only reload connections if they are on the authorized peers list + if _, exists := cr.authorizedPeers.Load(p.id); exists { + p.queued = true + // prioritize connections made recently... + log.Debugf("adding %v to queue", p.id) + if time.Since(p.lastSeen).Hours() < PriorityQueueTimeSinceQualifierHours { + cr.priorityQueue.insert(p) + } else { + cr.pendingQueue.insert(p) + } } return true @@ -397,10 +400,14 @@ func (cr *contactRetry) requeueReady() { cr.connections.Range(func(k, v interface{}) bool { p := v.(*contact) - if p.state == connections.DISCONNECTED && !p.queued { - timeout := time.Duration((math.Pow(2, float64(p.failedCount)))*float64(adjustedBaseTimeout /*baseTimeoutSec*/)) * time.Second - if time.Since(p.lastAttempt) > timeout { - retryable = append(retryable, p) + + // Don't retry anyone who isn't on the authorized peers list + if _, exists := cr.authorizedPeers.Load(p.id); exists { + if p.state == connections.DISCONNECTED && !p.queued { + timeout := time.Duration((math.Pow(2, float64(p.failedCount)))*float64(adjustedBaseTimeout /*baseTimeoutSec*/)) * time.Second + if time.Since(p.lastAttempt) > timeout { + retryable = append(retryable, p) + } } } return true diff --git a/testing/autodownload/file_sharing_integration_test.go b/testing/autodownload/file_sharing_integration_test.go index f388c92..7d39bc8 100644 --- a/testing/autodownload/file_sharing_integration_test.go +++ b/testing/autodownload/file_sharing_integration_test.go @@ -114,11 +114,11 @@ func TestFileSharing(t *testing.T) { t.Logf("** Waiting for Alice, Bob...") alice := app2.WaitGetPeer(app, "alice") app.ActivatePeerEngine(alice.GetOnion()) - app.ConfigureConnections(alice.GetOnion(), true, true, true); + app.ConfigureConnections(alice.GetOnion(), true, true, true) bob := app2.WaitGetPeer(app, "bob") app.ActivatePeerEngine(bob.GetOnion()) - app.ConfigureConnections(bob.GetOnion(), true, true, true); - + app.ConfigureConnections(bob.GetOnion(), true, true, true) + alice.AutoHandleEvents([]event.Type{event.PeerStateChange, event.NewRetValMessageFromPeer}) bob.AutoHandleEvents([]event.Type{event.PeerStateChange, event.NewRetValMessageFromPeer}) diff --git a/testing/cwtch_peer_server_integration_test.go b/testing/cwtch_peer_server_integration_test.go index 85f8797..e3d211f 100644 --- a/testing/cwtch_peer_server_integration_test.go +++ b/testing/cwtch_peer_server_integration_test.go @@ -156,7 +156,6 @@ func TestCwtchPeerIntegration(t *testing.T) { settings.Experiments[constants.GroupsExperiment] = true app.UpdateSettings(settings) - log.Infoln("Creating Alice...") app.CreateProfile("Alice", "asdfasdf", true) @@ -169,7 +168,7 @@ func TestCwtchPeerIntegration(t *testing.T) { alice := app2.WaitGetPeer(app, "Alice") aliceBus := app.GetEventBus(alice.GetOnion()) app.ActivatePeerEngine(alice.GetOnion()) - app.ConfigureConnections(alice.GetOnion(), true, true, true); + app.ConfigureConnections(alice.GetOnion(), true, true, true) log.Infoln("Alice created:", alice.GetOnion()) // alice.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name, "Alice") <- This is now done automatically by ProfileValueExtension, keeping this here for clarity alice.AutoHandleEvents([]event.Type{event.PeerStateChange, event.ServerStateChange, event.NewGroupInvite, event.NewRetValMessageFromPeer}) @@ -177,7 +176,7 @@ func TestCwtchPeerIntegration(t *testing.T) { bob := app2.WaitGetPeer(app, "Bob") bobBus := app.GetEventBus(bob.GetOnion()) app.ActivatePeerEngine(bob.GetOnion()) - app.ConfigureConnections(bob.GetOnion(), true, true, true); + app.ConfigureConnections(bob.GetOnion(), true, true, true) log.Infoln("Bob created:", bob.GetOnion()) // bob.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name, "Bob") <- This is now done automatically by ProfileValueExtension, keeping this here for clarity bob.AutoHandleEvents([]event.Type{event.PeerStateChange, event.ServerStateChange, event.NewGroupInvite, event.NewRetValMessageFromPeer}) @@ -185,7 +184,7 @@ func TestCwtchPeerIntegration(t *testing.T) { carol := app2.WaitGetPeer(app, "Carol") carolBus := app.GetEventBus(carol.GetOnion()) app.ActivatePeerEngine(carol.GetOnion()) - app.ConfigureConnections(carol.GetOnion(), true, true, true); + app.ConfigureConnections(carol.GetOnion(), true, true, true) log.Infoln("Carol created:", carol.GetOnion()) // carol.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name, "Carol") <- This is now done automatically by ProfileValueExtension, keeping this here for clarity carol.AutoHandleEvents([]event.Type{event.PeerStateChange, event.ServerStateChange, event.NewGroupInvite, event.NewRetValMessageFromPeer}) diff --git a/testing/filesharing/file_sharing_integration_test.go b/testing/filesharing/file_sharing_integration_test.go index 5ce7e4d..a6f2eb0 100644 --- a/testing/filesharing/file_sharing_integration_test.go +++ b/testing/filesharing/file_sharing_integration_test.go @@ -116,10 +116,10 @@ func TestFileSharing(t *testing.T) { t.Logf("** Waiting for Alice, Bob...") alice := app2.WaitGetPeer(app, "alice") app.ActivatePeerEngine(alice.GetOnion()) - app.ConfigureConnections(alice.GetOnion(), true, true, true); + app.ConfigureConnections(alice.GetOnion(), true, true, true) bob := app2.WaitGetPeer(app, "bob") app.ActivatePeerEngine(bob.GetOnion()) - app.ConfigureConnections(bob.GetOnion(), true, true, true); + app.ConfigureConnections(bob.GetOnion(), true, true, true) alice.AutoHandleEvents([]event.Type{event.PeerStateChange, event.NewRetValMessageFromPeer}) bob.AutoHandleEvents([]event.Type{event.PeerStateChange, event.NewRetValMessageFromPeer})