diff --git a/discovery/discovery.go b/discovery/discovery.go index 2c2570f..6c2ca4e 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -24,20 +24,20 @@ func DiscoveryDestroy() { discoverer = nil } -func DiscoverZone(dz *discoveryM.DiscoveryZone) { - discoverer.discoverZone(dz) +func DiscoverZone(requesterID string, dz *discoveryM.DiscoveryZone) { + discoverer.discoverZone(requesterID, dz) } -func DiscoverHost(zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) { - discoverer.discoverHost(zone, dh) +func DiscoverHost(requesterID string, zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) { + discoverer.discoverHost(requesterID, zone, dh) } -func DiscoverPort(host *discoveryM.Host, dp *discoveryM.DiscoveryPort) { - discoverer.discoverPort(host, dp) +func DiscoverPort(requesterID string, host *discoveryM.Host, dp *discoveryM.DiscoveryPort) { + discoverer.discoverPort(requesterID, host, dp) } -func DiscoverService(port *discoveryM.Port, ds *discoveryM.DiscoveryService) { - discoverer.discoverService(port, ds) +func DiscoverService(requesterID string, port *discoveryM.Port, ds *discoveryM.DiscoveryService) { + discoverer.discoverService(requesterID, port, ds) } func Stop() { @@ -74,7 +74,7 @@ func (d *discovery) stop() { logging.Logger().Info(fmt.Sprintf("Discovery: discovery is stopped")) } -func (d *discovery) discoverZone(dz *discoveryM.DiscoveryZone) { +func (d *discovery) discoverZone(requesterID string, dz *discoveryM.DiscoveryZone) { go taskScan(d, func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) { scanZone(dz, resultChan, errChan, doneChan, stopChan) @@ -82,7 +82,7 @@ func (d *discovery) discoverZone(dz *discoveryM.DiscoveryZone) { func(result interface{}) { z := result.(*discoveryM.Zone) logging.Logger().Info(fmt.Sprintf("zone: %v", z)) - d.sendResult("DiscoveryService.DiscoveredZone", z) + d.sendResult("DiscoveryService.DiscoveredZone", requesterID, z) if nil != dz.DiscoveryHost { cr, _ := cidr.NewCIDRRanger(z.Network) dh := &discoveryM.DiscoveryHost{ @@ -90,13 +90,13 @@ func (d *discovery) discoverZone(dz *discoveryM.DiscoveryZone) { LastScanRange: cr.Last().String(), DiscoveryPort: dz.DiscoveryHost.DiscoveryPort, } - d.discoverHost(z, dh) + d.discoverHost(requesterID, z, dh) } }, ) } -func (d *discovery) discoverHost(zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) { +func (d *discovery) discoverHost(requesterID string, zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) { go taskScan(d, func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) { scanHost(zone, dh, resultChan, errChan, doneChan, stopChan) @@ -104,15 +104,15 @@ func (d *discovery) discoverHost(zone *discoveryM.Zone, dh *discoveryM.Discovery func(result interface{}) { h := result.(*discoveryM.Host) logging.Logger().Info(fmt.Sprintf("host: %v", h)) - d.sendResult("DiscoveryService.DiscoveredHost", h) + d.sendResult("DiscoveryService.DiscoveredHost", requesterID, h) if nil != dh.DiscoveryPort { - d.discoverPort(h, dh.DiscoveryPort) + d.discoverPort(requesterID, h, dh.DiscoveryPort) } }, ) } -func (d *discovery) discoverPort(host *discoveryM.Host, dp *discoveryM.DiscoveryPort) { +func (d *discovery) discoverPort(requesterID string, host *discoveryM.Host, dp *discoveryM.DiscoveryPort) { go taskScan(d, func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) { scanPort(host, dp, resultChan, errChan, doneChan, stopChan) @@ -120,22 +120,22 @@ func (d *discovery) discoverPort(host *discoveryM.Host, dp *discoveryM.Discovery func(result interface{}) { p := result.(*discoveryM.Port) logging.Logger().Info(fmt.Sprintf("port: %v", p)) - d.sendResult("DiscoveryService.DiscoveredPort", p) + d.sendResult("DiscoveryService.DiscoveredPort", requesterID, p) if nil != dp.DiscoveryService { - d.discoverService(p, dp.DiscoveryService) + d.discoverService(requesterID, p, dp.DiscoveryService) } }, ) } -func (d *discovery) discoverService(port *discoveryM.Port, ds *discoveryM.DiscoveryService) { +func (d *discovery) discoverService(requesterID string, port *discoveryM.Port, ds *discoveryM.DiscoveryService) { go taskScan(d, func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) { scanService(port, ds, resultChan, errChan, doneChan, stopChan) }, func(result interface{}) { s := result.(*discoveryM.Service) - d.sendResult("DiscoveryService.DiscoveredService", s) + d.sendResult("DiscoveryService.DiscoveredService", requesterID, s) logging.Logger().Info(fmt.Sprintf("service: %s(%s)[%s:%s]", s.ServiceName, s.CryptoType, port.Host.IP, port.PortNumber)) }, ) diff --git a/service/DiscoveryService.go b/service/DiscoveryService.go index 24500cb..c65bc99 100644 --- a/service/DiscoveryService.go +++ b/service/DiscoveryService.go @@ -8,24 +8,24 @@ import ( type DiscoveryService struct { } -func (ds *DiscoveryService) DiscoverZone(dz *discoveryM.DiscoveryZone) error { +func (ds *DiscoveryService) DiscoverZone(requesterID string, dz *discoveryM.DiscoveryZone) error { - discovery.DiscoverZone(dz) + discovery.DiscoverZone(requesterID, dz) return nil } -func (ds *DiscoveryService) DiscoverHost(zone *discoveryM.Zone, dz *discoveryM.DiscoveryHost) error { +func (ds *DiscoveryService) DiscoverHost(requesterID string, zone *discoveryM.Zone, dz *discoveryM.DiscoveryHost) error { return nil } -func (ds *DiscoveryService) DiscoverPort(host *discoveryM.Host, dz *discoveryM.DiscoveryPort) error { +func (ds *DiscoveryService) DiscoverPort(requesterID string, host *discoveryM.Host, dz *discoveryM.DiscoveryPort) error { return nil } -func (ds *DiscoveryService) DiscoverService(port *discoveryM.Port, dz *discoveryM.DiscoveryService) error { +func (ds *DiscoveryService) DiscoverService(requesterID string, port *discoveryM.Port, dz *discoveryM.DiscoveryService) error { return nil }