mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-09-28 04:49:33 +02:00
Relay.AssumeValid
This commit is contained in:
19
relay.go
19
relay.go
@@ -48,6 +48,10 @@ type Relay struct {
|
|||||||
ConnectionError chan error
|
ConnectionError chan error
|
||||||
|
|
||||||
okCallbacks s.MapOf[string, func(bool)]
|
okCallbacks s.MapOf[string, func(bool)]
|
||||||
|
|
||||||
|
// custom things that aren't often used
|
||||||
|
//
|
||||||
|
AssumeValid bool // this will skip verifying signatures for events received from this relay
|
||||||
}
|
}
|
||||||
|
|
||||||
// RelayConnect returns a relay object connected to url.
|
// RelayConnect returns a relay object connected to url.
|
||||||
@@ -146,14 +150,15 @@ func (r *Relay) Connect(ctx context.Context) error {
|
|||||||
json.Unmarshal(jsonMessage[2], &event)
|
json.Unmarshal(jsonMessage[2], &event)
|
||||||
|
|
||||||
// check signature of all received events, ignore invalid
|
// check signature of all received events, ignore invalid
|
||||||
ok, err := event.CheckSignature()
|
if !r.AssumeValid {
|
||||||
if !ok {
|
if ok, err := event.CheckSignature(); !ok {
|
||||||
errmsg := ""
|
errmsg := ""
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errmsg = err.Error()
|
errmsg = err.Error()
|
||||||
|
}
|
||||||
|
log.Printf("bad signature: %s", errmsg)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
log.Printf("bad signature: %s", errmsg)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the event matches the desired filter, ignore otherwise
|
// check if the event matches the desired filter, ignore otherwise
|
||||||
|
Reference in New Issue
Block a user