Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit edd982e

Browse files
fix(vpn/tunnel): fix panic when starting tunnel with headers (#16565)
`http.Header` is a map so it needs to be initialized ..
1 parent b23e3f9 commit edd982e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

vpn/tunnel.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (t *Tunnel) start(req *StartRequest) error {
230230
if apiToken == "" {
231231
return xerrors.New("missing api token")
232232
}
233-
var header http.Header
233+
header := make(http.Header)
234234
for _, h := range req.GetHeaders() {
235235
header.Add(h.GetName(), h.GetValue())
236236
}

vpn/tunnel_internal_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ func TestTunnel_StartStop(t *testing.T) {
100100
TunnelFileDescriptor: 2,
101101
CoderUrl: "https://coder.example.com",
102102
ApiToken: "fakeToken",
103+
Headers: []*StartRequest_Header{
104+
{Name: "X-Test-Header", Value: "test"},
105+
},
103106
},
104107
},
105108
})

0 commit comments

Comments
 (0)