Skip to content

Commit

Permalink
Merge pull request #1 from NubeIO/issue/net-mask
Browse files Browse the repository at this point in the history
Fix: net mask
  • Loading branch information
RaiBnod authored Dec 18, 2024
2 parents 677676e + 2f1cd55 commit 1bc8a9a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions networking/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ func (inst *nets) GetNetworks() (interfaces []NetworkInterfaces, err error) {
switch v := addr.(type) {
case *net.IPNet:
ip = v.IP
networkInterfaces.NetMask = net.IP(v.Mask).String()
case *net.IPAddr:
ip = v.IP
networkInterfaces.NetMask = ""
}
if ip == nil || ip.IsLoopback() {
continue
Expand All @@ -92,7 +94,6 @@ func (inst *nets) GetNetworks() (interfaces []NetworkInterfaces, err error) {
if len(mask) >= 1 {
networkInterfaces.NetMaskLength = ToInt(mask[1])
}
networkInterfaces.NetMask = ipv4MaskString(ip.DefaultMask())
networkInterfaces.Gateway, err = inst.GetGatewayIP(iface.Name)
networkInterfaces.MacAddress = iface.HardwareAddr.String()
interfaces = append(interfaces, networkInterfaces)
Expand All @@ -119,8 +120,10 @@ func (inst *nets) GetNetworksThatHaveGateway() (interfaces []NetworkInterfaces,
switch v := addr.(type) {
case *net.IPNet:
ip = v.IP
networkInterfaces.NetMask = net.IP(v.Mask).String()
case *net.IPAddr:
ip = v.IP
networkInterfaces.NetMask = ""
}
if ip == nil || ip.IsLoopback() {
continue
Expand All @@ -136,7 +139,6 @@ func (inst *nets) GetNetworksThatHaveGateway() (interfaces []NetworkInterfaces,
if len(mask) >= 1 {
networkInterfaces.NetMaskLength = ToInt(mask[1])
}
networkInterfaces.NetMask = ipv4MaskString(ip.DefaultMask())
networkInterfaces.Gateway, err = inst.GetGatewayIP(iface.Name)
networkInterfaces.MacAddress = iface.HardwareAddr.String()
if networkInterfaces.Gateway != "" {
Expand Down

0 comments on commit 1bc8a9a

Please sign in to comment.