mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-24 02:01:01 +00:00
cmd/stunstamp: fix handling of invalid DERP map resp (#12679)
Updates tailscale/corp#20344 Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
parent
b56058d7e3
commit
ddf94a7b39
@ -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…
x
Reference in New Issue
Block a user