Skip to content

Commit

Permalink
Merge pull request warewulf#1150 from JasonYangShadow/issue/1130
Browse files Browse the repository at this point in the history
add CIDR format to warewulf.conf parse
  • Loading branch information
anderbubble authored Jun 1, 2024
2 parents a9b226b + b3d8f9c commit 36a5083
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Block unprivileged requests for arbitrary overlays in secure mode. #1215
- Fix installation docs to use github.com/warewulf instead of github.com/hpcng. #1219
- Fix the issue that warewulf.conf parse does not support CIDR format. #1130

### Security

Expand Down
13 changes: 13 additions & 0 deletions internal/pkg/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ func (conf *RootConf) Parse(data []byte) error {
if len(conf.TFTP.IpxeBinaries) == 0 {
conf.TFTP.IpxeBinaries = defIpxe
}

// check whether ip addr is CIDR type and configure related fields as required
if ip, network, err := net.ParseCIDR(conf.Ipaddr); err == nil {
conf.Ipaddr = ip.String()
if conf.Network == "" {
conf.Network = network.IP.String()
}
if conf.Netmask == "" {
mask := network.Mask
conf.Netmask = fmt.Sprintf("%d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3])
}
}

return nil
}

Expand Down

0 comments on commit 36a5083

Please sign in to comment.