mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
lnd: add http header timeout to config
This commit is contained in:
parent
ad5cd9c8bb
commit
039e9effe7
3 changed files with 15 additions and 6 deletions
10
config.go
10
config.go
|
@ -226,6 +226,9 @@ const (
|
||||||
// client should wait before sending a keepalive ping.
|
// client should wait before sending a keepalive ping.
|
||||||
defaultGrpcClientPingMinWait = 5 * time.Second
|
defaultGrpcClientPingMinWait = 5 * time.Second
|
||||||
|
|
||||||
|
// defaultHTTPHeaderTimeout is the default timeout for HTTP requests.
|
||||||
|
defaultHTTPHeaderTimeout = 5 * time.Second
|
||||||
|
|
||||||
// BitcoinChainName is a string that represents the Bitcoin blockchain.
|
// BitcoinChainName is a string that represents the Bitcoin blockchain.
|
||||||
BitcoinChainName = "bitcoin"
|
BitcoinChainName = "bitcoin"
|
||||||
|
|
||||||
|
@ -492,6 +495,10 @@ type Config struct {
|
||||||
// Dev specifies configs used for integration tests, which is always
|
// Dev specifies configs used for integration tests, which is always
|
||||||
// empty if not built with `integration` flag.
|
// empty if not built with `integration` flag.
|
||||||
Dev *lncfg.DevConfig `group:"dev" namespace:"dev"`
|
Dev *lncfg.DevConfig `group:"dev" namespace:"dev"`
|
||||||
|
|
||||||
|
// HTTPHeaderTimeout is the maximum duration that the server will wait
|
||||||
|
// before timing out reading the headers of an HTTP request.
|
||||||
|
HTTPHeaderTimeout time.Duration `long:"http-header-timeout" description:"The maximum duration that the server will wait before timing out reading the headers of an HTTP request."`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GRPCConfig holds the configuration options for the gRPC server.
|
// GRPCConfig holds the configuration options for the gRPC server.
|
||||||
|
@ -694,7 +701,8 @@ func DefaultConfig() Config {
|
||||||
ServerPingTimeout: defaultGrpcServerPingTimeout,
|
ServerPingTimeout: defaultGrpcServerPingTimeout,
|
||||||
ClientPingMinWait: defaultGrpcClientPingMinWait,
|
ClientPingMinWait: defaultGrpcClientPingMinWait,
|
||||||
},
|
},
|
||||||
WtClient: lncfg.DefaultWtClientCfg(),
|
WtClient: lncfg.DefaultWtClientCfg(),
|
||||||
|
HTTPHeaderTimeout: defaultHTTPHeaderTimeout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
lnd.go
4
lnd.go
|
@ -214,7 +214,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
||||||
pprofServer := &http.Server{
|
pprofServer := &http.Server{
|
||||||
Addr: cfg.Profile,
|
Addr: cfg.Profile,
|
||||||
Handler: pprofMux,
|
Handler: pprofMux,
|
||||||
ReadHeaderTimeout: 5 * time.Second,
|
ReadHeaderTimeout: cfg.HTTPHeaderTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shut the server down when lnd is shutting down.
|
// Shut the server down when lnd is shutting down.
|
||||||
|
@ -271,6 +271,8 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
||||||
LetsEncryptListen: cfg.LetsEncryptListen,
|
LetsEncryptListen: cfg.LetsEncryptListen,
|
||||||
|
|
||||||
DisableRestTLS: cfg.DisableRestTLS,
|
DisableRestTLS: cfg.DisableRestTLS,
|
||||||
|
|
||||||
|
HTTPHeaderTimeout: cfg.HTTPHeaderTimeout,
|
||||||
}
|
}
|
||||||
tlsManager := NewTLSManager(tlsManagerCfg)
|
tlsManager := NewTLSManager(tlsManagerCfg)
|
||||||
serverOpts, restDialOpts, restListen, cleanUp,
|
serverOpts, restDialOpts, restListen, cleanUp,
|
||||||
|
|
|
@ -39,9 +39,6 @@ var (
|
||||||
// - `-----BEGIN PRIVATE KEY-----` (PKCS8).
|
// - `-----BEGIN PRIVATE KEY-----` (PKCS8).
|
||||||
// - `-----BEGIN EC PRIVATE KEY-----` (SEC1/rfc5915, the legacy format).
|
// - `-----BEGIN EC PRIVATE KEY-----` (SEC1/rfc5915, the legacy format).
|
||||||
privateKeyPrefix = []byte("-----BEGIN ")
|
privateKeyPrefix = []byte("-----BEGIN ")
|
||||||
|
|
||||||
// letsEncryptTimeout sets a timeout for the Lets Encrypt server.
|
|
||||||
letsEncryptTimeout = 5 * time.Second
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TLSManagerCfg houses a set of values and methods that is passed to the
|
// TLSManagerCfg houses a set of values and methods that is passed to the
|
||||||
|
@ -61,6 +58,8 @@ type TLSManagerCfg struct {
|
||||||
LetsEncryptListen string
|
LetsEncryptListen string
|
||||||
|
|
||||||
DisableRestTLS bool
|
DisableRestTLS bool
|
||||||
|
|
||||||
|
HTTPHeaderTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// TLSManager generates/renews a TLS cert/key pair when needed. When required,
|
// TLSManager generates/renews a TLS cert/key pair when needed. When required,
|
||||||
|
@ -424,7 +423,7 @@ func (t *TLSManager) setUpLetsEncrypt(certData *tls.Certificate,
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Addr: t.cfg.LetsEncryptListen,
|
Addr: t.cfg.LetsEncryptListen,
|
||||||
Handler: manager.HTTPHandler(nil),
|
Handler: manager.HTTPHandler(nil),
|
||||||
ReadHeaderTimeout: letsEncryptTimeout,
|
ReadHeaderTimeout: t.cfg.HTTPHeaderTimeout,
|
||||||
}
|
}
|
||||||
shutdownCompleted := make(chan struct{})
|
shutdownCompleted := make(chan struct{})
|
||||||
cleanUp = func() {
|
cleanUp = func() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue