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 28, 2024
1 parent 784a622 commit 4129f29
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 105 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
uid 1
gid 1
profiling.memory on
Expand Down
226 changes: 124 additions & 102 deletions configuration/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,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 @@ -1082,108 +1094,110 @@ 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,
HttpclientSslCaFile: httpClientSSLCaFile,
HttpclientSslVerify: httpClientSSLVerify,
PreallocFd: preallocFD,
SslDefaultBindCiphers: sslBindCiphers,
SslDefaultBindCiphersuites: sslBindCiphersuites,
SslDefaultBindCurves: sslDefaultBindCurves,
SslDefaultBindOptions: sslBindOptions,
SslDefaultServerCiphers: sslDefaultServerCiphers,
SslDefaultServerCiphersuites: sslServerCiphersuites,
SslDefaultServerOptions: sslServerOptions,
SslModeAsync: sslModeAsync,
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,
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,
HttpclientSslCaFile: httpClientSSLCaFile,
HttpclientSslVerify: httpClientSSLVerify,
PreallocFd: preallocFD,
SslDefaultBindCiphers: sslBindCiphers,
SslDefaultBindCiphersuites: sslBindCiphersuites,
SslDefaultBindCurves: sslDefaultBindCurves,
SslDefaultBindOptions: sslBindOptions,
SslDefaultServerCiphers: sslDefaultServerCiphers,
SslDefaultServerCiphersuites: sslServerCiphersuites,
SslDefaultServerOptions: sslServerOptions,
SslModeAsync: sslModeAsync,
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,
}

return global, nil
Expand Down Expand Up @@ -1814,6 +1828,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 @@ -10,7 +10,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/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/mitchellh/mapstructure v1.5.0
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,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.

4 changes: 4 additions & 0 deletions specification/build/haproxy_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,8 @@ definitions:
pattern: ^[^\s]+$
type: string
x-display-name: Group
h1_accept_payload_with_any_method:
type: boolean
h1_case_adjust:
items:
properties:
Expand All @@ -1129,6 +1131,8 @@ definitions:
x-omitempty: true
h1_case_adjust_file:
type: string
h1_do_not_close_on_insecure_transfer_encoding:
type: boolean
h2_workaround_bogus_websocket_clients:
type: boolean
hard_stop_after:
Expand Down
4 changes: 4 additions & 0 deletions specification/models/configuration/global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,10 @@ global:
type: string
h1_case_adjust_file:
type: string
h1_accept_payload_with_any_method:
type: boolean
h1_do_not_close_on_insecure_transfer_encoding:
type: boolean
quiet:
type: boolean
zero_warning:
Expand Down

0 comments on commit 4129f29

Please sign in to comment.