Skip to content

Commit ba497ad

Browse files
committed
BUG/MAJOR: runtime_server: fix adding all the server options for server
1 parent a364a31 commit ba497ad

File tree

2 files changed

+150
-77
lines changed

2 files changed

+150
-77
lines changed

.aspell.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ allowed:
1414
- bmarkovic
1515
- browserslist
1616
- caniuse
17+
- cfg
1718
- cli
1819
- clickhouse
1920
- composable

handlers/runtime_server.go

Lines changed: 149 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,14 @@ func SerializeRuntimeAddServer(srv *models.RuntimeAddServer) string { //nolint:c
248248
}
249249
// push a quoted string
250250
pushq := func(key, val string) {
251-
fmt.Fprintf(b, ` %s "%s"`, key, val)
251+
fmt.Fprintf(b, ` %s %s`, key, val)
252252
}
253253
enabled := func(s string) bool {
254254
return s == "enabled"
255255
}
256+
disabled := func(s string) bool {
257+
return s == "disabled"
258+
}
256259

257260
// Address is mandatory and must come first, with an optional port number.
258261
addr := srv.Address
@@ -261,155 +264,224 @@ func SerializeRuntimeAddServer(srv *models.RuntimeAddServer) string { //nolint:c
261264
}
262265
push(addr)
263266

