From 707e5b3918cff690c29cd33542c4b7a3070b6de0 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 17 Feb 2025 17:00:21 -0300 Subject: [PATCH] req: print at least something when auth fails. --- req.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/req.go b/req.go index d189db0..3d3e799 100644 --- a/req.go +++ b/req.go @@ -6,10 +6,10 @@ import ( "os" "strings" - "github.com/urfave/cli/v3" "github.com/mailru/easyjson" "github.com/nbd-wtf/go-nostr" "github.com/nbd-wtf/go-nostr/nip77" + "github.com/urfave/cli/v3" ) const ( @@ -80,7 +80,16 @@ example: relayUrls, c.Bool("force-pre-auth"), nostr.WithAuthHandler( - func(ctx context.Context, authEvent nostr.RelayEvent) error { + func(ctx context.Context, authEvent nostr.RelayEvent) (err error) { + defer func() { + if err != nil { + log("auth to %s failed: %s\n", + (*authEvent.Tags.GetFirst([]string{"relay", ""}))[1], + err, + ) + } + }() + if !c.Bool("auth") && !c.Bool("force-pre-auth") { return fmt.Errorf("auth not authorized") }