ing
This commit is contained in:
parent
cb7a0cea64
commit
1481ab4a7f
|
@ -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"`
|
||||
|
|
11
net/zone.go
11
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user