mirror of
https://github.com/projectdiscovery/subfinder
synced 2026-06-21 14:05:24 +00:00
e96320ec38
Adds request counting to all sources to help users monitor API usage and debug quota consumption issues like #1562. Changes: - Add Requests field to Statistics struct - Track HTTP requests in all 53 sources - Display request count in stats output Closes #1698
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package runner
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/projectdiscovery/gologger"
|
|
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping"
|
|
"golang.org/x/exp/maps"
|
|
)
|
|
|
|
func printStatistics(stats map[string]subscraping.Statistics) {
|
|
|
|
sources := maps.Keys(stats)
|
|
sort.Strings(sources)
|
|
|
|
var lines []string
|
|
var skipped []string
|
|
|
|
for _, source := range sources {
|
|
sourceStats := stats[source]
|
|
if sourceStats.Skipped {
|
|
skipped = append(skipped, fmt.Sprintf(" %s", source))
|
|
} else {
|
|
lines = append(lines, fmt.Sprintf(" %-20s %-10s %10d %10d %10d", source, sourceStats.TimeTaken.Round(time.Millisecond).String(), sourceStats.Results, sourceStats.Requests, sourceStats.Errors))
|
|
}
|
|
}
|
|
|
|
if len(lines) > 0 {
|
|
gologger.Print().Msgf("\n Source Duration Results Requests Errors\n%s\n", strings.Repeat("─", 68))
|
|
gologger.Print().Msg(strings.Join(lines, "\n"))
|
|
gologger.Print().Msgf("\n")
|
|
}
|
|
|
|
if len(skipped) > 0 {
|
|
gologger.Print().Msgf("\n The following sources were included but skipped...\n\n")
|
|
gologger.Print().Msg(strings.Join(skipped, "\n"))
|
|
gologger.Print().Msgf("\n\n")
|
|
}
|
|
}
|
|
|
|
func (r *Runner) GetStatistics() map[string]subscraping.Statistics {
|
|
return r.passiveAgent.GetStatistics()
|
|
}
|