ing
This commit is contained in:
parent
23ee90a233
commit
451f005f75
|
@ -16,9 +16,6 @@ import (
|
|||
"github.com/google/gopacket/layers"
|
||||
)
|
||||
|
||||
var totalCount = 0
|
||||
var count = 0
|
||||
|
||||
func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) error {
|
||||
ps := discoverySession.PCapScanner()
|
||||
if nil == ps {
|
||||
|
@ -28,13 +25,7 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) err
|
|||
tcpChan := ps.OpenTCP(targetHost.Address)
|
||||
defer func() {
|
||||
ps.CloseTCP(targetHost.Address, tcpChan)
|
||||
count = count - 1
|
||||
log.Print("TCP -Count: ", count)
|
||||
}()
|
||||
count = count + 1
|
||||
log.Print("TCP +Count: ", count)
|
||||
totalCount = totalCount + 1
|
||||
log.Print("TCP Total Count: ", totalCount)
|
||||
|
||||
timerStopped := make(chan struct{})
|
||||
stopChan := make(chan struct{})
|
||||
|
@ -46,6 +37,8 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) err
|
|||
var delay atomic.Value
|
||||
delay.Store(false)
|
||||
ticker := time.NewTicker(time.Millisecond * 1000)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case packet, ok := <-tcpChan:
|
||||
|
@ -58,7 +51,7 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) err
|
|||
}
|
||||
case <-ticker.C:
|
||||
if false == delay.Load().(bool) {
|
||||
ticker.Stop()
|
||||
log.Print("SYN Timeout IP ", targetHost.Address)
|
||||
timerStopped <- struct{}{}
|
||||
return
|
||||
}
|
||||
|
@ -128,6 +121,8 @@ func handlePacketTCP4(discoverySession session.DiscoverySession, host *omd.Host,
|
|||
|
||||
dp := discoverySession.DiscoverPort()
|
||||
|
||||
log.Print("SYN HandlePacket IP ", host.Address)
|
||||
|
||||
if packet.SYN && packet.ACK {
|
||||
port := int(packet.SrcPort)
|
||||
|
||||
|
|
|
@ -128,6 +128,10 @@ func handlePacketTCP(ps *pCapScan, packet gopacket.Packet) {
|
|||
layer := packet.Layer(layers.LayerTypeTCP)
|
||||
tcp, _ := layer.(*layers.TCP)
|
||||
|
||||
if !tcp.SYN || !tcp.ACK {
|
||||
return
|
||||
}
|
||||
|
||||
ps.tcpListenerChanMtx.RLock()
|
||||
defer func() {
|
||||
ps.tcpListenerChanMtx.RUnlock()
|
||||
|
|
Loading…
Reference in New Issue
Block a user