mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-11 02:34:43 +00:00
wgengine/wgcfg: return better errors from DeviceConfig, ReconfigDevice
Prefer the error from the actual wireguard-go device method call, not {To,From}UAPI, as those tend to be less interesting I/O errors. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
1f6c4ba7c3
commit
777c816b34
@ -20,13 +20,14 @@ func DeviceConfig(d *device.Device) (*Config, error) {
|
|||||||
w.Close()
|
w.Close()
|
||||||
}()
|
}()
|
||||||
cfg, err := FromUAPI(r)
|
cfg, err := FromUAPI(r)
|
||||||
|
// Prefer errors from IpcGetOperation.
|
||||||
|
if setErr := <-errc; setErr != nil {
|
||||||
|
return nil, setErr
|
||||||
|
}
|
||||||
|
// Check FromUAPI error.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := <-errc; err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Slice(cfg.Peers, func(i, j int) bool {
|
sort.Slice(cfg.Peers, func(i, j int) bool {
|
||||||
return cfg.Peers[i].PublicKey.LessThan(&cfg.Peers[j].PublicKey)
|
return cfg.Peers[i].PublicKey.LessThan(&cfg.Peers[j].PublicKey)
|
||||||
})
|
})
|
||||||
@ -54,9 +55,10 @@ func ReconfigDevice(d *device.Device, cfg *Config, logf logger.Logf) (err error)
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
err = cfg.ToUAPI(w, prev)
|
err = cfg.ToUAPI(w, prev)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.Close()
|
w.Close()
|
||||||
return <-errc
|
// Prefer errors from IpcSetOperation.
|
||||||
|
if setErr := <-errc; setErr != nil {
|
||||||
|
return setErr
|
||||||
|
}
|
||||||
|
return err // err (if any) from cfg.ToUAPI
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user