cmd/stunstamp: fix handling of invalid DERP map resp (#12679)

Updates tailscale/corp#20344

Signed-off-by: Jordan Whited <jordan@tailscale.com>
pull/12680/head
Jordan Whited 4 months ago committed by GitHub
parent b56058d7e3
commit ddf94a7b39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -60,10 +60,13 @@ func getDERPMap(ctx context.Context, url string) (*tailcfg.DERPMap, error) {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("non-200 derp map resp: %d", resp.StatusCode)
}
dm := tailcfg.DERPMap{}
err = json.NewDecoder(resp.Body).Decode(&dm)
if err != nil {
return nil, nil
return nil, fmt.Errorf("failed to decode derp map resp: %v", err)
}
return &dm, nil
}

Loading…
Cancel
Save