From 2345777e4719ae31b482bb6aac11c6e7c3015643 Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 4 Jun 2018 20:56:19 +0900 Subject: [PATCH] ing --- Gopkg.lock | 2 +- internal/discoverer/discoverer.go | 3 ++- internal/discoverer/discoverer_test.go | 6 +++--- service/DiscoveryService.go | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index cb4a645..f0c5440 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -34,7 +34,7 @@ "protocol/json", "registry" ] - revision = "1092f7a7ae44ef2f907579af217f1a594e48959c" + revision = "dcc3af07239b3f6fcbae3529bcb52c522b02053d" [[projects]] branch = "master" diff --git a/internal/discoverer/discoverer.go b/internal/discoverer/discoverer.go index dcf37b7..e359a54 100644 --- a/internal/discoverer/discoverer.go +++ b/internal/discoverer/discoverer.go @@ -43,6 +43,7 @@ func GetDiscoverer() Discoverer { type Discoverer interface { Retain() chan *DiscoveryData Release(dataChan chan *DiscoveryData) + Stop() DiscoverZone(dataChan chan *DiscoveryData, dz *ocmd.DiscoverZone) DiscoverHost(dataChan chan *DiscoveryData, zone *ocmd.Zone, dh *ocmd.DiscoverHost) DiscoverPort(dataChan chan *DiscoveryData, host *ocmd.Host, dp *ocmd.DiscoverPort) @@ -67,7 +68,7 @@ func (d *defaultDiscoverer) Release(dataChan chan *DiscoveryData) { d.dataChanPool <- dataChan } -func (d *defaultDiscoverer) Stop(dataChan chan *DiscoveryData) { +func (d *defaultDiscoverer) Stop() { if nil != d.stopChan { close(d.stopChan) d.stopChan = nil diff --git a/internal/discoverer/discoverer_test.go b/internal/discoverer/discoverer_test.go index 1d1a4b2..c552815 100644 --- a/internal/discoverer/discoverer_test.go +++ b/internal/discoverer/discoverer_test.go @@ -75,13 +75,13 @@ var ( "UNKNOWN", "SSH", "WMI", - "SNMP", + "SNMP V3", }, } dha = &ocmd.DiscoverHost{ - FirstScanRangeV4: "192.168.1.1", - LastScanRangeV4: "192.168.1.254", + FirstScanRangeV4: "192.168.1.0", + LastScanRangeV4: "192.168.1.255", DiscoverPort: &ocmd.DiscoverPort{ FirstScanRange: 1, LastScanRange: 50000, diff --git a/service/DiscoveryService.go b/service/DiscoveryService.go index 68ae452..82bb9cb 100644 --- a/service/DiscoveryService.go +++ b/service/DiscoveryService.go @@ -85,7 +85,7 @@ func (s *DiscoveryService) DiscoverService(requesterID string, port *ocmd.Port, return nil } -func (s *DiscoveryService) StopRequest(requesterID string) error { +func (s *DiscoveryService) StopDiscovery(requesterID string) error { _stopChan, ok := s.pendingDiscovery.Load(requesterID) if !ok { return fmt.Errorf("discovery request for [%s] is not exist", requesterID) @@ -152,6 +152,7 @@ func (s *DiscoveryService) handleDiscovery(requesterID string, discoveryFunc fun } data.Release() case <-stopChan: + s.discoverer.Stop() return nil } }