ing
This commit is contained in:
parent
c59c3ed31b
commit
f5e37136e0
|
@ -24,20 +24,20 @@ func DiscoveryDestroy() {
|
||||||
discoverer = nil
|
discoverer = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DiscoverZone(dz *discoveryM.DiscoveryZone) {
|
func DiscoverZone(requesterID string, dz *discoveryM.DiscoveryZone) {
|
||||||
discoverer.discoverZone(dz)
|
discoverer.discoverZone(requesterID, dz)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DiscoverHost(zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) {
|
func DiscoverHost(requesterID string, zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) {
|
||||||
discoverer.discoverHost(zone, dh)
|
discoverer.discoverHost(requesterID, zone, dh)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DiscoverPort(host *discoveryM.Host, dp *discoveryM.DiscoveryPort) {
|
func DiscoverPort(requesterID string, host *discoveryM.Host, dp *discoveryM.DiscoveryPort) {
|
||||||
discoverer.discoverPort(host, dp)
|
discoverer.discoverPort(requesterID, host, dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DiscoverService(port *discoveryM.Port, ds *discoveryM.DiscoveryService) {
|
func DiscoverService(requesterID string, port *discoveryM.Port, ds *discoveryM.DiscoveryService) {
|
||||||
discoverer.discoverService(port, ds)
|
discoverer.discoverService(requesterID, port, ds)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Stop() {
|
func Stop() {
|
||||||
|
@ -74,7 +74,7 @@ func (d *discovery) stop() {
|
||||||
logging.Logger().Info(fmt.Sprintf("Discovery: discovery is stopped"))
|
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,
|
go taskScan(d,
|
||||||
func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) {
|
func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) {
|
||||||
scanZone(dz, resultChan, errChan, doneChan, stopChan)
|
scanZone(dz, resultChan, errChan, doneChan, stopChan)
|
||||||
|
@ -82,7 +82,7 @@ func (d *discovery) discoverZone(dz *discoveryM.DiscoveryZone) {
|
||||||
func(result interface{}) {
|
func(result interface{}) {
|
||||||
z := result.(*discoveryM.Zone)
|
z := result.(*discoveryM.Zone)
|
||||||
logging.Logger().Info(fmt.Sprintf("zone: %v", z))
|
logging.Logger().Info(fmt.Sprintf("zone: %v", z))
|
||||||
d.sendResult("DiscoveryService.DiscoveredZone", z)
|
d.sendResult("DiscoveryService.DiscoveredZone", requesterID, z)
|
||||||
if nil != dz.DiscoveryHost {
|
if nil != dz.DiscoveryHost {
|
||||||
cr, _ := cidr.NewCIDRRanger(z.Network)
|
cr, _ := cidr.NewCIDRRanger(z.Network)
|
||||||
dh := &discoveryM.DiscoveryHost{
|
dh := &discoveryM.DiscoveryHost{
|
||||||
|
@ -90,13 +90,13 @@ func (d *discovery) discoverZone(dz *discoveryM.DiscoveryZone) {
|
||||||
LastScanRange: cr.Last().String(),
|
LastScanRange: cr.Last().String(),
|
||||||
DiscoveryPort: dz.DiscoveryHost.DiscoveryPort,
|
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,
|
go taskScan(d,
|
||||||
func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) {
|
func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) {
|
||||||
scanHost(zone, dh, resultChan, errChan, doneChan, stopChan)
|
scanHost(zone, dh, resultChan, errChan, doneChan, stopChan)
|
||||||
|
@ -104,15 +104,15 @@ func (d *discovery) discoverHost(zone *discoveryM.Zone, dh *discoveryM.Discovery
|
||||||
func(result interface{}) {
|
func(result interface{}) {
|
||||||
h := result.(*discoveryM.Host)
|
h := result.(*discoveryM.Host)
|
||||||
logging.Logger().Info(fmt.Sprintf("host: %v", h))
|
logging.Logger().Info(fmt.Sprintf("host: %v", h))
|
||||||
d.sendResult("DiscoveryService.DiscoveredHost", h)
|
d.sendResult("DiscoveryService.DiscoveredHost", requesterID, h)
|
||||||
if nil != dh.DiscoveryPort {
|
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,
|
go taskScan(d,
|
||||||
func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) {
|
func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) {
|
||||||
scanPort(host, dp, resultChan, errChan, doneChan, stopChan)
|
scanPort(host, dp, resultChan, errChan, doneChan, stopChan)
|
||||||
|
@ -120,22 +120,22 @@ func (d *discovery) discoverPort(host *discoveryM.Host, dp *discoveryM.Discovery
|
||||||
func(result interface{}) {
|
func(result interface{}) {
|
||||||
p := result.(*discoveryM.Port)
|
p := result.(*discoveryM.Port)
|
||||||
logging.Logger().Info(fmt.Sprintf("port: %v", p))
|
logging.Logger().Info(fmt.Sprintf("port: %v", p))
|
||||||
d.sendResult("DiscoveryService.DiscoveredPort", p)
|
d.sendResult("DiscoveryService.DiscoveredPort", requesterID, p)
|
||||||
if nil != dp.DiscoveryService {
|
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,
|
go taskScan(d,
|
||||||
func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) {
|
func(resultChan chan interface{}, errChan chan error, doneChan chan struct{}, stopChan chan struct{}) {
|
||||||
scanService(port, ds, resultChan, errChan, doneChan, stopChan)
|
scanService(port, ds, resultChan, errChan, doneChan, stopChan)
|
||||||
},
|
},
|
||||||
func(result interface{}) {
|
func(result interface{}) {
|
||||||
s := result.(*discoveryM.Service)
|
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))
|
logging.Logger().Info(fmt.Sprintf("service: %s(%s)[%s:%s]", s.ServiceName, s.CryptoType, port.Host.IP, port.PortNumber))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,24 +8,24 @@ import (
|
||||||
type DiscoveryService struct {
|
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
|
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
|
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
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user