Merge pull request #1150 from JasonYangShadow/issue/1130

add CIDR format to warewulf.conf parse
This commit is contained in:
Jonathon Anderson
2024-05-31 23:44:12 -06:00
committed by GitHub
2 changed files with 14 additions and 0 deletions

View File

@@ -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

View File

@@ -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
}