This commit is contained in:
crusader 2017-10-20 18:20:13 +09:00
parent cb7a0cea64
commit 1481ab4a7f
2 changed files with 7 additions and 6 deletions

View File

@ -2,8 +2,8 @@ package model
type DiscoveryZone struct { type DiscoveryZone struct {
ID int `json:"id,omitempty"` ID int `json:"id,omitempty"`
Network string `json:"network"`
IP string `json:"ip"` IP string `json:"ip"`
Netmask string `json:"netmask"`
Iface string `json:"iface"` Iface string `json:"iface"`
Mac string `json:"mac"` Mac string `json:"mac"`
FirstScanRange int64 `json:"firstScanRange"` FirstScanRange int64 `json:"firstScanRange"`

View File

@ -2,6 +2,7 @@ package net
import "net" import "net"
import "git.loafle.net/overflow/overflow_discovery/net/model" import "git.loafle.net/overflow/overflow_discovery/net/model"
import "strings"
func ScanZone(endChan chan<- bool, zoneChan chan<- *model.DiscoveryZone, logChan chan<- error) { func ScanZone(endChan chan<- bool, zoneChan chan<- *model.DiscoveryZone, logChan chan<- error) {
var err error var err error
@ -25,7 +26,7 @@ func ScanZone(endChan chan<- bool, zoneChan chan<- *model.DiscoveryZone, logChan
} }
for _, addr := range addrs { for _, addr := range addrs {
// log.Printf("addr: %s", addr.String())
if _, ipnet, err = net.ParseCIDR(addr.String()); nil != err { if _, ipnet, err = net.ParseCIDR(addr.String()); nil != err {
logChan <- err logChan <- err
continue continue
@ -34,13 +35,13 @@ func ScanZone(endChan chan<- bool, zoneChan chan<- *model.DiscoveryZone, logChan
continue continue
} }
// log.Printf("zone: %s", ipnet.String())
zones = append(zones, ipnet) zones = append(zones, ipnet)
dz := &model.DiscoveryZone{ dz := &model.DiscoveryZone{
Network: ipnet.String(),
Iface: i.Name, Iface: i.Name,
Mac: i.HardwareAddr.String(), Mac: i.HardwareAddr.String(),
IP: ipnet.IP.String(), IP: strings.Split(addr.String(), "/")[0],
} }
zoneChan <- dz zoneChan <- dz