Skip to content

Commit

Permalink
Merge pull request #75 from projectdiscovery/bump_versions
Browse files Browse the repository at this point in the history
Bump versions + limit instance to one port
  • Loading branch information
Mzack9999 authored Sep 2, 2024
2 parents e7394e0 + 16e8096 commit e952db6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.21

- name: Check out code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.21
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v4.0.0
with:
Expand Down
31 changes: 18 additions & 13 deletions clistats.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ func (s *Statistics) metricsHandler(w http.ResponseWriter, req *http.Request) {

// Start starts the event loop of the stats client.
func (s *Statistics) Start() error {
if s.httpServer != nil {
return errorutil.New("server already started")
}

if s.Options.Web {
mux := http.NewServeMux()
mux.HandleFunc("/metrics", s.metricsHandler)
Expand Down Expand Up @@ -209,6 +213,20 @@ func (s *Statistics) Start() error {
return nil
}

// Stop stops the event loop of the stats client
func (s *Statistics) Stop() error {
defer s.cancel()

if s.httpServer != nil {
if err := s.httpServer.Shutdown(s.ctx); err != nil {
return err
}
}
s.httpServer = nil

return nil
}

// GetStatResponse returns '/metrics' response for a given interval
func (s *Statistics) GetStatResponse(interval time.Duration, callback func(string, error) error) {
metricCallback := func(url string) (string, error) {
Expand Down Expand Up @@ -242,16 +260,3 @@ func (s *Statistics) GetStatResponse(interval time.Duration, callback func(strin
}
}()
}

// Stop stops the event loop of the stats client
func (s *Statistics) Stop() error {
defer s.cancel()

if s.httpServer != nil {
if err := s.httpServer.Shutdown(s.ctx); err != nil {
return err
}
}

return nil
}
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module github.com/projectdiscovery/clistats

go 1.19
go 1.21



require (
github.com/json-iterator/go v1.1.12
github.com/projectdiscovery/freeport v0.0.5
github.com/projectdiscovery/freeport v0.0.6
github.com/projectdiscovery/utils v0.0.80
github.com/stretchr/testify v1.8.4
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/projectdiscovery/freeport v0.0.5 h1:jnd3Oqsl4S8n0KuFkE5Hm8WGDP24ITBvmyw5pFTHS8Q=
github.com/projectdiscovery/freeport v0.0.5/go.mod h1:PY0bxSJ34HVy67LHIeF3uIutiCSDwOqKD8ruBkdiCwE=
github.com/projectdiscovery/freeport v0.0.6 h1:ROqzuXN8JPqkGdBueb3ah691nS2g2p7r3/3x2E33GbI=
github.com/projectdiscovery/freeport v0.0.6/go.mod h1:T2kIy+WrbyxBIhI8V3Y9aeNGnuhnM8tEUSK/cm9GjAg=
github.com/projectdiscovery/utils v0.0.80 h1:daFuQwhVRtQ14JZs3DnI9ubaX273S8V1dZ+x/vr+YbI=
github.com/projectdiscovery/utils v0.0.80/go.mod h1:WXm3MIzKhgqUtTMwxDIW5bWe5nWkCYqRlZeqin0FqTc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down

0 comments on commit e952db6

Please sign in to comment.