probe/discovery/session/mock-discovery-session.go

44 lines
1.2 KiB
Go
Raw Normal View History

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-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-11 07:59:21 +00:00
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)
}
2018-08-29 12:04:23 +00:00
2018-09-11 07:59:21 +00:00
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)
}
2018-08-29 12:04:23 +00:00
2018-09-11 07:59:21 +00:00
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)
}