Skip to content

Commit

Permalink
BUG/MINOR: add h1-accept-payload-with-any-method and h1-do-not-close-…
Browse files Browse the repository at this point in the history
…on-insecure-transfer-encoding to global
  • Loading branch information
hdurand0710 committed Aug 27, 2024
1 parent 80ee7c6 commit 352c778
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 117 deletions.
2 changes: 2 additions & 0 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ global
h1-case-adjust-file /etc/headers.adjust
h1-case-adjust host Host
h1-case-adjust content-type Content-Type
h1-accept-payload-with-any-method
h1-do-not-close-on-insecure-transfer-encoding
limited-quic
uid 1
gid 1
Expand Down
246 changes: 134 additions & 112 deletions configuration/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,18 @@ func ParseGlobalSection(p parser.Parser) (*models.Global, error) { //nolint:goco
h1CaseAdjustFile = caseFileParser.Value
}

var h1AcceptPayloadWithAnyMethod bool
h1AcceptPayloadWithAnyMethod, err = parseBoolOption(p, "h1-accept-payload-with-any-method")
if err != nil {
return nil, err
}

var h1DoNotCloseOnInsecureTransferEncoding bool
h1DoNotCloseOnInsecureTransferEncoding, err = parseBoolOption(p, "h1-do-not-close-on-insecure-transfer-encoding")
if err != nil {
return nil, err
}

