probe/discovery/session/mock-discovery-session.go
crusader b3e58106a9 ing
2018-09-17 23:18:49 +09:00

45 lines
1.3 KiB
Go

package session
import (
"encoding/json"
"log"
omd "git.loafle.net/overflow/model/discovery"
omm "git.loafle.net/overflow/model/meta"
"git.loafle.net/overflow_scanner/probe/discovery/types"
)
func NewMockDiscoverySession(requesterID string, discoveryRequestType types.DiscoveryRequestType, params ...interface{}) DiscoverySession {
s := &mockDiscoverySession{}
s.InitWithRequest(
types.NewMockDiscoveryRequest(
requesterID,
discoveryRequestType,
params...,
),
)
return s
}
type mockDiscoverySession struct {
ofDiscoverySession
}
func (ds *mockDiscoverySession) AddHost(discoveredBy *omm.MetaDiscovererType, host *omd.Host, meta map[string]string) *omd.Host {
b, _ := json.Marshal(host)
log.Print("Host: ", string(b))
return ds.ofDiscoverySession.AddHost(discoveredBy, host, meta)
}
func (ds *mockDiscoverySession) AddPort(discoveredBy *omm.MetaDiscovererType, port *omd.Port, meta map[string]string) *omd.Port {
b, _ := json.Marshal(port)
log.Print("Port: ", string(b))
return ds.ofDiscoverySession.AddPort(discoveredBy, port, meta)
}
func (ds *mockDiscoverySession) AddService(discoveredBy *omm.MetaDiscovererType, service *omd.Service, meta map[string]string) *omd.Service {
b, _ := json.Marshal(service)
log.Print("Service: ", string(b))
return ds.ofDiscoverySession.AddService(discoveredBy, service, meta)
}