mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 01:33:02 +01:00
Merge pull request #7991 from Roasbeef/ws-bufio-max-msg
lnrpc: increase max message size for ws proxy
This commit is contained in:
commit
327b0c92bd
@ -228,6 +228,11 @@ None
|
||||
|
||||
* The [WalletBalance](https://github.com/lightningnetwork/lnd/pull/7857) RPC
|
||||
(lncli walletbalance) now supports showing the balance for a specific account.
|
||||
|
||||
* The [websockets proxy now uses a larger default max
|
||||
message](https://github.com/lightningnetwork/lnd/pull/7991) size to support
|
||||
proxying larger messages.
|
||||
|
||||
|
||||
## lncli Updates
|
||||
* Added ability to use [environment variables to override `lncli` global
|
||||
|
@ -38,6 +38,11 @@ const (
|
||||
// an arbitrary non-empty message that has no deeper meaning but should
|
||||
// be sent back by the client in the pong message.
|
||||
PingContent = "are you there?"
|
||||
|
||||
// MaxWsMsgSize is the largest websockets message we'll attempt to
|
||||
// decode in the gRPC <-> WS proxy. gRPC has a similar setting used
|
||||
// elsewhere.
|
||||
MaxWsMsgSize = 4 * 1024 * 1024
|
||||
)
|
||||
|
||||
var (
|
||||
@ -413,9 +418,18 @@ func (r *requestForwardingReader) CloseWriter() {
|
||||
// what's written to it and presents it through a bufio.Scanner interface.
|
||||
func newResponseForwardingWriter() *responseForwardingWriter {
|
||||
r, w := io.Pipe()
|
||||
|
||||
scanner := bufio.NewScanner(r)
|
||||
|
||||
// We pass in a custom buffer for the bufio scanner to use. We'll keep
|
||||
// with a normal 64KB buffer, but allow a larger max message size,
|
||||
// which may cause buffer expansion when needed.
|
||||
buf := make([]byte, 0, bufio.MaxScanTokenSize)
|
||||
scanner.Buffer(buf, MaxWsMsgSize)
|
||||
|
||||
return &responseForwardingWriter{
|
||||
Writer: w,
|
||||
Scanner: bufio.NewScanner(r),
|
||||
Scanner: scanner,
|
||||
pipeR: r,
|
||||
pipeW: w,
|
||||
header: http.Header{},
|
||||
|
Loading…
x
Reference in New Issue
Block a user