mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-05-18 22:49:57 +02:00
fix: don't stop reading the websocket for no reason!
This commit is contained in:
parent
6e79f72174
commit
c03c028142
11
relay.go
11
relay.go
@ -236,6 +236,7 @@ func (r *Relay) Connect(ctx context.Context) error {
|
|||||||
message, err := conn.ReadMessage(r.connectionContext)
|
message, err := conn.ReadMessage(r.connectionContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.ConnectionError = err
|
r.ConnectionError = err
|
||||||
|
r.Close()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +257,7 @@ func (r *Relay) Connect(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
case *AuthEnvelope:
|
case *AuthEnvelope:
|
||||||
if env.Challenge == nil {
|
if env.Challenge == nil {
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
// see WithAuthHandler
|
// see WithAuthHandler
|
||||||
if r.challenges != nil {
|
if r.challenges != nil {
|
||||||
@ -264,16 +265,16 @@ func (r *Relay) Connect(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
case *EventEnvelope:
|
case *EventEnvelope:
|
||||||
if env.SubscriptionID == nil {
|
if env.SubscriptionID == nil {
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
if subscription, ok := r.Subscriptions.Load(*env.SubscriptionID); !ok {
|
if subscription, ok := r.Subscriptions.Load(*env.SubscriptionID); !ok {
|
||||||
// InfoLogger.Printf("{%s} no subscription with id '%s'\n", r.URL, *env.SubscriptionID)
|
// InfoLogger.Printf("{%s} no subscription with id '%s'\n", r.URL, *env.SubscriptionID)
|
||||||
return
|
continue
|
||||||
} else {
|
} else {
|
||||||
// check if the event matches the desired filter, ignore otherwise
|
// check if the event matches the desired filter, ignore otherwise
|
||||||
if !subscription.Filters.Match(&env.Event) {
|
if !subscription.Filters.Match(&env.Event) {
|
||||||
InfoLogger.Printf("{%s} filter does not match: %v ~ %v\n", r.URL, subscription.Filters, env.Event)
|
InfoLogger.Printf("{%s} filter does not match: %v ~ %v\n", r.URL, subscription.Filters, env.Event)
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// check signature, ignore invalid, except from trusted (AssumeValid) relays
|
// check signature, ignore invalid, except from trusted (AssumeValid) relays
|
||||||
@ -284,7 +285,7 @@ func (r *Relay) Connect(ctx context.Context) error {
|
|||||||
errmsg = err.Error()
|
errmsg = err.Error()
|
||||||
}
|
}
|
||||||
InfoLogger.Printf("{%s} bad signature: %s\n", r.URL, errmsg)
|
InfoLogger.Printf("{%s} bad signature: %s\n", r.URL, errmsg)
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user