From 63e94a38a233a16102250ba07fbba5a5c31ee0dd Mon Sep 17 00:00:00 2001 From: shubhamrasal Date: Thu, 25 May 2023 13:28:09 +0530 Subject: [PATCH] Implement Close method for session --- v2/pkg/passive/passive.go | 1 + v2/pkg/subscraping/agent.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/v2/pkg/passive/passive.go b/v2/pkg/passive/passive.go index fe41971fb..826228146 100644 --- a/v2/pkg/passive/passive.go +++ b/v2/pkg/passive/passive.go @@ -28,6 +28,7 @@ func (a *Agent) EnumerateSubdomainsWithCtx(ctx context.Context, domain string, p } return } + defer session.Close() ctx, cancel := context.WithTimeout(ctx, maxEnumTime) diff --git a/v2/pkg/subscraping/agent.go b/v2/pkg/subscraping/agent.go index 5b985c87a..dd4e3f0c8 100644 --- a/v2/pkg/subscraping/agent.go +++ b/v2/pkg/subscraping/agent.go @@ -123,6 +123,12 @@ func (s *Session) DiscardHTTPResponse(response *http.Response) { } } +// Close the session +func (s *Session) Close() { + s.RateLimiter.Stop() + s.Client.CloseIdleConnections() +} + func httpRequestWrapper(client *http.Client, request *http.Request) (*http.Response, error) { response, err := client.Do(request) if err != nil {