var busyPolling bool
_, err = p.Get(parser.Global, parser.GlobalSectionName, "busy-polling")
if !errors.Is(err, parser_errors.ErrFetch) {
Expand Down Expand Up @@ -1148,118 +1160,120 @@ func ParseGlobalSection(p parser.Parser) (*models.Global, error) { //nolint:goco
}

global := &models.Global{
Anonkey: anonkey,
PresetEnvs: presetEnvs,
SetEnvs: setEnvs,
Resetenv: resetEnv,
Unsetenv: unsetEnv,
UID: uid,
User: user,
Gid: gid,
Group: group,
ClusterSecret: clusterSecret,
Chroot: chroot,
Localpeer: localPeer,
CaBase: caBase,
CrtBase: crtBase,
ServerStateBase: srvStateBase,
ServerStateFile: srvStateFile,
HardStopAfter: hardStop,
Daemon: daemon,
DefaultPath: defaultPath,
MasterWorker: masterWorker,
Maxconn: mConn,
Nbproc: nbproc,
Nbthread: nbthread,
Pidfile: pidfile,
RuntimeAPIs: rAPIs,
StatsTimeout: statsTimeout,
CPUMaps: cpuMaps,
HttpclientResolversDisabled: httpClientResolversDisabled,
HttpclientResolversID: httpClientResolversID,
HttpclientResolversPrefer: httpClientResolversPrefer,
HttpclientRetries: httpClientRetries,
HttpclientSslCaFile: httpClientSSLCaFile,
HttpclientSslVerify: httpClientSSLVerify,
HttpclientTimeoutConnect: httpClientTimeoutConnect,
PreallocFd: preallocFD,
SslDefaultBindCiphers: sslBindCiphers,
SslDefaultBindCiphersuites: sslBindCiphersuites,
SslDefaultBindCurves: sslDefaultBindCurves,
SslDefaultServerCurves: sslDefaultServerCurves,
SslDefaultBindOptions: sslBindOptions,
SslDefaultServerCiphers: sslDefaultServerCiphers,
SslDefaultServerCiphersuites: sslServerCiphersuites,
SslDefaultServerOptions: sslServerOptions,
SslModeAsync: sslModeAsync,
SslPropquery: sslPropquery,
SslProvider: sslProvider,
SslProviderPath: sslProviderPath,
SslSkipSelfIssuedCa: sslSkipSelfIssuedCa,
TuneOptions: tuneOptions,
TuneSslDefaultDhParam: dhParam,
ExternalCheck: externalCheck,
LuaLoads: luaLoads,
LuaPrependPath: luaPrependPath,
LogSendHostname: globalLogSendHostName,
H1CaseAdjusts: h1CaseAdjusts,
H1CaseAdjustFile: h1CaseAdjustFile,
BusyPolling: busyPolling,
MaxSpreadChecks: maxSpreadChecks,
CloseSpreadTime: closeSpreadTime,
Maxconnrate: maxconnrate,
Maxcomprate: maxcomprate,
Maxcompcpuusage: maxcompcpuusage,
Maxpipes: maxpipes,
Maxsessrate: maxsessrate,
Maxsslconn: maxsslconn,
Maxsslrate: maxsslrate,
Maxzlibmem: maxzlibmem,
NoQuic: noQuic,
Noepoll: noepoll,
Nokqueue: nokqueue,
Noevports: noevports,
Nopoll: nopoll,
Nosplice: nosplice,
Nogetaddrinfo: nogetaddrinfo,
Noreuseport: noreuseport,
ProfilingTasks: profilingTasks,
SpreadChecks: spreadChecks,
ThreadGroups: threadGroups,
StatsMaxconn: statsMaxconn,
SslLoadExtraFiles: SSLLoadExtraFiles,
ThreadGroupLines: threadGroupLines,
Node: node,
Description: description,
ExposeExperimentalDirectives: exposeExperimentalDirectives,
Grace: grace,
InsecureForkWanted: insecureForkWanted,
InsecureSetuidWanted: insecureSetuidWanted,
IssuersChainPath: issuersChainPath,
H2WorkaroundBogusWebsocketClients: h2WorkaroundBogusWebsocketClients,
LuaLoadPerThread: luaLoadPerThread,
MworkerMaxReloads: mworkerMaxReloads,
NumaCPUMapping: numaCPUMapping,
Pp2NeverSendLocal: pp2NeverSendLocal,
Ulimitn: ulimitn,
SetDumpable: setDumpable,
StrictLimits: strictLimits,
WurflOptions: &wurflOptions,
DeviceAtlasOptions: deviceAtlasOptions,
FiftyOneDegreesOptions: fiftyOneDegreesOptions,
Quiet: quiet,
ZeroWarning: zeroWarning,
SslEngines: sslEngines,
SslDhParamFile: sslDhParamFile,
SslServerVerify: sslServerVerify,
SetVars: setVars,
SetVarFmts: setVarFormats,
SslDefaultBindSigalgs: sslBindSigalgs,
SslDefaultBindClientSigalgs: sslBindClientSigalgs,
SslDefaultServerSigalgs: sslServerSigalgs,
SslDefaultServerClientSigalgs: sslServerClientSigalgs,
Setcap: setcap,
LimitedQuic: limitedQuic,
Anonkey: anonkey,
PresetEnvs: presetEnvs,
SetEnvs: setEnvs,
Resetenv: resetEnv,
Unsetenv: unsetEnv,
UID: uid,
User: user,
Gid: gid,
Group: group,
ClusterSecret: clusterSecret,
Chroot: chroot,
Localpeer: localPeer,
CaBase: caBase,
CrtBase: crtBase,
ServerStateBase: srvStateBase,
ServerStateFile: srvStateFile,
HardStopAfter: hardStop,
Daemon: daemon,
DefaultPath: defaultPath,
MasterWorker: masterWorker,
Maxconn: mConn,
Nbproc: nbproc,
Nbthread: nbthread,
Pidfile: pidfile,
RuntimeAPIs: rAPIs,
StatsTimeout: statsTimeout,
CPUMaps: cpuMaps,
HttpclientResolversDisabled: httpClientResolversDisabled,
HttpclientResolversID: httpClientResolversID,
HttpclientResolversPrefer: httpClientResolversPrefer,
HttpclientRetries: httpClientRetries,
HttpclientSslCaFile: httpClientSSLCaFile,
HttpclientSslVerify: httpClientSSLVerify,
HttpclientTimeoutConnect: httpClientTimeoutConnect,
PreallocFd: preallocFD,
SslDefaultBindCiphers: sslBindCiphers,
SslDefaultBindCiphersuites: sslBindCiphersuites,
SslDefaultBindCurves: sslDefaultBindCurves,
SslDefaultServerCurves: sslDefaultServerCurves,
SslDefaultBindOptions: sslBindOptions,
SslDefaultServerCiphers: sslDefaultServerCiphers,
SslDefaultServerCiphersuites: sslServerCiphersuites,
SslDefaultServerOptions: sslServerOptions,
SslModeAsync: sslModeAsync,
SslPropquery: sslPropquery,
SslProvider: sslProvider,
SslProviderPath: sslProviderPath,
SslSkipSelfIssuedCa: sslSkipSelfIssuedCa,
TuneOptions: tuneOptions,
TuneSslDefaultDhParam: dhParam,
ExternalCheck: externalCheck,
LuaLoads: luaLoads,
LuaPrependPath: luaPrependPath,
LogSendHostname: globalLogSendHostName,
H1CaseAdjusts: h1CaseAdjusts,
H1CaseAdjustFile: h1CaseAdjustFile,
H1AcceptPayloadWithAnyMethod: h1AcceptPayloadWithAnyMethod,
H1DoNotCloseOnInsecureTransferEncoding: h1DoNotCloseOnInsecureTransferEncoding,
BusyPolling: busyPolling,
MaxSpreadChecks: maxSpreadChecks,
CloseSpreadTime: closeSpreadTime,
Maxconnrate: maxconnrate,
Maxcomprate: maxcomprate,
Maxcompcpuusage: maxcompcpuusage,
Maxpipes: maxpipes,
Maxsessrate: maxsessrate,
Maxsslconn: maxsslconn,
Maxsslrate: maxsslrate,
Maxzlibmem: maxzlibmem,
NoQuic: noQuic,
Noepoll: noepoll,
Nokqueue: nokqueue,
Noevports: noevports,
Nopoll: nopoll,
Nosplice: nosplice,
Nogetaddrinfo: nogetaddrinfo,
Noreuseport: noreuseport,
ProfilingTasks: profilingTasks,
SpreadChecks: spreadChecks,
ThreadGroups: threadGroups,
StatsMaxconn: statsMaxconn,
SslLoadExtraFiles: SSLLoadExtraFiles,
ThreadGroupLines: threadGroupLines,
Node: node,
Description: description,
ExposeExperimentalDirectives: exposeExperimentalDirectives,
Grace: grace,
InsecureForkWanted: insecureForkWanted,
InsecureSetuidWanted: insecureSetuidWanted,
IssuersChainPath: issuersChainPath,
H2WorkaroundBogusWebsocketClients: h2WorkaroundBogusWebsocketClients,
LuaLoadPerThread: luaLoadPerThread,
MworkerMaxReloads: mworkerMaxReloads,
NumaCPUMapping: numaCPUMapping,
Pp2NeverSendLocal: pp2NeverSendLocal,
Ulimitn: ulimitn,
SetDumpable: setDumpable,
StrictLimits: strictLimits,
WurflOptions: &wurflOptions,
DeviceAtlasOptions: deviceAtlasOptions,
FiftyOneDegreesOptions: fiftyOneDegreesOptions,
Quiet: quiet,
ZeroWarning: zeroWarning,
SslEngines: sslEngines,
SslDhParamFile: sslDhParamFile,
SslServerVerify: sslServerVerify,
SetVars: setVars,
SetVarFmts: setVarFormats,
SslDefaultBindSigalgs: sslBindSigalgs,
SslDefaultBindClientSigalgs: sslBindClientSigalgs,
SslDefaultServerSigalgs: sslServerSigalgs,
SslDefaultServerClientSigalgs: sslServerClientSigalgs,
Setcap: setcap,
LimitedQuic: limitedQuic,
}

return global, nil
Expand Down Expand Up @@ -1940,6 +1954,14 @@ func SerializeGlobalSection(p parser.Parser, data *models.Global) error { //noli
return err
}

if err := serializeBoolOption(p, "h1-accept-payload-with-any-method", data.H1AcceptPayloadWithAnyMethod); err != nil {
return err
}

if err := serializeBoolOption(p, "h1-do-not-close-on-insecure-transfer-encoding", data.H1DoNotCloseOnInsecureTransferEncoding); err != nil {
return err
}

node := &types.StringC{Value: data.Node}
if data.Node == "" {
node = nil
Expand Down
6 changes: 6 additions & 0 deletions configuration/global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ func TestGetGlobal(t *testing.T) {
if global.H1CaseAdjustFile != "/etc/headers.adjust" {
t.Errorf("H1CaseAdjustFile is %v, expected /etc/headers.adjust", global.H1CaseAdjustFile)
}
if !global.H1AcceptPayloadWithAnyMethod {
t.Errorf("H1AcceptPayloadWithAnyMethod is false, expected true")
}
if !global.H1DoNotCloseOnInsecureTransferEncoding {
t.Errorf("H1DoNotCloseOnInsecureTransferEncoding is false, expected true")
}
if global.UID != 1 {
t.Errorf("UID is %v, expected 1", global.UID)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/google/go-cmp v0.6.0
github.com/google/renameio v1.0.1
github.com/google/uuid v1.6.0
github.com/haproxytech/config-parser/v5 v5.1.4
github.com/haproxytech/config-parser/v5 v5.1.5
github.com/json-iterator/go v1.1.12
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/mitchellh/mapstructure v1.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/google/renameio v1.0.1 h1:Lh/jXZmvZxb0BBeSY5VKEfidcbcbenKjZFzM/q0fSeU
github.com/google/renameio v1.0.1/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/haproxytech/config-parser/v5 v5.1.4 h1:TArFSuRpYlmTanZjt3nVe7lNcPw+pXmth8tLW72ENeM=
github.com/haproxytech/config-parser/v5 v5.1.4/go.mod h1:16+1AbS+AvMZkDScIhergz2dqecQuEmjwV4Xt5ncS9s=
github.com/haproxytech/config-parser/v5 v5.1.5 h1:wZZ7z62Q5xbRQCoyEejli3unj0/Eo+ixJrwe9ZBdzvI=
github.com/haproxytech/config-parser/v5 v5.1.5/go.mod h1:16+1AbS+AvMZkDScIhergz2dqecQuEmjwV4Xt5ncS9s=
github.com/haproxytech/go-logger v1.1.0 h1:HgGtYaI1ApkvbQdsm7f9AzQQoxTB7w37criTflh7IQE=
github.com/haproxytech/go-logger v1.1.0/go.mod h1:OekUd8HCb7ubxMplzHUPBTHNxZmddOWfOjWclZsqIeM=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
Expand Down
6 changes: 6 additions & 0 deletions models/global.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions models/global_compare.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions models/global_compare_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 352c778

Please sign in to comment.