Change result count & history
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -51,29 +51,13 @@ func routes(s *server.Server, cache *map[string]*search.Result, searchQueue chan
|
||||
})
|
||||
|
||||
s.Router.GET("/history", func(c *gin.Context) {
|
||||
type historyItem struct {
|
||||
Id string
|
||||
Status string
|
||||
Date time.Time
|
||||
Query search.Query
|
||||
Results int
|
||||
}
|
||||
var history []historyItem
|
||||
var history []search.Result
|
||||
s.Mu.RLock()
|
||||
for _, r := range *cache {
|
||||
resultsCount := 0
|
||||
if r.LeakResult.Rows != nil {
|
||||
resultsCount = len(r.LeakResult.Rows)
|
||||
}
|
||||
history = append(history, historyItem{
|
||||
Id: r.Id,
|
||||
Status: r.Status,
|
||||
Date: r.Date,
|
||||
Query: r.Query,
|
||||
Results: resultsCount,
|
||||
})
|
||||
history = append(history, *r)
|
||||
}
|
||||
s.Mu.RUnlock()
|
||||
// Sort by date (newest first)
|
||||
for i := 0; i < len(history)-1; i++ {
|
||||
for j := 0; j < len(history)-i-1; j++ {
|
||||
if history[j].Date.Before(history[j+1].Date) {
|
||||
|
||||
@@ -25,10 +25,11 @@ type Query struct {
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
Id string
|
||||
Date time.Time
|
||||
Status string // "queued", "pending", "completed"
|
||||
Query Query
|
||||
Id string
|
||||
Date time.Time
|
||||
Status string // "queued", "pending", "completed", "error"
|
||||
Query Query
|
||||
ResultsCount int // Total number of results found across all services
|
||||
|
||||
LeakResult dataleak.LeakResult
|
||||
GithubResult osint.GithubResult
|
||||
@@ -40,6 +41,7 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
|
||||
|
||||
mu.Lock()
|
||||
r.Status = "pending"
|
||||
r.ResultsCount = 0
|
||||
mu.Unlock()
|
||||
|
||||
wg.Add(3)
|
||||
@@ -54,6 +56,7 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
|
||||
leakResult := dataleak.Search(s, q.Text, q.Column, q.ExactMatch)
|
||||
mu.Lock()
|
||||
r.LeakResult = leakResult
|
||||
r.ResultsCount += len(leakResult.Rows)
|
||||
mu.Unlock()
|
||||
wg.Done()
|
||||
}()
|
||||
@@ -89,6 +92,15 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
|
||||
}
|
||||
mu.Lock()
|
||||
r.GithubResult = githubResult
|
||||
if githubResult.EmailResult != nil && githubResult.EmailResult.Commits != nil {
|
||||
r.ResultsCount += len(githubResult.EmailResult.Commits)
|
||||
}
|
||||
if githubResult.EmailResult != nil && githubResult.EmailResult.Spoofing != nil && githubResult.EmailResult.Spoofing.Username != "" {
|
||||
r.ResultsCount += 1
|
||||
}
|
||||
if githubResult.UsernameResult != nil && githubResult.UsernameResult.Commits != nil {
|
||||
r.ResultsCount += len(githubResult.UsernameResult.Commits)
|
||||
}
|
||||
mu.Unlock()
|
||||
wg.Done()
|
||||
}()
|
||||
@@ -104,6 +116,9 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
|
||||
gravatarResult := osint.GravatarSearch(s, cleanQueryText)
|
||||
mu.Lock()
|
||||
r.GravatarResult = gravatarResult
|
||||
if gravatarResult.Results != nil {
|
||||
r.ResultsCount += len(gravatarResult.Results)
|
||||
}
|
||||
mu.Unlock()
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user