ing
This commit is contained in:
parent
4c5ca04b8e
commit
126472bc2d
|
@ -75,6 +75,26 @@ func Test_ofDiscoverer_DiscoverHost(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
// b, _ := json.Marshal(__test.Zone())
|
||||
// log.Print(string(b))
|
||||
|
||||
// b, _ = json.Marshal(__test.DiscoverHost(
|
||||
// __test.DiscoveryConfig(),
|
||||
// 1,
|
||||
// 254,
|
||||
// __test.DiscoverPort(
|
||||
// nil,
|
||||
// 1,
|
||||
// 65535,
|
||||
// true,
|
||||
// false,
|
||||
// __test.DiscoverService(
|
||||
// nil,
|
||||
// ),
|
||||
// ),
|
||||
// ))
|
||||
// log.Print(string(b))
|
||||
|
||||
i.DiscoverHost(
|
||||
"testRequesterID",
|
||||
__test.Zone(),
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
od "git.loafle.net/overflow/di-go"
|
||||
omd "git.loafle.net/overflow/model/discovery"
|
||||
"git.loafle.net/overflow_scanner/probe/discovery"
|
||||
"git.loafle.net/overflow_scanner/probe/discovery/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -52,6 +53,41 @@ func (s *DiscoveryService) DestroyService() {
|
|||
}
|
||||
|
||||
func (s *DiscoveryService) DiscoverHost(requesterID string, zone *omd.Zone, dh *omd.DiscoverHost) error {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case msg, ok := <-s.Discoverer.Message():
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
switch msg.Type() {
|
||||
case types.DiscoveryMessageTypeStart:
|
||||
log.Print("Start ", msg.Data())
|
||||
case types.DiscoveryMessageTypeStop:
|
||||
log.Print("Stop ", msg.Data())
|
||||
return
|
||||
case types.DiscoveryMessageTypeQueueing:
|
||||
log.Print("Queueing ", msg.Data())
|
||||
case types.DiscoveryMessageTypeFailedQueueing:
|
||||
log.Print("FailedQueueing ", msg.Data())
|
||||
case types.DiscoveryMessageTypeTimeout:
|
||||
log.Print("Timeout ", msg.Data())
|
||||
case types.DiscoveryMessageTypeError:
|
||||
log.Print("Error ", msg.Error())
|
||||
case types.DiscoveryMessageTypeHost:
|
||||
log.Print("Host ", msg.Data())
|
||||
case types.DiscoveryMessageTypePort:
|
||||
log.Print("Port ", msg.Data())
|
||||
case types.DiscoveryMessageTypeService:
|
||||
log.Print("Service ", msg.Data())
|
||||
default:
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
s.Discoverer.DiscoverHost(requesterID, zone, dh)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user