probe/__test/test.go

75 lines
2.0 KiB
Go
Raw Normal View History

2018-09-01 06:07:15 +00:00
package __test
import (
"encoding/json"
"fmt"
omd "git.loafle.net/overflow/model/discovery"
omm "git.loafle.net/overflow/model/meta"
)
const (
ZONE_NETWORK = "192.168.1"
ZONE_IFACE = "enp3s0"
ZONE_ADDRESS = "101"
ZONE_MAC = "44:8a:5b:f1:f1:f3"
)
func Zone() *omd.Zone {
return &omd.Zone{
Network: fmt.Sprintf("%s.0/24", ZONE_NETWORK),
Iface: ZONE_IFACE,
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
Address: fmt.Sprintf("%s.$s", ZONE_ADDRESS),
Mac: ZONE_MAC,
}
}
func Host(hostName string, address string, mac string) *omd.Host {
return &omd.Host{
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
Name: hostName,
Address: fmt.Sprintf("%s.$s", address),
Mac: mac,
Zone: Zone(),
}
}
func Port(host *omd.Host, port string) *omd.Port {
return &omd.Port{
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
PortNumber: json.Number(port),
Host: host,
}
}
func DiscoveryConfig() *omd.DiscoveryConfig {
return &omd.DiscoveryConfig{}
}
func DiscoverHost(discoveryConfig *omd.DiscoveryConfig, firstScanRange int, lastScanRange int, discoverPort *omd.DiscoverPort) *omd.DiscoverHost {
return &omd.DiscoverHost{
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
FirstScanRange: fmt.Sprintf("%s.%d", ZONE_NETWORK, firstScanRange),
LastScanRange: fmt.Sprintf("%s.%d", ZONE_NETWORK, lastScanRange),
DiscoveryConfig: discoveryConfig,
DiscoverPort: discoverPort,
}
}
func DiscoverPort(discoveryConfig *omd.DiscoveryConfig, firstScanRange int, lastScanRange int, includeTCP bool, includeUDP bool, discoverService *omd.DiscoverService) *omd.DiscoverPort {
return &omd.DiscoverPort{
FirstScanRange: firstScanRange,
LastScanRange: lastScanRange,
IncludeTCP: includeTCP,
IncludeUDP: includeUDP,
DiscoverService: discoverService,
}
}
func DiscoverService(discoveryConfig *omd.DiscoveryConfig) *omd.DiscoverService {
return &omd.DiscoverService{
DiscoveryConfig: discoveryConfig,
}
}