2018-08-29 12:04:23 +00:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
2018-09-11 07:59:21 +00:00
|
|
|
"encoding/json"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
omd "git.loafle.net/overflow/model/discovery"
|
2018-09-17 14:18:49 +00:00
|
|
|
omm "git.loafle.net/overflow/model/meta"
|
2018-08-31 02:32:25 +00:00
|
|
|
"git.loafle.net/overflow_scanner/probe/discovery/types"
|
2018-08-29 12:04:23 +00:00
|
|
|
)
|
|
|
|
|
2018-08-31 02:32:25 +00:00
|
|
|
func NewMockDiscoverySession(requesterID string, discoveryRequestType types.DiscoveryRequestType, params ...interface{}) DiscoverySession {
|
|
|
|
s := &mockDiscoverySession{}
|
|
|
|
s.InitWithRequest(
|
|
|
|
types.NewMockDiscoveryRequest(
|
|
|
|
requesterID,
|
|
|
|
discoveryRequestType,
|
|
|
|
params...,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
return s
|
2018-08-29 12:04:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type mockDiscoverySession struct {
|
|
|
|
ofDiscoverySession
|
|
|
|
}
|
|
|
|
|
2018-09-17 14:18:49 +00:00
|
|
|
func (ds *mockDiscoverySession) AddHost(discoveredBy *omm.MetaDiscovererType, host *omd.Host, meta map[string]string) *omd.Host {
|
2018-09-11 07:59:21 +00:00
|
|
|
b, _ := json.Marshal(host)
|
|
|
|
log.Print("Host: ", string(b))
|
|
|
|
return ds.ofDiscoverySession.AddHost(discoveredBy, host, meta)
|
|
|
|
}
|
2018-08-29 12:04:23 +00:00
|
|
|
|
2018-09-17 14:18:49 +00:00
|
|
|
func (ds *mockDiscoverySession) AddPort(discoveredBy *omm.MetaDiscovererType, port *omd.Port, meta map[string]string) *omd.Port {
|
2018-09-11 07:59:21 +00:00
|
|
|
b, _ := json.Marshal(port)
|
|
|
|
log.Print("Port: ", string(b))
|
|
|
|
return ds.ofDiscoverySession.AddPort(discoveredBy, port, meta)
|
|
|
|
}
|
2018-08-29 12:04:23 +00:00
|
|
|
|
2018-09-17 14:18:49 +00:00
|
|
|
func (ds *mockDiscoverySession) AddService(discoveredBy *omm.MetaDiscovererType, service *omd.Service, meta map[string]string) *omd.Service {
|
2018-09-11 07:59:21 +00:00
|
|
|
b, _ := json.Marshal(service)
|
|
|
|
log.Print("Service: ", string(b))
|
|
|
|
return ds.ofDiscoverySession.AddService(discoveredBy, service, meta)
|
|
|
|
}
|