From 0a25894cba1ea1036ba356f4647a8a4b1a55bf95 Mon Sep 17 00:00:00 2001 From: Shubham Rasal Date: Sat, 27 May 2023 22:34:15 +0530 Subject: [PATCH] Implement Close method for session (#846) --- 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 {