Merge pull request #16206 from gluk256/277-mailserver
whisper: mailserver no longer supports the signature validation Mailserver is provided as an example, but client validation belongs to the upper layer protocol and needs not be covered in this example. The check that was previously available hinders the switch to libp2p so we agreed not to include that check in that example code anymore.
This commit is contained in:
commit
1843615456
|
@ -17,7 +17,6 @@
|
||||||
package mailserver
|
package mailserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
@ -175,7 +174,10 @@ func (s *WMailServer) validateRequest(peerID []byte, request *whisper.Envelope)
|
||||||
if len(src)-len(peerID) == 1 {
|
if len(src)-len(peerID) == 1 {
|
||||||
src = src[1:]
|
src = src[1:]
|
||||||
}
|
}
|
||||||
if !bytes.Equal(peerID, src) {
|
|
||||||
|
// if you want to check the signature, you can do it here. e.g.:
|
||||||
|
// if !bytes.Equal(peerID, src) {
|
||||||
|
if src == nil {
|
||||||
log.Warn(fmt.Sprintf("Wrong signature of p2p request"))
|
log.Warn(fmt.Sprintf("Wrong signature of p2p request"))
|
||||||
return false, 0, 0, topic
|
return false, 0, 0, topic
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,8 +167,9 @@ func singleRequest(t *testing.T, server *WMailServer, env *whisper.Envelope, p *
|
||||||
|
|
||||||
src[0]++
|
src[0]++
|
||||||
ok, lower, upper, topic = server.validateRequest(src, request)
|
ok, lower, upper, topic = server.validateRequest(src, request)
|
||||||
if ok {
|
if !ok {
|
||||||
t.Fatalf("request validation false positive, seed: %d (lower: %d, upper: %d).", seed, lower, upper)
|
// request should be valid regardless of signature
|
||||||
|
t.Fatalf("request validation false negative, seed: %d (lower: %d, upper: %d).", seed, lower, upper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue