add error handling to dynamic network configuration

This commit is contained in:
Matt Jolly
2023-09-07 18:52:34 +10:00
parent f1eab8c363
commit 0364f1c9ca
3 changed files with 6 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add EL9 Quickstart guide to index.rst
- Container file gids are now updated properly during syncuser. #840
- Fix build for API.
- Add error handling to `wwctl`'s dynamic IP configuration attempt.
### Changed

View File

@@ -27,3 +27,4 @@
* Jeffrey Frey @jtfrey
* Xu Yang(Jason Yang) <jasonyangshadow@gmail.com> @JasonYangShadow
* Arnaud LECOMTE <contact@arnaud-lcm.com>
* Matt Jolly <Matt.Jolly@footclan.ninja>

View File

@@ -119,7 +119,10 @@ func (conf *RootConf) SetDynamicDefaults() (err error) {
if conf.Ipaddr == "" {
wwlog.Verbose("Configuration has no valid network, going to dynamic values")
conn, _ := net.Dial("udp", "8.8.8.8:80")
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
return errors.Wrap(err, "Couldn't establish a connection to remote")
}
defer conn.Close()
ipaddr = conn.LocalAddr().(*net.UDPAddr).IP
mask = ipaddr.DefaultMask()