264-
switch {
265-
case enabled(srv.AgentCheck):
267+
if enabled(srv.AgentCheck) {
266268
push("agent-check")
267-
case srv.AgentAddr != "":
269+
}
270+
if srv.AgentAddr != "" {
268271
pushq("agent-addr", srv.AgentAddr)
269-
case srv.AgentPort != nil:
272+
}
273+
if srv.AgentPort != nil {
270274
pushi("agent-port", srv.AgentPort)
271-
case srv.AgentInter != nil:
275+
}
276+
if srv.AgentInter != nil {
272277
pushi("agent-inter", srv.AgentInter)
273-
case srv.AgentSend != "":
278+
}
279+
if srv.AgentSend != "" {
274280
pushq("agent-send", srv.AgentSend)
275-
case srv.Allow0rtt:
281+
}
282+
if srv.Allow0rtt {
276283
push("allow-0rtt")
277-
case srv.Alpn != "":
284+
}
285+
if srv.Alpn != "" {
278286
pushq("alpn", srv.Alpn)
279-
case enabled(srv.Backup):
287+
}
288+
if enabled(srv.Backup) {
280289
push("backup")
281-
case srv.SslCafile != "":
290+
}
291+
if srv.SslCafile != "" {
282292
pushq("ca-file", srv.SslCafile)
283-
case enabled(srv.Check):
293+
}
294+
if enabled(srv.Check) {
284295
push("check")
285-
case srv.CheckAlpn != "":
296+
}
297+
if srv.CheckAlpn != "" {
286298
pushq("check-alpn", srv.CheckAlpn)
287-
case srv.HealthCheckAddress != "":
299+
}
300+
if srv.HealthCheckAddress != "" {
288301
pushq("addr", srv.HealthCheckAddress)
289-
case srv.HealthCheckPort != nil:
302+
}
303+
if srv.HealthCheckPort != nil {
290304
pushi("port", srv.HealthCheckPort)
291-
case srv.CheckProto != "":
305+
}
306+
if srv.CheckProto != "" {
292307
pushq("check-proto", srv.CheckProto)
293-
case enabled(srv.CheckSendProxy):
308+
}
309+
if enabled(srv.CheckSendProxy) {
294310
push("check-send-proxy")
295-
case srv.CheckSni != "":
311+
}
312+
if srv.CheckSni != "" {
296313
pushq("check-sni", srv.CheckSni)
297-
case enabled(srv.CheckSsl):
314+
}
315+
if enabled(srv.CheckSsl) {
298316
push("check-ssl")
299-
case enabled(srv.CheckViaSocks4):
317+
}
318+
if enabled(srv.CheckViaSocks4) {
300319
push("check-via-socks4")
301-
case srv.Ciphers != "":
320+
}
321+
if srv.Ciphers != "" {
302322
pushq("ciphers", srv.Ciphers)
303-
case srv.Ciphersuites != "":
323+
}
324+
if srv.Ciphersuites != "" {
304325
pushq("ciphersuites", srv.Ciphersuites)
305-
case srv.CrlFile != "":
326+
}
327+
if srv.CrlFile != "" {
306328
pushq("crl-file", srv.CrlFile)
307-
case srv.SslCertificate != "":
329+
}
330+
if srv.SslCertificate != "" {
308331
pushq("crt", srv.SslCertificate)
309-
case enabled(srv.Maintenance):
332+
}
333+
if enabled(srv.Maintenance) {
310334
push("disabled")
311-
case srv.Downinter != nil:
335+
}
336+
if srv.Downinter != nil {
312337
pushi("downinter", srv.Downinter)
313-
case !enabled(srv.Maintenance):
338+
}
339+
if disabled(srv.Maintenance) {
314340
push("enabled")
315-
case srv.ErrorLimit != nil:
341+
}
342+
if srv.ErrorLimit != nil {
316343
pushi("error-limit", srv.ErrorLimit)
317-
case srv.Fall != nil:
344+
}
345+
if srv.Fall != nil {
318346
pushi("fall", srv.Fall)
319-
case srv.Fastinter != nil:
347+
}
348+
if srv.Fastinter != nil {
320349
pushi("fastinter", srv.Fastinter)
321-
case enabled(srv.ForceSslv3):
350+
}
351+
if enabled(srv.ForceSslv3) {
322352
push("force-sslv3")
323-
case enabled(srv.ForceTlsv10):
353+
}
354+
if enabled(srv.ForceTlsv10) {
324355
push("force-tlsv10")
325-
case enabled(srv.ForceTlsv11):
356+
}
357+
if enabled(srv.ForceTlsv11) {
326358
push("force-tlsv11")
327-
case enabled(srv.ForceTlsv12):
359+
}
360+
if enabled(srv.ForceTlsv12) {
328361
push("force-tlsv12")
329-
case enabled(srv.ForceTlsv13):
362+
}
363+
if enabled(srv.ForceTlsv13) {
330364
push("force-tlsv13")
331-
case srv.ID != "":
365+
}
366+
if srv.ID != "" {
332367
pushq("id", srv.ID)
333-
case srv.Inter != nil:
368+
}
369+
if srv.Inter != nil {
334370
pushi("inter", srv.Inter)
335-
case srv.Maxconn != nil:
371+
}
372+
if srv.Maxconn != nil {
336373
pushi("maxconn", srv.Maxconn)
337-
case srv.Maxqueue != nil:
374+
}
375+
if srv.Maxqueue != nil {
338376
pushi("maxqueue", srv.Maxqueue)
339-
case srv.Minconn != nil:
377+
}
378+
if srv.Minconn != nil {
340379
pushi("minconn", srv.Minconn)
341-
case !enabled(srv.SslReuse):
380+
}
381+
if disabled(srv.SslReuse) {
342382
push("no-ssl-reuse")
343-
case enabled(srv.NoSslv3):
383+
}
384+
if enabled(srv.NoSslv3) {
344385
push("no-sslv3")
345-
case enabled(srv.NoTlsv10):
386+
}
387+
if enabled(srv.NoTlsv10) {
346388
push("no-tlsv10")
347-
case enabled(srv.NoTlsv11):
389+
}
390+
if enabled(srv.NoTlsv11) {
348391
push("no-tlsv11")
349-
case enabled(srv.NoTlsv12):
392+
}
393+
if enabled(srv.NoTlsv12) {
350394
push("no-tlsv12")
351-
case enabled(srv.NoTlsv13):
395+
}
396+
if enabled(srv.NoTlsv13) {
352397
push("no-tlsv13")
353-
case !enabled(srv.TLSTickets):
398+
}
399+
if disabled(srv.TLSTickets) {
354400
push("no-tls-tickets")
355-
case srv.Npn != "":
401+
}
402+
if srv.Npn != "" {
356403
pushq("npm", srv.Npn)
357-
case srv.Observe != "":
404+
}
405+
if srv.Observe != "" {
358406
pushq("observe", srv.Observe)
359-
case srv.OnError != "":
407+
}
408+
if srv.OnError != "" {
360409
pushq("on-error", srv.OnError)
361-
case srv.OnMarkedDown != "":
410+
}
411+
if srv.OnMarkedDown != "" {
362412
pushq("on-marked-down", srv.OnMarkedDown)
363-
case srv.OnMarkedUp != "":
413+
}
414+
if srv.OnMarkedUp != "" {
364415
pushq("on-marked-up", srv.OnMarkedUp)
365-
case srv.PoolLowConn != nil:
416+
}
417+
if srv.PoolLowConn != nil {
366418
pushi("pool-low-conn", srv.PoolLowConn)
367-
case srv.PoolMaxConn != nil:
419+
}
420+
if srv.PoolMaxConn != nil {
368421
pushi("pool-max-conn", srv.PoolMaxConn)
369-
case srv.PoolPurgeDelay != nil:
422+
}
423+
if srv.PoolPurgeDelay != nil {
370424
pushi("pool-purge-delay", srv.PoolPurgeDelay)
371-
case srv.Proto != "":
425+
}
426+
if srv.Proto != "" {
372427
pushq("proto", srv.Proto)
373-
case len(srv.ProxyV2Options) > 0:
428+
}
429+
if len(srv.ProxyV2Options) > 0 {
374430
pushq("proxy-v2-options", strings.Join(srv.ProxyV2Options, ","))
375-
case srv.Rise != nil:
431+
}
432+
if srv.Rise != nil {
376433
pushi("rise", srv.Rise)
377-
case enabled(srv.SendProxy):
434+
}
435+
if enabled(srv.SendProxy) {
378436
push("send-proxy")
379-
case enabled(srv.SendProxyV2):
437+
}
438+
if enabled(srv.SendProxyV2) {
380439
push("send-proxy-v2")
381-
case enabled(srv.SendProxyV2Ssl):
440+
}
441+
if enabled(srv.SendProxyV2Ssl) {
382442
push("send-proxy-v2-ssl")
383-
case enabled(srv.SendProxyV2SslCn):
443+
}
444+
if enabled(srv.SendProxyV2SslCn) {
384445
push("send-proxy-v2-ssl-cn")
385-
case srv.Slowstart != nil:
446+
}
447+
if srv.Slowstart != nil {
386448
pushi("slowstart", srv.Slowstart)
387-
case srv.Sni != "":
449+
}
450+
if srv.Sni != "" {
388451
pushq("sni", srv.Sni)
389-
case srv.Source != "":
452+
}
453+
if srv.Source != "" {
390454
pushq("source", srv.Source)
391-
case enabled(srv.Ssl):
455+
}
456+
if enabled(srv.Ssl) {
392457
push("ssl")
393-
case srv.SslMaxVer != "":
458+
}
459+
if srv.SslMaxVer != "" {
394460
pushq("ssl-max-ver", srv.SslMaxVer)
395-
case srv.SslMinVer != "":
461+
}
462+
if srv.SslMinVer != "" {
396463
pushq("ssl-min-ver", srv.SslMinVer)
397-
case enabled(srv.Tfo):
464+
}
465+
if enabled(srv.Tfo) {
398466
push("tfo")
399-
case enabled(srv.TLSTickets):
467+
}
468+
if enabled(srv.TLSTickets) {
400469
push("tls-tickets")
401-
case srv.Track != "":
470+
}
471+
if srv.Track != "" {
402472
pushq("track", srv.Track)
403-
/* XXX usesrc is not supported */
404-
case srv.Verify != "":
473+
}
474+
if srv.Verify != "" {
405475
pushq("verify", srv.Verify)
406-
case srv.Verifyhost != "":
476+
}
477+
if srv.Verifyhost != "" {
407478
pushq("verifyhost", srv.Verifyhost)
408-
case srv.Weight != nil:
479+
}
480+
if srv.Weight != nil {
409481
pushi("weight", srv.Weight)
410-
case srv.Ws != "":
482+
}
483+
if srv.Ws != "" {
411484
pushq("ws", srv.Ws)
412485
}
413-
414486
return b.String()
415487
}

0 commit comments

Comments
 (0)