This commit is contained in:
crusader 2018-04-28 01:56:47 +09:00
parent f01cb68527
commit 26da7a2e03
7 changed files with 27 additions and 27 deletions

View File

@ -154,9 +154,9 @@ func (d *defaultDiscoverer) innerDiscoverZone(wg *sync.WaitGroup, dataChan chan
if nil != dz.DiscoverHost {
cr, _ := cidr.NewCIDRRanger(z.Network)
dh := &ocmd.DiscoverHost{
FirstScanRange: cr.First().String(),
LastScanRange: cr.Last().String(),
DiscoverPort: dz.DiscoverHost.DiscoverPort,
FirstScanRangeV4: cr.First().String(),
LastScanRangeV4: cr.Last().String(),
DiscoverPort: dz.DiscoverHost.DiscoverPort,
}
wg.Add(1)
go d.innerDiscoverHost(wg, dataChan, z, dh)

View File

@ -94,9 +94,9 @@ func sendARP(ps pcap.PCapScanner, zone *ocmd.Zone, hostRanges []net.IP, stopChan
if nil != err {
return err
}
ip := net.ParseIP(zone.IP)
ip := net.ParseIP(zone.IPV4)
if nil == ip {
return fmt.Errorf("Discovery: IP(%s) of zone is not valid", zone.IP)
return fmt.Errorf("Discovery: IP(%s) of zone is not valid", zone.IPV4)
}
ethPacket := makePacketEthernet(hwAddr)
@ -146,7 +146,7 @@ func handlePacketARP(zone *ocmd.Zone, hostRanges []net.IP, hosts map[string]*ocm
}
h := &ocmd.Host{}
h.IP = ip.String()
h.IPV4 = ip.String()
h.Mac = net.HardwareAddr(packet.SourceHwAddress).String()
h.Zone = zone
@ -157,22 +157,22 @@ func handlePacketARP(zone *ocmd.Zone, hostRanges []net.IP, hosts map[string]*ocm
func getTargetHostRange(dh *ocmd.DiscoverHost, cr cidr.CIDRRanger) ([]net.IP, error) {
var firstIP net.IP
if "" != dh.FirstScanRange {
firstIP = net.ParseIP(dh.FirstScanRange)
if "" != dh.FirstScanRangeV4 {
firstIP = net.ParseIP(dh.FirstScanRangeV4)
if nil == firstIP {
return nil, fmt.Errorf("Discovery: IP(%v) of FirstScanRange host is not valid", firstIP)
}
}
var lastIP net.IP
if "" != dh.LastScanRange {
lastIP = net.ParseIP(dh.LastScanRange)
if "" != dh.LastScanRangeV4 {
lastIP = net.ParseIP(dh.LastScanRangeV4)
if nil == lastIP {
return nil, fmt.Errorf("Discovery: IP(%v) of LastScanRange host is not valid", lastIP)
}
}
includeIPs := make([]net.IP, 0)
for _, iHost := range dh.IncludeHosts {
for _, iHost := range dh.IncludeHostsV4 {
iIP := net.ParseIP(iHost)
if nil == iIP {
return nil, fmt.Errorf("Discovery: IP(%v) of include host is not valid", iHost)
@ -181,7 +181,7 @@ func getTargetHostRange(dh *ocmd.DiscoverHost, cr cidr.CIDRRanger) ([]net.IP, er
}
excludeIPs := make([]net.IP, 0)
for _, eHost := range dh.ExcludeHosts {
for _, eHost := range dh.ExcludeHostsV4 {
eIP := net.ParseIP(eHost)
if nil == eIP {
return nil, fmt.Errorf("Discovery: IP(%v) of exclude host is not valid", eHost)

View File

@ -32,9 +32,9 @@ func scanPortTCP(host *ocmd.Host, dp *ocmd.DiscoverPort, resultChan chan interfa
go pcap.ReleaseScanner(host.Zone)
}()
tcpChan := ps.OpenTCP(host.IP)
tcpChan := ps.OpenTCP(host.IPV4)
defer func() {
go ps.CloseTCP(host.IP, tcpChan)
go ps.CloseTCP(host.IPV4, tcpChan)
}()
timerStopped := make(chan struct{})
@ -133,7 +133,7 @@ func handlePacketTCP(host *ocmd.Host, dp *ocmd.DiscoverPort, ports map[int]*ocmd
}
port := int(packet.SrcPort)
logging.Logger().Debugf("Discovery: IP of TCP(%d) src %s", port, host.IP)
logging.Logger().Debugf("Discovery: IP of TCP(%d) src %s", port, host.IPV4)
if _, ok := ports[port]; ok || !dp.Contains(port) {
return nil
@ -160,13 +160,13 @@ type PortPacketTCP struct {
func makePacketPortTCP(host *ocmd.Host) (*PortPacketTCP, error) {
packetTCP := &PortPacketTCP{}
srcIP := net.ParseIP(host.Zone.IP)
srcIP := net.ParseIP(host.Zone.IPV4)
if nil == srcIP {
return nil, fmt.Errorf("Discovery: IP(%s) of zone is not valid", host.Zone.IP)
return nil, fmt.Errorf("Discovery: IP(%s) of zone is not valid", host.Zone.IPV4)
}
dstIP := net.ParseIP(host.IP)
dstIP := net.ParseIP(host.IPV4)
if nil == dstIP {
return nil, fmt.Errorf("Discovery: IP(%s) of host is not valid", host.IP)
return nil, fmt.Errorf("Discovery: IP(%s) of host is not valid", host.IPV4)
}
packetTCP.IP = &layers.IPv4{

View File

@ -33,9 +33,9 @@ func scanPortUDP(host *ocmd.Host, dp *ocmd.DiscoverPort, resultChan chan interfa
pcap.ReleaseScanner(host.Zone)
}()
udpChan := ps.OpenUDP(host.IP)
udpChan := ps.OpenUDP(host.IPV4)
defer func() {
ps.CloseUDP(host.IP, udpChan)
ps.CloseUDP(host.IPV4, udpChan)
}()
timerStopped := make(chan struct{})
@ -84,9 +84,9 @@ func scanPortUDP(host *ocmd.Host, dp *ocmd.DiscoverPort, resultChan chan interfa
}
func sendUDP(host *ocmd.Host, dp *ocmd.DiscoverPort, stopChan chan struct{}) error {
ip := net.ParseIP(host.IP)
ip := net.ParseIP(host.IPV4)
if nil == ip {
return fmt.Errorf("Discovery: IP(%s) of host is not valid", host.IP)
return fmt.Errorf("Discovery: IP(%s) of host is not valid", host.IPV4)
}
ms := matcher.GetUDPMatchers()
@ -140,7 +140,7 @@ func sendUDP(host *ocmd.Host, dp *ocmd.DiscoverPort, stopChan chan struct{}) err
func handlePacketUDP(host *ocmd.Host, dp *ocmd.DiscoverPort, ports map[int]*ocmd.Port, packet gopacket.Packet) *ocmd.Port {
ipLayer := packet.Layer(layers.LayerTypeIPv4)
if ipLayer.(*layers.IPv4).SrcIP.String() == host.Zone.IP {
if ipLayer.(*layers.IPv4).SrcIP.String() == host.Zone.IPV4 {
return nil
}

View File

@ -14,7 +14,7 @@ import (
)
func scanServiceTCP(port *ocmd.Port, ds *ocmd.DiscoverService, resultChan chan interface{}, errChan chan error, stopChan chan struct{}) bool {
hostIP := port.Host.IP
hostIP := port.Host.IPV4
portNumber, err := cuej.NumberToInt(port.PortNumber)
if err != nil {
errChan <- fmt.Errorf("Discovery: Service scan on %s:%s error has occurred %v ", hostIP, port.PortNumber, err)

View File

@ -17,7 +17,7 @@ func scanServiceUDP(port *ocmd.Port, ds *ocmd.DiscoverService, resultChan chan i
}
ms := matcher.GetUDPMatchers()
mi := csm.NewMatchInfo(port.Host.IP, portNumber)
mi := csm.NewMatchInfo(port.Host.IPV4, portNumber)
for i := 0; i < len(ms); i++ {
m := ms[i]

View File

@ -56,7 +56,7 @@ func scanZone(dz *ocmd.DiscoverZone, resultChan chan interface{}, errChan chan e
Network: ipnet.String(),
Iface: i.Name,
Mac: i.HardwareAddr.String(),
IP: strings.Split(addr.String(), "/")[0],
IPV4: strings.Split(addr.String(), "/")[0],
}
resultChan <- z