mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 21:01:21 +00:00
rpc: make max_body_bytes and max_header_bytes configurable (#3818)
* rpc: make max_body_bytes and max_header_bytes configurable * update changelog pending
This commit is contained in:
committed by
Jack Zampolin
parent
073cd1125e
commit
5d7e22a53c
@ -448,6 +448,9 @@ type wsConnection struct {
|
||||
// Send pings to server with this period. Must be less than readWait, but greater than zero.
|
||||
pingPeriod time.Duration
|
||||
|
||||
// Maximum message size.
|
||||
readLimit int64
|
||||
|
||||
// callback which is called upon disconnect
|
||||
onDisconnect func(remoteAddr string)
|
||||
|
||||
@ -467,7 +470,6 @@ func NewWSConnection(
|
||||
cdc *amino.Codec,
|
||||
options ...func(*wsConnection),
|
||||
) *wsConnection {
|
||||
baseConn.SetReadLimit(maxBodyBytes)
|
||||
wsc := &wsConnection{
|
||||
remoteAddr: baseConn.RemoteAddr().String(),
|
||||
baseConn: baseConn,
|
||||
@ -481,6 +483,7 @@ func NewWSConnection(
|
||||
for _, option := range options {
|
||||
option(wsc)
|
||||
}
|
||||
wsc.baseConn.SetReadLimit(wsc.readLimit)
|
||||
wsc.BaseService = *cmn.NewBaseService(nil, "wsConnection", wsc)
|
||||
return wsc
|
||||
}
|
||||
@ -525,6 +528,14 @@ func PingPeriod(pingPeriod time.Duration) func(*wsConnection) {
|
||||
}
|
||||
}
|
||||
|
||||
// ReadLimit sets the maximum size for reading message.
|
||||
// It should only be used in the constructor - not Goroutine-safe.
|
||||
func ReadLimit(readLimit int64) func(*wsConnection) {
|
||||
return func(wsc *wsConnection) {
|
||||
wsc.readLimit = readLimit
|
||||
}
|
||||
}
|
||||
|
||||
// OnStart implements cmn.Service by starting the read and write routines. It
|
||||
// blocks until the connection closes.
|
||||
func (wsc *wsConnection) OnStart() error {
|
||||
|
Reference in New Issue
Block a user