Skip to content

Commit 5c903df

Browse files
authored
Merge pull request #15 from Daniel-Ric/feature/2026-02-03/refactor-percentage-display-layout
Improve lookup progress output and concurrency
2 parents 05fdcf8 + 9c39734 commit 5c903df

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

internal/cli/cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func (a *App) executeLookup(config LookupConfig) error {
389389
BaseHost: config.BaseHost,
390390
Subdomains: config.Subdomains,
391391
DomainEndings: config.Endings,
392-
Concurrency: 24,
392+
Concurrency: 0,
393393
Progress: func(progress ping.LookupProgress) {
394394
current.Store(progress)
395395
},
@@ -418,7 +418,7 @@ func formatLookupProgress(progress ping.LookupProgress, frame int) string {
418418
bar := buildProgressBar(progress.Completed, progress.Total, frame, 20)
419419
percent := (float64(progress.Completed) / float64(progress.Total)) * 100
420420
return fmt.Sprintf(
421-
"%s %d/%d (%.0f%%) | Subdomain: %s | Endung: %s | Host: %s",
421+
"%s %d/%d (%.0f%%)\nSubdomain: %-12s | Endung: %-10s | Host: %s",
422422
bar,
423423
progress.Completed,
424424
progress.Total,

internal/ping/lookup.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ping
33
import (
44
"context"
55
"fmt"
6+
"runtime"
67
"strings"
78
"sync"
89
"sync/atomic"
@@ -53,14 +54,21 @@ func LookupDomains(ctx context.Context, config LookupConfig) (LookupResult, erro
5354
subdomains = []string{""}
5455
}
5556

56-
concurrency := config.Concurrency
57-
if concurrency <= 0 {
58-
concurrency = 16
59-
}
6057
total := len(subdomains) * len(endings)
6158
if total == 0 {
6259
return LookupResult{}, fmt.Errorf("keine kombinationen verfügbar")
6360
}
61+
concurrency := config.Concurrency
62+
if concurrency <= 0 {
63+
base := runtime.NumCPU() * 8
64+
if base < 32 {
65+
base = 32
66+
}
67+
concurrency = base
68+
}
69+
if concurrency > total {
70+
concurrency = total
71+
}
6472

6573
type lookupCandidate struct {
6674
subdomain string

0 commit comments

Comments
 (0)