probe/discovery/session/mock-discovery-session.go
crusader d2e70072e3 ing
2018-09-11 16:59:21 +09:00

44 lines
1.2 KiB
Go

package session
import (
"encoding/json"
"log"
omd "git.loafle.net/overflow/model/discovery"
"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 string, 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 string, 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 string, 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)
}