ing
This commit is contained in:
parent
218c4c050c
commit
2345777e47
2
Gopkg.lock
generated
2
Gopkg.lock
generated
|
@ -34,7 +34,7 @@
|
|||
"protocol/json",
|
||||
"registry"
|
||||
]
|
||||
revision = "1092f7a7ae44ef2f907579af217f1a594e48959c"
|
||||
revision = "dcc3af07239b3f6fcbae3529bcb52c522b02053d"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user