diff --git a/cmd/cloudflared/tunnel/cmd.go b/cmd/cloudflared/tunnel/cmd.go index f39a3a9b..46468567 100644 --- a/cmd/cloudflared/tunnel/cmd.go +++ b/cmd/cloudflared/tunnel/cmd.go @@ -315,8 +315,7 @@ func StartServer(c *cli.Context, version string, shutdownC, graceShutdownC chan c.Set("url", "http://"+listener.Addr().String()) } - tunnelConfig, err := prepareTunnelConfig(c, buildInfo, version, logger, transportLogger) - tunnelConfig.CloseConnOnce = &closeConnOnce + tunnelConfig, err := prepareTunnelConfig(c, buildInfo, version, logger, transportLogger, &closeConnOnce) if err != nil { return err } diff --git a/cmd/cloudflared/tunnel/configuration.go b/cmd/cloudflared/tunnel/configuration.go index 17c15cb7..0d3510d8 100644 --- a/cmd/cloudflared/tunnel/configuration.go +++ b/cmd/cloudflared/tunnel/configuration.go @@ -13,6 +13,7 @@ import ( "path/filepath" "runtime" "strings" + "sync" "time" "github.com/cloudflare/cloudflared/cmd/cloudflared/config" @@ -136,7 +137,13 @@ If you don't have a certificate signed by Cloudflare, run the command: return originCert, nil } -func prepareTunnelConfig(c *cli.Context, buildInfo *origin.BuildInfo, version string, logger, transportLogger *logrus.Logger) (*origin.TunnelConfig, error) { +func prepareTunnelConfig( + c *cli.Context, + buildInfo *origin.BuildInfo, + version string, logger, + transportLogger *logrus.Logger, + closeConnOnce *sync.Once, +) (*origin.TunnelConfig, error) { hostname, err := validation.ValidateHostname(c.String("hostname")) if err != nil { logger.WithError(err).Error("Invalid hostname") @@ -231,6 +238,7 @@ func prepareTunnelConfig(c *cli.Context, buildInfo *origin.BuildInfo, version st NoChunkedEncoding: c.Bool("no-chunked-encoding"), CompressionQuality: c.Uint64("compression-quality"), IncidentLookup: origin.NewIncidentLookup(), + CloseConnOnce: closeConnOnce, }, nil }