diff --git a/net/model/zone.go b/net/model/zone.go index fb928f6..958b441 100644 --- a/net/model/zone.go +++ b/net/model/zone.go @@ -2,8 +2,8 @@ package model type DiscoveryZone struct { ID int `json:"id,omitempty"` + Network string `json:"network"` IP string `json:"ip"` - Netmask string `json:"netmask"` Iface string `json:"iface"` Mac string `json:"mac"` FirstScanRange int64 `json:"firstScanRange"` diff --git a/net/zone.go b/net/zone.go index b56fc80..efb6c4b 100644 --- a/net/zone.go +++ b/net/zone.go @@ -2,6 +2,7 @@ package net import "net" import "git.loafle.net/overflow/overflow_discovery/net/model" +import "strings" func ScanZone(endChan chan<- bool, zoneChan chan<- *model.DiscoveryZone, logChan chan<- error) { var err error @@ -25,7 +26,7 @@ func ScanZone(endChan chan<- bool, zoneChan chan<- *model.DiscoveryZone, logChan } for _, addr := range addrs { - // log.Printf("addr: %s", addr.String()) + if _, ipnet, err = net.ParseCIDR(addr.String()); nil != err { logChan <- err continue @@ -34,13 +35,13 @@ func ScanZone(endChan chan<- bool, zoneChan chan<- *model.DiscoveryZone, logChan continue } - // log.Printf("zone: %s", ipnet.String()) zones = append(zones, ipnet) dz := &model.DiscoveryZone{ - Iface: i.Name, - Mac: i.HardwareAddr.String(), - IP: ipnet.IP.String(), + Network: ipnet.String(), + Iface: i.Name, + Mac: i.HardwareAddr.String(), + IP: strings.Split(addr.String(), "/")[0], } zoneChan <- dz