diff --git a/cmd/geth/main.go b/cmd/geth/main.go index d3934a8cb6..31608e85fb 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -177,6 +177,7 @@ var ( utils.AllowUnprotectedTxs, utils.BatchRequestLimit, utils.BatchResponseMaxSize, + utils.HTTPBodyLimitFlag, utils.RPCTxSyncDefaultTimeoutFlag, utils.RPCTxSyncMaxTimeoutFlag, utils.RPCGlobalRangeLimitFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a6f7576ea2..64c41b00b9 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -861,6 +861,12 @@ var ( Value: node.DefaultConfig.BatchResponseMaxSize, Category: flags.APICategory, } + HTTPBodyLimitFlag = &cli.IntFlag{ + Name: "rpc.http-body-limit", + Usage: "Maximum size (in megabytes) of an HTTP request body", + Value: node.DefaultConfig.HTTPBodyLimit / (1024 * 1024), + Category: flags.APICategory, + } // Network Settings MaxPeersFlag = &cli.IntFlag{ @@ -1361,6 +1367,10 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) { if ctx.IsSet(BatchResponseMaxSize.Name) { cfg.BatchResponseMaxSize = ctx.Int(BatchResponseMaxSize.Name) } + + if ctx.IsSet(HTTPBodyLimitFlag.Name) { + cfg.HTTPBodyLimit = ctx.Int(HTTPBodyLimitFlag.Name) * 1024 * 1024 + } } // setGraphQL creates the GraphQL listener interface string from the set diff --git a/node/config.go b/node/config.go index 77ca78a471..b0f8753a7d 100644 --- a/node/config.go +++ b/node/config.go @@ -198,6 +198,9 @@ type Config struct { // BatchResponseMaxSize is the maximum number of bytes returned from a batched rpc call. BatchResponseMaxSize int `toml:",omitempty"` + // HTTPBodyLimit is the maximum size (in bytes) of an HTTP request body. + HTTPBodyLimit int `toml:",omitempty"` + // JWTSecret is the path to the hex-encoded jwt secret. JWTSecret string `toml:",omitempty"` diff --git a/node/defaults.go b/node/defaults.go index 3410fa2ae5..145507ffe9 100644 --- a/node/defaults.go +++ b/node/defaults.go @@ -67,6 +67,7 @@ var DefaultConfig = Config{ WSModules: []string{"net", "web3"}, BatchRequestLimit: 1000, BatchResponseMaxSize: 25 * 1000 * 1000, + HTTPBodyLimit: 5 * 1024 * 1024, GraphQLVirtualHosts: []string{"localhost"}, P2P: p2p.Config{ ListenAddr: ":30303", diff --git a/node/node.go b/node/node.go index 7c0d69775c..3dd780f42b 100644 --- a/node/node.go +++ b/node/node.go @@ -392,6 +392,7 @@ func (n *Node) startRPC() error { rpcConfig := rpcEndpointConfig{ batchItemLimit: n.config.BatchRequestLimit, batchResponseSizeLimit: n.config.BatchResponseMaxSize, + httpBodyLimit: n.config.HTTPBodyLimit, } initHttp := func(server *httpServer, port int) error {