From cbc22b64f14cfec1e1ebdc2e76f74b7f492d4d39 Mon Sep 17 00:00:00 2001 From: Mark Pashmfouroush Date: Thu, 21 Mar 2024 18:04:21 +0000 Subject: [PATCH] wiresocks: pass logger to ipscanner Signed-off-by: Mark Pashmfouroush --- app/app.go | 2 +- ipscanner/internal/engine/engine.go | 2 +- wiresocks/scanner.go | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index b2afbf75c..f2b4f0d56 100644 --- a/app/app.go +++ b/app/app.go @@ -60,7 +60,7 @@ func RunWarp(ctx context.Context, l *slog.Logger, opts WarpOptions) error { endpoints := []string{opts.Endpoint, opts.Endpoint} if opts.Scan != nil { - res, err := wiresocks.RunScan(ctx, *opts.Scan) + res, err := wiresocks.RunScan(ctx, l, *opts.Scan) if err != nil { return err } diff --git a/ipscanner/internal/engine/engine.go b/ipscanner/internal/engine/engine.go index bac9dceb3..3af6ab600 100644 --- a/ipscanner/internal/engine/engine.go +++ b/ipscanner/internal/engine/engine.go @@ -28,7 +28,7 @@ func NewScannerEngine(opts *statute.ScannerOptions) *Engine { ipQueue: queue, ping: p.DoPing, generator: iterator.NewIterator(opts), - log: opts.Logger.With(slog.String("subsystem", "engine")), + log: opts.Logger.With(slog.String("subsystem", "scanner/engine")), } } diff --git a/wiresocks/scanner.go b/wiresocks/scanner.go index 109f1908d..80e244696 100644 --- a/wiresocks/scanner.go +++ b/wiresocks/scanner.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "log/slog" "time" "github.com/bepass-org/warp-plus/ipscanner" @@ -17,7 +18,7 @@ type ScanOptions struct { MaxRTT time.Duration } -func RunScan(ctx context.Context, opts ScanOptions) (result []ipscanner.IPInfo, err error) { +func RunScan(ctx context.Context, l *slog.Logger, opts ScanOptions) (result []ipscanner.IPInfo, err error) { cfg, err := ini.Load("./primary/wgcf-profile.ini") if err != nil { return nil, fmt.Errorf("failed to read file: %w", err) @@ -31,6 +32,7 @@ func RunScan(ctx context.Context, opts ScanOptions) (result []ipscanner.IPInfo, // new scanner scanner := ipscanner.NewScanner( + ipscanner.WithLogger(l.With(slog.String("subsystem", "scanner"))), ipscanner.WithWarpPing(), ipscanner.WithWarpPrivateKey(privateKey), ipscanner.WithWarpPeerPublicKey(publicKey),