Skip to content

Commit

Permalink
Fix network settings error when gateway empty (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
ale7714 authored Nov 11, 2024
1 parent 71acf22 commit 6078ea6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions subsystems/provisioning/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ func generateIPv4Settings(cfg NetworkConfig) (map[string]any, error) {
return nil, err
}

gateway, err := generateAddress(cfg.IPv4Gateway)
if err != nil {
return nil, err
var gateway uint32
if len(cfg.IPv4Gateway) > 0 {
gateway, err = generateAddress(cfg.IPv4Gateway)
if err != nil {
return nil, err
}
}

mask, err := strconv.ParseUint(ret[2], 10, 32)
Expand Down
6 changes: 4 additions & 2 deletions subsystems/provisioning/networkmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,11 @@ func (w *Provisioning) addOrUpdateConnection(cfg NetworkConfig) (bool, error) {
nw.isHotspot = true
settings = generateHotspotSettings(w.cfg.HotspotPrefix, w.Config().hotspotSSID, w.cfg.HotspotPassword, w.Config().HotspotInterface)
} else {
settings, err = generateNetworkSettings(w.cfg.Manufacturer+"-"+netKey, cfg)
id := w.cfg.Manufacturer + "-" + netKey
settings, err = generateNetworkSettings(id, cfg)
w.logger.Debugf("Network settings: ", settings)
if err != nil {
return changesMade, err
return changesMade, errw.Errorf("error generating network settings for %s: %v", id, err)
}
}

Expand Down
1 change: 1 addition & 0 deletions subsystems/provisioning/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ func (w *Provisioning) processAdditionalnetworks(ctx context.Context) {
_, err := w.addOrUpdateConnection(network)
if err != nil {
w.logger.Error(errw.Wrapf(err, "error adding network %s", network.SSID))
continue
}
if network.Interface != "" {
if err := w.activateConnection(ctx, network.Interface, network.SSID); err != nil {
Expand Down

0 comments on commit 6078ea6

Please sign in to comment.