From edd982e8520157e4664bda6526e52a8bbadc862e Mon Sep 17 00:00:00 2001 From: Ethan <39577870+ethanndickson@users.noreply.github.com> Date: Fri, 14 Feb 2025 14:11:51 +1100 Subject: [PATCH] fix(vpn/tunnel): fix panic when starting tunnel with headers (#16565) `http.Header` is a map so it needs to be initialized .. --- vpn/tunnel.go | 2 +- vpn/tunnel_internal_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vpn/tunnel.go b/vpn/tunnel.go index 4ed21ab026..002963ae02 100644 --- a/vpn/tunnel.go +++ b/vpn/tunnel.go @@ -230,7 +230,7 @@ func (t *Tunnel) start(req *StartRequest) error { if apiToken == "" { return xerrors.New("missing api token") } - var header http.Header + header := make(http.Header) for _, h := range req.GetHeaders() { header.Add(h.GetName(), h.GetValue()) } diff --git a/vpn/tunnel_internal_test.go b/vpn/tunnel_internal_test.go index 0110ce58ab..6cd18085ab 100644 --- a/vpn/tunnel_internal_test.go +++ b/vpn/tunnel_internal_test.go @@ -100,6 +100,9 @@ func TestTunnel_StartStop(t *testing.T) { TunnelFileDescriptor: 2, CoderUrl: "https://coder.example.com", ApiToken: "fakeToken", + Headers: []*StartRequest_Header{ + {Name: "X-Test-Header", Value: "test"}, + }, }, }, })