This commit is contained in:
crusader 2018-09-04 01:11:58 +09:00
parent 4c5ca04b8e
commit 126472bc2d
2 changed files with 56 additions and 0 deletions

View File

@ -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( i.DiscoverHost(
"testRequesterID", "testRequesterID",
__test.Zone(), __test.Zone(),

View File

@ -8,6 +8,7 @@ import (
od "git.loafle.net/overflow/di-go" od "git.loafle.net/overflow/di-go"
omd "git.loafle.net/overflow/model/discovery" omd "git.loafle.net/overflow/model/discovery"
"git.loafle.net/overflow_scanner/probe/discovery" "git.loafle.net/overflow_scanner/probe/discovery"
"git.loafle.net/overflow_scanner/probe/discovery/types"
) )
func init() { func init() {
@ -52,6 +53,41 @@ func (s *DiscoveryService) DestroyService() {
} }
func (s *DiscoveryService) DiscoverHost(requesterID string, zone *omd.Zone, dh *omd.DiscoverHost) error { 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) s.Discoverer.DiscoverHost(requesterID, zone, dh)
return nil return nil
} }