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) {
|
s.Router.GET("/history", func(c *gin.Context) {
|
||||||
type historyItem struct {
|
var history []search.Result
|
||||||
Id string
|
|
||||||
Status string
|
|
||||||
Date time.Time
|
|
||||||
Query search.Query
|
|
||||||
Results int
|
|
||||||
}
|
|
||||||
var history []historyItem
|
|
||||||
s.Mu.RLock()
|
s.Mu.RLock()
|
||||||
for _, r := range *cache {
|
for _, r := range *cache {
|
||||||
resultsCount := 0
|
history = append(history, *r)
|
||||||
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,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
s.Mu.RUnlock()
|
s.Mu.RUnlock()
|
||||||
|
// Sort by date (newest first)
|
||||||
for i := 0; i < len(history)-1; i++ {
|
for i := 0; i < len(history)-1; i++ {
|
||||||
for j := 0; j < len(history)-i-1; j++ {
|
for j := 0; j < len(history)-i-1; j++ {
|
||||||
if history[j].Date.Before(history[j+1].Date) {
|
if history[j].Date.Before(history[j+1].Date) {
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ type Query struct {
|
|||||||
type Result struct {
|
type Result struct {
|
||||||
Id string
|
Id string
|
||||||
Date time.Time
|
Date time.Time
|
||||||
Status string // "queued", "pending", "completed"
|
Status string // "queued", "pending", "completed", "error"
|
||||||
Query Query
|
Query Query
|
||||||
|
ResultsCount int // Total number of results found across all services
|
||||||
|
|
||||||
LeakResult dataleak.LeakResult
|
LeakResult dataleak.LeakResult
|
||||||
GithubResult osint.GithubResult
|
GithubResult osint.GithubResult
|
||||||
@@ -40,6 +41,7 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
|
|||||||
|
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
r.Status = "pending"
|
r.Status = "pending"
|
||||||
|
r.ResultsCount = 0
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
|
|
||||||
wg.Add(3)
|
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)
|
leakResult := dataleak.Search(s, q.Text, q.Column, q.ExactMatch)
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
r.LeakResult = leakResult
|
r.LeakResult = leakResult
|
||||||
|
r.ResultsCount += len(leakResult.Rows)
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
@@ -89,6 +92,15 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
|
|||||||
}
|
}
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
r.GithubResult = githubResult
|
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()
|
mu.Unlock()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
@@ -104,6 +116,9 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
|
|||||||
gravatarResult := osint.GravatarSearch(s, cleanQueryText)
|
gravatarResult := osint.GravatarSearch(s, cleanQueryText)
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
r.GravatarResult = gravatarResult
|
r.GravatarResult = gravatarResult
|
||||||
|
if gravatarResult.Results != nil {
|
||||||
|
r.ResultsCount += len(gravatarResult.Results)
|
||||||
|
}
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -82,13 +82,14 @@
|
|||||||
{item.Query.Text}
|
{item.Query.Text}
|
||||||
</button>
|
</button>
|
||||||
</th>
|
</th>
|
||||||
<td>{item.Results}</td>
|
<td>{item.ResultsCount}</td>
|
||||||
<td
|
<td
|
||||||
><div
|
><div
|
||||||
class="badge badge-xs"
|
class="badge badge-xs"
|
||||||
class:badge-success={item.Status === "completed"}
|
class:badge-success={item.Status === "completed"}
|
||||||
class:badge-warning={item.Status === "pending"}
|
class:badge-warning={item.Status === "pending"}
|
||||||
class:badge-neutral={item.Status === "queued"}
|
class:badge-neutral={item.Status === "queued"}
|
||||||
|
class:badge-error={item.Status === "error"}
|
||||||
>
|
>
|
||||||
{item.Status}
|
{item.Status}
|
||||||
</div></td
|
</div></td
|
||||||
|
|||||||
@@ -4,18 +4,6 @@
|
|||||||
import { BadgeInfo, Clock, File } from "@lucide/svelte";
|
import { BadgeInfo, Clock, File } from "@lucide/svelte";
|
||||||
|
|
||||||
const { result }: { result: Result } = $props();
|
const { result }: { result: Result } = $props();
|
||||||
|
|
||||||
let nresult = $state(0);
|
|
||||||
$effect(() => {
|
|
||||||
const r = [
|
|
||||||
result.LeakResult.Rows?.length | 0,
|
|
||||||
result.GithubResult.EmailResult?.Commits?.length | 0,
|
|
||||||
result.GithubResult.EmailResult?.Spoofing ? 1 : 0,
|
|
||||||
result.GithubResult.UsernameResult?.Commits?.length | 0,
|
|
||||||
result.GravatarResult.Results?.length | 0,
|
|
||||||
];
|
|
||||||
nresult = r.reduce((a, b) => a + b, 0);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="stats stats-vertical md:stats-horizontal">
|
<div class="stats stats-vertical md:stats-horizontal">
|
||||||
@@ -25,7 +13,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="stat-title">Results</div>
|
<div class="stat-title">Results</div>
|
||||||
<div class="stat-value" class:animate-pulse={result.Status === "pending"}>
|
<div class="stat-value" class:animate-pulse={result.Status === "pending"}>
|
||||||
{nresult.toLocaleString("fr")}
|
{result.ResultsCount.toLocaleString("fr")}
|
||||||
{#if result.Status === "pending"}
|
{#if result.Status === "pending"}
|
||||||
<span class="loading loading-dots loading-xs ml-2"></span>
|
<span class="loading loading-dots loading-xs ml-2"></span>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -49,9 +37,9 @@
|
|||||||
{#if result.Status === "pending"}
|
{#if result.Status === "pending"}
|
||||||
Pending
|
Pending
|
||||||
<span class="loading loading-dots loading-xs ml-2"></span>
|
<span class="loading loading-dots loading-xs ml-2"></span>
|
||||||
{:else if result.Status === "completed" && nresult === 0}
|
{:else if result.Status === "completed" && result.ResultsCount === 0}
|
||||||
No results
|
No results
|
||||||
{:else if result.Status === "completed" && nresult > 0}
|
{:else if result.Status === "completed"}
|
||||||
Completed
|
Completed
|
||||||
{:else}
|
{:else}
|
||||||
{result.Status}
|
{result.Status}
|
||||||
|
|||||||
@@ -36,23 +36,17 @@ export type GravatarResult = {
|
|||||||
|
|
||||||
export type Result = {
|
export type Result = {
|
||||||
Id: string;
|
Id: string;
|
||||||
Status: "queued" | "pending" | "completed";
|
Status: "queued" | "pending" | "completed" | "error";
|
||||||
Date: string;
|
Date: string;
|
||||||
Query: Query;
|
Query: Query;
|
||||||
|
ResultsCount: number;
|
||||||
|
|
||||||
LeakResult: LeakResult;
|
LeakResult: LeakResult;
|
||||||
GithubResult: GithubResult;
|
GithubResult: GithubResult;
|
||||||
GravatarResult: GravatarResult;
|
GravatarResult: GravatarResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type HistoryItem = {
|
export type History = Result[];
|
||||||
Id: string;
|
|
||||||
Status: "queued" | "pending" | "completed";
|
|
||||||
Date: string;
|
|
||||||
Query: Query;
|
|
||||||
Results: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type History = HistoryItem[];
|
|
||||||
|
|
||||||
export type ServerSettings = {
|
export type ServerSettings = {
|
||||||
Folders: string[];
|
Folders: string[];
|
||||||
|
|||||||
Reference in New Issue
Block a user