Skip to content

Commit

Permalink
add a default user-agent: github.com/nbd-wtf/go-nostr.
Browse files Browse the repository at this point in the history
fixes #147
  • Loading branch information
fiatjaf committed Sep 16, 2024
1 parent a54852f commit 515f76b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 515f76b

Please sign in to comment.