mirror of
https://gitgud.io/yats/cerberus.git
synced 2026-04-30 09:42:06 -04:00
Fix resp.Body not closed when >1 steps
This commit is contained in:
@@ -42,7 +42,7 @@ func solveTest(ctx context.Context, hc http.Client, host string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("Solution hash: %x, nonce: %d, remaining steps: %d\n", s.Hash, s.Nonce, s.Steps)
|
||||
log.Printf("Solution hash: %x, nonce: %d\n", s.Hash, s.Nonce)
|
||||
|
||||
resp, err := Submit(ctx, hc, s, "")
|
||||
if err != nil {
|
||||
|
||||
16
http.go
16
http.go
@@ -85,21 +85,23 @@ func Submit(ctx context.Context, hc http.Client, s Solution, redirect string) (*
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if s.Steps > 0 {
|
||||
// This feels gross, but it works.
|
||||
for s.Steps > 0 {
|
||||
resp.Body.Close()
|
||||
|
||||
c, err := NewChallenge(ctx, hc, s.host.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// maybe useful later. idk.
|
||||
// c.Steps = s.Steps
|
||||
|
||||
s, err := Solve(ctx, c)
|
||||
s, err = Solve(ctx, c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err = Submit(ctx, hc, s, redirect)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return Submit(ctx, hc, s, redirect)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
||||
Reference in New Issue
Block a user