ing
This commit is contained in:
parent
b9ac5b2a71
commit
1aa43cf403
|
@ -56,20 +56,23 @@ func Test_ofDiscoverer_DiscoverHost(t *testing.T) {
|
|||
if !ok {
|
||||
return
|
||||
}
|
||||
switch msg.Type() {
|
||||
|
||||
_, messageType, data, _ := msg()
|
||||
|
||||
switch messageType {
|
||||
case types.DiscoveryMessageTypeHost:
|
||||
log.Print("Discovered Host: ", msg.Data())
|
||||
log.Print("Discovered Host: ", data)
|
||||
case types.DiscoveryMessageTypePort:
|
||||
log.Print("Discovered Port: ", msg.Data(), " Host: ", msg.Data().(*omd.Port).Host)
|
||||
log.Print("Discovered Port: ", data, " Host: ", data.(*omd.Port).Host)
|
||||
case types.DiscoveryMessageTypeService:
|
||||
log.Print("Discovered Service: ", msg.Data(), " Port: ", msg.Data().(*omd.Service).Port, " Host: ", msg.Data().(*omd.Service).Port.Host)
|
||||
log.Print("Discovered Service: ", data, " Port: ", data.(*omd.Service).Port, " Host: ", data.(*omd.Service).Port.Host)
|
||||
case types.DiscoveryMessageTypeStart:
|
||||
log.Print("Discovery start: ", msg.Data())
|
||||
log.Print("Discovery start: ", data)
|
||||
case types.DiscoveryMessageTypeStop:
|
||||
log.Print("Discovery stop: ", msg.Data())
|
||||
log.Print("Discovery stop: ", data)
|
||||
close(stopChan)
|
||||
default:
|
||||
// log.Print(msg.Data())
|
||||
// log.Print(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -384,35 +387,35 @@ func Test_ofDiscoverer_handleRequest(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func Test_ofDiscoverer_discover(t *testing.T) {
|
||||
type fields struct {
|
||||
stopChan chan struct{}
|
||||
stopWg sync.WaitGroup
|
||||
requestQueue chan types.DiscoveryRequest
|
||||
messageChan chan types.DiscoveryMessage
|
||||
}
|
||||
type args struct {
|
||||
req types.DiscoveryRequest
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
d := &ofDiscoverer{
|
||||
stopChan: tt.fields.stopChan,
|
||||
stopWg: tt.fields.stopWg,
|
||||
requestQueue: tt.fields.requestQueue,
|
||||
messageChan: tt.fields.messageChan,
|
||||
}
|
||||
d.discover(tt.args.req)
|
||||
})
|
||||
}
|
||||
}
|
||||
// func Test_ofDiscoverer_discover(t *testing.T) {
|
||||
// type fields struct {
|
||||
// stopChan chan struct{}
|
||||
// stopWg sync.WaitGroup
|
||||
// requestQueue chan types.DiscoveryRequest
|
||||
// messageChan chan types.DiscoveryMessage
|
||||
// }
|
||||
// type args struct {
|
||||
// req types.DiscoveryRequest
|
||||
// }
|
||||
// tests := []struct {
|
||||
// name string
|
||||
// fields fields
|
||||
// args args
|
||||
// }{
|
||||
// // TODO: Add test cases.
|
||||
// }
|
||||
// for _, tt := range tests {
|
||||
// t.Run(tt.name, func(t *testing.T) {
|
||||
// d := &ofDiscoverer{
|
||||
// stopChan: tt.fields.stopChan,
|
||||
// stopWg: tt.fields.stopWg,
|
||||
// requestQueue: tt.fields.requestQueue,
|
||||
// messageChan: tt.fields.messageChan,
|
||||
// }
|
||||
// d.discover(tt.args.req)
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
|
||||
func Test_ofDiscoverer_complexDiscover(t *testing.T) {
|
||||
type fields struct {
|
||||
|
|
|
@ -38,7 +38,7 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) err
|
|||
|
||||
var delay atomic.Value
|
||||
delay.Store(false)
|
||||
ticker := time.NewTicker(time.Millisecond * 500)
|
||||
ticker := time.NewTicker(time.Millisecond * 1000)
|
||||
for {
|
||||
select {
|
||||
case packet, ok := <-tcpChan:
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/google/gopacket/pcap"
|
||||
deadlock "github.com/sasha-s/go-deadlock"
|
||||
)
|
||||
|
||||
func NewPCapScanner(zone *omd.Zone) PCapScanner {
|
||||
|
@ -49,24 +48,19 @@ type pCapScan struct {
|
|||
pCapHandle *pcap.Handle
|
||||
zone *omd.Zone
|
||||
|
||||
// arpListenerChanMtx sync.RWMutex
|
||||
arpListenerChanMtx deadlock.RWMutex
|
||||
arpListenerChanMtx sync.RWMutex
|
||||
arpListenerChans []chan *layers.ARP
|
||||
|
||||
// icmp4ListenerChanMtx sync.RWMutex
|
||||
icmp4ListenerChanMtx deadlock.RWMutex
|
||||
icmp4ListenerChanMtx sync.RWMutex
|
||||
icmp4ListenerChans []chan gopacket.Packet
|
||||
|
||||
// icmp6ListenerChanMtx sync.RWMutex
|
||||
icmp6ListenerChanMtx deadlock.RWMutex
|
||||
icmp6ListenerChanMtx sync.RWMutex
|
||||
icmp6ListenerChans []chan gopacket.Packet
|
||||
|
||||
// tcpListenerChanMtx sync.RWMutex
|
||||
tcpListenerChanMtx deadlock.RWMutex
|
||||
tcpListenerChanMtx sync.RWMutex
|
||||
tcpListenerChans map[string][]chan *layers.TCP
|
||||
|
||||
// udpListenerChanMtx sync.RWMutex
|
||||
udpListenerChanMtx deadlock.RWMutex
|
||||
udpListenerChanMtx sync.RWMutex
|
||||
udpListenerChans map[string][]chan gopacket.Packet
|
||||
|
||||
refCount int
|
||||
|
|
Loading…
Reference in New Issue
Block a user