send discovery mode msg
This commit is contained in:
parent
7db69d4551
commit
03ec5c7b74
|
@ -193,6 +193,12 @@ func (d *ofDiscoverer) discover(req types.DiscoveryRequest, s session.DiscoveryS
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.Privileged() {
|
||||||
|
d.SendMessage(req, types.DiscoveryMessageTypeMode, "Privileged")
|
||||||
|
} else {
|
||||||
|
d.SendMessage(req, types.DiscoveryMessageTypeMode, "Unprivileged")
|
||||||
|
}
|
||||||
|
|
||||||
d.complexDiscover(s)
|
d.complexDiscover(s)
|
||||||
d.hierarchyDiscover(s)
|
d.hierarchyDiscover(s)
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ type DiscoverySession interface {
|
||||||
DiscoveredService(port *omd.Port, name string) *omd.Service
|
DiscoveredService(port *omd.Port, name string) *omd.Service
|
||||||
DiscoveredServices(port *omd.Port) map[string]*omd.Service
|
DiscoveredServices(port *omd.Port) map[string]*omd.Service
|
||||||
DiscoveredAllServices() map[*omd.Port]map[string]*omd.Service
|
DiscoveredAllServices() map[*omd.Port]map[string]*omd.Service
|
||||||
|
Privileged() bool
|
||||||
|
|
||||||
Shutdown()
|
Shutdown()
|
||||||
StopChan() <-chan struct{}
|
StopChan() <-chan struct{}
|
||||||
|
@ -84,6 +85,7 @@ type ofDiscoverySession struct {
|
||||||
includeMachosts map[string]*omd.Host
|
includeMachosts map[string]*omd.Host
|
||||||
ports map[*omd.Host]map[json.Number]map[string]*omd.Port
|
ports map[*omd.Host]map[json.Number]map[string]*omd.Port
|
||||||
services map[*omd.Port]map[string]*omd.Service
|
services map[*omd.Port]map[string]*omd.Service
|
||||||
|
privileged bool
|
||||||
|
|
||||||
stopChan chan struct{}
|
stopChan chan struct{}
|
||||||
}
|
}
|
||||||
|
@ -191,9 +193,11 @@ func (ds *ofDiscoverySession) InitWithRequest(request types.DiscoveryRequest) er
|
||||||
_pCapScanner := pcap.NewPCapScanner(ds.zone)
|
_pCapScanner := pcap.NewPCapScanner(ds.zone)
|
||||||
if err := _pCapScanner.Start(); nil == err {
|
if err := _pCapScanner.Start(); nil == err {
|
||||||
ds.pCapScanner = _pCapScanner
|
ds.pCapScanner = _pCapScanner
|
||||||
|
ds.privileged = true
|
||||||
log.Print("Privileged mode")
|
log.Print("Privileged mode")
|
||||||
} else {
|
} else {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
|
ds.privileged = false
|
||||||
log.Print("Unprivileged mode")
|
log.Print("Unprivileged mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +208,10 @@ func (ds *ofDiscoverySession) PCapScanner() pcap.PCapScanner {
|
||||||
return ds.pCapScanner
|
return ds.pCapScanner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ds *ofDiscoverySession) Privileged() bool {
|
||||||
|
return ds.privileged
|
||||||
|
}
|
||||||
|
|
||||||
func (ds *ofDiscoverySession) SetDiscoveryDelegator(discoveryDelegator chan<- interface{}) {
|
func (ds *ofDiscoverySession) SetDiscoveryDelegator(discoveryDelegator chan<- interface{}) {
|
||||||
ds.discoveryDelegator = discoveryDelegator
|
ds.discoveryDelegator = discoveryDelegator
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ const (
|
||||||
DiscoveryMessageTypeQueueing
|
DiscoveryMessageTypeQueueing
|
||||||
DiscoveryMessageTypeQueueingFailed
|
DiscoveryMessageTypeQueueingFailed
|
||||||
DiscoveryMessageTypeQueueingTimeout
|
DiscoveryMessageTypeQueueingTimeout
|
||||||
|
DiscoveryMessageTypeMode
|
||||||
DiscoveryMessageTypeStart
|
DiscoveryMessageTypeStart
|
||||||
DiscoveryMessageTypeStop
|
DiscoveryMessageTypeStop
|
||||||
DiscoveryMessageTypeError
|
DiscoveryMessageTypeError
|
||||||
|
|
|
@ -72,7 +72,16 @@ func (s *DiscoveryService) InitService() {
|
||||||
),
|
),
|
||||||
"/scanner",
|
"/scanner",
|
||||||
)
|
)
|
||||||
// log.Print("Queueing ", data)
|
case types.DiscoveryMessageTypeMode:
|
||||||
|
s.PubSub.Pub(
|
||||||
|
rpc.MakeRPCMessage(
|
||||||
|
[]string{request.RequesterID()},
|
||||||
|
"DiscoveryService.DiscoveryMode",
|
||||||
|
datas,
|
||||||
|
),
|
||||||
|
"/scanner",
|
||||||
|
)
|
||||||
|
// log.Print("Queueing ", data)
|
||||||
case types.DiscoveryMessageTypeQueueingFailed:
|
case types.DiscoveryMessageTypeQueueingFailed:
|
||||||
s.PubSub.Pub(
|
s.PubSub.Pub(
|
||||||
rpc.MakeRPCMessage(
|
rpc.MakeRPCMessage(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user