This commit is contained in:
crusader 2018-09-28 17:46:05 +09:00
parent d50a6608c0
commit e1f698cc1c

View File

@ -34,16 +34,14 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) err
go func() { go func() {
defer func() { defer func() {
close(timerStopped) close(timerStopped)
log.Print("timer close:", targetHost.Address)
}() }()
ports := make(map[int]*omd.Port) ports := make(map[int]*omd.Port)
var delay atomic.Value var delay atomic.Value
delay.Store(false) delay.Store(false)
ticker := time.NewTicker(time.Millisecond * 3000) ticker := time.NewTicker(time.Millisecond * 20000)
defer func() { defer func() {
ticker.Stop() ticker.Stop()
log.Print("ticker stop:", targetHost.Address)
}() }()
for { for {
@ -89,6 +87,7 @@ func sendTCP4(discoverySession session.DiscoverySession, ps pcap.PCapScanner, ho
} }
buf := gopacket.NewSerializeBuffer() buf := gopacket.NewSerializeBuffer()
startTime := time.Now()
Loop: Loop:
for portNumber := dp.FirstScanRange; portNumber < dp.LastScanRange; portNumber++ { for portNumber := dp.FirstScanRange; portNumber < dp.LastScanRange; portNumber++ {
@ -107,18 +106,20 @@ Loop:
if err := gopacket.SerializeLayers(buf, tcpPacket.Opts, tcpPacket.Eth, tcpPacket.IP, tcpPacket.TCP); err != nil { if err := gopacket.SerializeLayers(buf, tcpPacket.Opts, tcpPacket.Eth, tcpPacket.IP, tcpPacket.TCP); err != nil {
return err return err
} }
if err := ps.WritePacketData(buf.Bytes()); err != nil { if err := ps.WritePacketData(buf.Bytes()); err != nil {
return err return err
} }
select { select {
// case <-time.After(time.Microsecond * 10): case <-time.After(time.Microsecond * 100):
case <-stopChan: case <-stopChan:
return nil return nil
default:
} }
} }
log.Print("IP:", host.Address, " t:", time.Since(startTime))
return nil return nil
} }