Fix varinterval panic if request IH is not provided

This commit is contained in:
Širhoe Biazhkovič
2021-11-26 19:21:49 +03:00
committed by Lawrence, Rendall
parent 9122aefdd7
commit 239a642bfc
6 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -172,7 +172,7 @@ func NewFrontend(logic frontend.TrackerLogic, provided Config) (*Frontend, error
}
}
if cfg.HTTPSAddr == "" || f.tlsCfg == nil {
if (cfg.HTTPSAddr == "") != (f.tlsCfg == nil) {
return nil, errors.New("must specify both https_addr, tls_cert_path and tls_key_path")
}
+2 -4
View File
@@ -21,8 +21,7 @@ func TestWriteError(t *testing.T) {
for _, tt := range table {
t.Run(fmt.Sprintf("%s expecting %s", tt.reason, tt.expected), func(t *testing.T) {
r := httptest.NewRecorder()
err := WriteError(r, bittorrent.ClientError(tt.reason))
require.Nil(t, err)
WriteError(r, bittorrent.ClientError(tt.reason))
require.Equal(t, r.Body.String(), tt.expected)
})
}
@@ -38,8 +37,7 @@ func TestWriteStatus(t *testing.T) {
for _, tt := range table {
t.Run(fmt.Sprintf("%s expecting %s", tt.reason, tt.expected), func(t *testing.T) {
r := httptest.NewRecorder()
err := WriteError(r, bittorrent.ClientError(tt.reason))
require.Nil(t, err)
WriteError(r, bittorrent.ClientError(tt.reason))
require.Equal(t, r.Body.String(), tt.expected)
})
}