mirror of
https://github.com/fiatjaf/nak.git
synced 2025-07-30 16:58:29 -04:00
more colors.
This commit is contained in:
@@ -209,7 +209,7 @@ func connectToAllRelays(
|
|||||||
} else {
|
} else {
|
||||||
// simple flow
|
// simple flow
|
||||||
for _, url := range relayUrls {
|
for _, url := range relayUrls {
|
||||||
log("connecting to %s... ", url)
|
log("connecting to %s... ", color.CyanString(url))
|
||||||
relay := connectToSingleRelay(ctx, url, preAuthSigner, nil, log)
|
relay := connectToSingleRelay(ctx, url, preAuthSigner, nil, log)
|
||||||
if relay != nil {
|
if relay != nil {
|
||||||
relays = append(relays, relay)
|
relays = append(relays, relay)
|
||||||
|
15
req.go
15
req.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
"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/nip19"
|
"github.com/nbd-wtf/go-nostr/nip19"
|
||||||
@@ -81,7 +82,7 @@ example:
|
|||||||
authSigner := func(ctx context.Context, log func(s string, args ...any), authEvent nostr.RelayEvent) (err error) {
|
authSigner := func(ctx context.Context, log func(s string, args ...any), authEvent nostr.RelayEvent) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log("auth to %s failed: %s",
|
log("%s failed: %s",
|
||||||
authEvent.Tags.Find("relay")[1],
|
authEvent.Tags.Find("relay")[1],
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
@@ -89,7 +90,7 @@ example:
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
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 required, but --auth flag not given")
|
||||||
}
|
}
|
||||||
kr, _, err := gatherKeyerFromArguments(ctx, c)
|
kr, _, err := gatherKeyerFromArguments(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -98,7 +99,7 @@ example:
|
|||||||
|
|
||||||
pk, _ := kr.GetPublicKey(ctx)
|
pk, _ := kr.GetPublicKey(ctx)
|
||||||
npub, _ := nip19.EncodePublicKey(pk)
|
npub, _ := nip19.EncodePublicKey(pk)
|
||||||
log("performing auth as %s…%s... ", npub[0:7], npub[58:])
|
log("authenticating as %s... ", color.YellowString("%s…%s", npub[0:7], npub[58:]))
|
||||||
|
|
||||||
return kr.SignEvent(ctx, authEvent.Event)
|
return kr.SignEvent(ctx, authEvent.Event)
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,13 @@ example:
|
|||||||
relayUrls,
|
relayUrls,
|
||||||
forcePreAuthSigner,
|
forcePreAuthSigner,
|
||||||
nostr.WithAuthHandler(func(ctx context.Context, authEvent nostr.RelayEvent) error {
|
nostr.WithAuthHandler(func(ctx context.Context, authEvent nostr.RelayEvent) error {
|
||||||
return authSigner(ctx, func(s string, args ...any) { log(s+"\n", args...) }, authEvent)
|
return authSigner(ctx, func(s string, args ...any) {
|
||||||
|
if strings.HasPrefix(s, "authenticating as") {
|
||||||
|
url := authEvent.Tags.Find("relay")[1]
|
||||||
|
s = "authenticating to " + color.CyanString(url) + " as" + s[len("authenticating as"):]
|
||||||
|
}
|
||||||
|
log(s+"\n", args...)
|
||||||
|
}, authEvent)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user