mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-08 16:48:51 +00:00
req: print at least something when auth fails.
This commit is contained in:
13
req.go
13
req.go
@@ -6,10 +6,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/urfave/cli/v3"
|
|
||||||
"github.com/mailru/easyjson"
|
"github.com/mailru/easyjson"
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"github.com/nbd-wtf/go-nostr"
|
||||||
"github.com/nbd-wtf/go-nostr/nip77"
|
"github.com/nbd-wtf/go-nostr/nip77"
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -80,7 +80,16 @@ example:
|
|||||||
relayUrls,
|
relayUrls,
|
||||||
c.Bool("force-pre-auth"),
|
c.Bool("force-pre-auth"),
|
||||||
nostr.WithAuthHandler(
|
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") {
|
if !c.Bool("auth") && !c.Bool("force-pre-auth") {
|
||||||
return fmt.Errorf("auth not authorized")
|
return fmt.Errorf("auth not authorized")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user