Skip to content

Commit 7571d76

Browse files
authored
Merge pull request #12 from Daniel-Ric/feature/2026-02-03/enhance-tool-with-ip-lookup-options-kijt1v
Ladeanimation zeigt aktuelle Subdomain und Domain-Endung
2 parents d6cef99 + 36db4b6 commit 7571d76

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

internal/cli/cli.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"strings"
8+
"sync/atomic"
89
"time"
910

1011
"UWP-TCP-Con/internal/ping"
@@ -291,7 +292,9 @@ func (a *App) executeDirect(config DirectConfig) error {
291292
ctx, cancel := context.WithTimeout(context.Background(), a.inputTimeout)
292293
defer cancel()
293294

294-
resultText, err := withSpinner("Abfrage", "Server wird abgefragt", 120*time.Millisecond, func() (string, error) {
295+
resultText, err := withSpinner("Abfrage", func() string {
296+
return "Server wird abgefragt"
297+
}, 120*time.Millisecond, func() (string, error) {
295298
result, err := ping.Execute(ctx, config.Edition, config.Host, config.Port)
296299
if err != nil {
297300
return "", err
@@ -309,14 +312,29 @@ func (a *App) executeDirect(config DirectConfig) error {
309312
func (a *App) executeLookup(config LookupConfig) error {
310313
ctx := context.Background()
311314

312-
resultText, err := withSpinner("IP Lookup", "Domains werden überprüft", 120*time.Millisecond, func() (string, error) {
315+
var current atomic.Value
316+
current.Store("Domains werden überprüft")
317+
formatProgress := func(subdomain, ending string) string {
318+
sub := subdomain
319+
if sub == "" {
320+
sub = "(keine)"
321+
}
322+
return fmt.Sprintf("Subdomain: %s | Endung: %s", sub, ending)
323+
}
324+
325+
resultText, err := withSpinner("IP Lookup", func() string {
326+
return current.Load().(string)
327+
}, 120*time.Millisecond, func() (string, error) {
313328
result, lookupErr := ping.LookupDomains(ctx, ping.LookupConfig{
314329
Edition: config.Edition,
315330
Port: config.Port,
316331
BaseHost: config.BaseHost,
317332
Subdomains: config.Subdomains,
318333
DomainEndings: config.Endings,
319334
Concurrency: 24,
335+
Progress: func(subdomain, ending string) {
336+
current.Store(formatProgress(subdomain, ending))
337+
},
320338
})
321339
if lookupErr != nil {
322340
return "", lookupErr

internal/cli/ui.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func renderSpinnerPage(title, message, frame string) {
213213
renderPage(title, []string{fmt.Sprintf("%s %s", style(message, colorDim), style(frame, colorAccent))})
214214
}
215215

216-
func withSpinner(title, message string, tick time.Duration, action func() (string, error)) (string, error) {
216+
func withSpinner(title string, message func() string, tick time.Duration, action func() (string, error)) (string, error) {
217217
resultCh := make(chan struct {
218218
result string
219219
err error
@@ -245,7 +245,7 @@ func withSpinner(title, message string, tick time.Duration, action func() (strin
245245
fmt.Println()
246246
return res.result, res.err
247247
case <-ticker.C:
248-
line := fmt.Sprintf("%s %s", style(message, colorDim), style(frames[frame], colorAccent))
248+
line := fmt.Sprintf("%s %s", style(message(), colorDim), style(frames[frame], colorAccent))
249249
if lastLen > 0 && len(line) < lastLen {
250250
line += strings.Repeat(" ", lastLen-len(line))
251251
}

internal/ping/lookup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type LookupConfig struct {
1515
Subdomains []string
1616
DomainEndings []string
1717
Concurrency int
18+
Progress func(subdomain, ending string)
1819
}
1920

2021
type LookupMatch struct {
@@ -88,6 +89,9 @@ func LookupDomains(ctx context.Context, config LookupConfig) (LookupResult, erro
8889
defer close(candidates)
8990
for _, sub := range subdomains {
9091
for _, ending := range endings {
92+
if config.Progress != nil {
93+
config.Progress(sub, ending)
94+
}
9195
select {
9296
case <-ctx.Done():
9397
return

0 commit comments

Comments
 (0)