diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-01-19 02:54:41 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-01-28 05:57:44 +0300 |
commit | 8627963a4cf1874e2550889cd687bc30ecdab0c6 (patch) | |
tree | cf92b87bc9ef68aa2b3daca0836677914719ac52 /main.go | |
parent | bc757b304ff6c958dfd771f87959b3dad8418c92 (diff) |
Define separator for MultiStringFlag
Allows initializing each MultiStringFlag using its own separator and
defaults to `,` when not specified.
This change makes the `-header` flag use a `;;` separator so that it can
be defined inside a config file.
Fixes https://gitlab.com/gitlab-org/gitlab-pages/-/issues/531.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -33,7 +33,7 @@ func init() { flag.Var(&listenHTTP, "listen-http", "The address(es) to listen on for HTTP requests") flag.Var(&listenHTTPS, "listen-https", "The address(es) to listen on for HTTPS requests") flag.Var(&listenProxy, "listen-proxy", "The address(es) to listen on for proxy requests") - flag.Var(&ListenHTTPSProxyv2, "listen-https-proxyv2", "The address(es) to listen on for HTTPS PROXYv2 requests (https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt)") + flag.Var(&listenHTTPSProxyv2, "listen-https-proxyv2", "The address(es) to listen on for HTTPS PROXYv2 requests (https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt)") flag.Var(&header, "header", "The additional http header(s) that should be send to the client") } @@ -86,12 +86,12 @@ var ( disableCrossOriginRequests = flag.Bool("disable-cross-origin-requests", false, "Disable cross-origin requests") // See init() - listenHTTP MultiStringFlag - listenHTTPS MultiStringFlag - listenProxy MultiStringFlag - ListenHTTPSProxyv2 MultiStringFlag + listenHTTP = MultiStringFlag{separator: ","} + listenHTTPS = MultiStringFlag{separator: ","} + listenProxy = MultiStringFlag{separator: ","} + listenHTTPSProxyv2 = MultiStringFlag{separator: ","} - header MultiStringFlag + header = MultiStringFlag{separator: ";;"} ) func gitlabServerFromFlags() string { @@ -172,7 +172,7 @@ func configFromFlags() appConfig { // tlsMinVersion and tlsMaxVersion are validated in appMain config.TLSMinVersion = tlsconfig.AllTLSVersions[*tlsMinVersion] config.TLSMaxVersion = tlsconfig.AllTLSVersions[*tlsMaxVersion] - config.CustomHeaders = header + config.CustomHeaders = header.Split() for _, file := range []struct { contents *[]byte @@ -274,10 +274,10 @@ func loadConfig() appConfig { "disable-cross-origin-requests": *disableCrossOriginRequests, "domain": config.Domain, "insecure-ciphers": config.InsecureCiphers, - "listen-http": strings.Join(listenHTTP, ","), - "listen-https": strings.Join(listenHTTPS, ","), - "listen-proxy": strings.Join(listenProxy, ","), - "listen-https-proxyv2": strings.Join(ListenHTTPSProxyv2, ","), + "listen-http": listenHTTP, + "listen-https": listenHTTPS, + "listen-proxy": listenProxy, + "listen-https-proxyv2": listenHTTPSProxyv2, "log-format": *logFormat, "metrics-address": *metricsAddress, "pages-domain": *pagesDomain, @@ -399,7 +399,7 @@ func createAppListeners(config *appConfig) []io.Closer { config.ListenProxy = append(config.ListenProxy, f.Fd()) } - for _, addr := range ListenHTTPSProxyv2.Split() { + for _, addr := range listenHTTPSProxyv2.Split() { l, f := createSocket(addr) closers = append(closers, l, f) |