swarm/network: disallow historical retrieval requests (#17936)

This commit is contained in:
Elad
2018-10-19 10:50:25 +02:00
committed by Viktor Trón
parent 97fb08342d
commit aeb733623e
5 changed files with 11 additions and 7 deletions

View File

@@ -18,6 +18,7 @@ package stream
import (
"context"
"errors"
"fmt"
"math"
"sync"
@@ -96,7 +97,10 @@ func NewRegistry(localID enode.ID, delivery *Delivery, syncChunkStore storage.Sy
delivery.getPeer = streamer.getPeer
if options.DoServeRetrieve {
streamer.RegisterServerFunc(swarmChunkServerStreamName, func(_ *Peer, _ string, _ bool) (Server, error) {
streamer.RegisterServerFunc(swarmChunkServerStreamName, func(_ *Peer, _ string, live bool) (Server, error) {
if !live {
return nil, errors.New("only live retrieval requests supported")
}
return NewSwarmChunkServer(delivery.chunkStore), nil
})
}
@@ -279,7 +283,6 @@ func (r *Registry) Subscribe(peerId enode.ID, s Stream, h *Range, priority uint8
if err != nil {
return err
}
if s.Live && h != nil {
if err := peer.setClientParams(
getHistoryStream(s),