mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
Relay.AssumeValid
This commit is contained in:
parent
483f40a596
commit
02759120ea
19
relay.go
19
relay.go
@ -48,6 +48,10 @@ type Relay struct {
|
||||
ConnectionError chan error
|
||||
|
||||
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.
|
||||
@ -146,14 +150,15 @@ func (r *Relay) Connect(ctx context.Context) error {
|
||||
json.Unmarshal(jsonMessage[2], &event)
|
||||
|
||||
// check signature of all received events, ignore invalid
|
||||
ok, err := event.CheckSignature()
|
||||
if !ok {
|
||||
errmsg := ""
|
||||
if err != nil {
|
||||
errmsg = err.Error()
|
||||
if !r.AssumeValid {
|
||||
if ok, err := event.CheckSignature(); !ok {
|
||||
errmsg := ""
|
||||
if err != nil {
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user