From 515f76bd86412f9d0ddcc86823798d59449df460 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 16 Sep 2024 07:11:16 -0300 Subject: [PATCH] add a default user-agent: github.com/nbd-wtf/go-nostr. fixes https://github.com/nbd-wtf/go-nostr/issues/147 --- relay.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/relay.go b/relay.go index ce44268..ca86a1c 100644 --- a/relay.go +++ b/relay.go @@ -160,6 +160,13 @@ func (r *Relay) ConnectWithTLS(ctx context.Context, tlsConfig *tls.Config) error defer cancel() } + if r.RequestHeader == nil { + r.RequestHeader = make(http.Header, 1) + } + if r.RequestHeader.Get("User-Agent") == "" { + r.RequestHeader.Set("User-Agent", "github.com/nbd-wtf/go-nostr") + } + conn, err := NewConnection(ctx, r.URL, r.RequestHeader, tlsConfig) if err != nil { return fmt.Errorf("error opening websocket to '%s': %w", r.URL, err)