From 3232473aaf0bae9302a2a776746a7dfc106d0f04 Mon Sep 17 00:00:00 2001 From: Brian Olson Date: Thu, 9 Jan 2025 10:19:51 -0500 Subject: [PATCH] disconnect a pds when we block it --- bgs/admin.go | 3 +++ bgs/fedmgr.go | 1 + 2 files changed, 4 insertions(+) diff --git a/bgs/admin.go b/bgs/admin.go index 44b07cd8f..1d415d66a 100644 --- a/bgs/admin.go +++ b/bgs/admin.go @@ -264,6 +264,9 @@ func (bgs *BGS) handleBlockPDS(e echo.Context) error { return err } + // don't care if this errors, but we should try to disconnect something we just blocked + _ = bgs.slurper.KillUpstreamConnection(host, false) + return e.JSON(200, map[string]any{ "success": "true", }) diff --git a/bgs/fedmgr.go b/bgs/fedmgr.go index c68759d91..10212f0a4 100644 --- a/bgs/fedmgr.go +++ b/bgs/fedmgr.go @@ -745,6 +745,7 @@ func (s *Slurper) KillUpstreamConnection(host string, block bool) error { return fmt.Errorf("killing connection %q: %w", host, ErrNoActiveConnection) } ac.cancel() + // cleanup in the run thread subscribeWithRedialer() will delete(s.active, host) if block { if err := s.db.Model(models.PDS{}).Where("id = ?", ac.pds.ID).UpdateColumn("blocked", true).Error; err != nil {