From 1481ab4a7fa55df5cd3fd2f953b826f99eed3e93 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 20 Oct 2017 18:20:13 +0900 Subject: [PATCH] ing --- net/model/zone.go | 2 +- net/zone.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) 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