probe/__test/test.go

114 lines
2.7 KiB
Go
Raw Normal View History

2018-09-01 06:07:15 +00:00
package __test
import (
"fmt"
2018-10-08 12:49:37 +00:00
"strings"
2018-09-01 06:07:15 +00:00
omd "git.loafle.net/overflow/model/discovery"
omm "git.loafle.net/overflow/model/meta"
)
2018-09-21 16:18:59 +00:00
// const (
// ZONE_NETWORK = "192.168.1"
// ZONE_IFACE = "enp3s0"
// ZONE_ADDRESS = "101"
// ZONE_MAC = "44:8a:5b:f1:f1:f3"
// )
2018-09-01 06:07:15 +00:00
2018-09-03 10:33:20 +00:00
// const (
// ZONE_NETWORK = "192.168.1"
// ZONE_IFACE = "\\Device\\NPF_{1924FA2B-6927-4BA5-AF43-876C3F8853CE}"
// ZONE_ADDRESS = "103"
// ZONE_MAC = "30:9C:23:15:A3:09"
// )
2018-09-17 16:25:56 +00:00
// const (
// ZONE_NETWORK = "192.168.35"
// ZONE_IFACE = "wlp5s0"
// ZONE_ADDRESS = "234"
// ZONE_MAC = "d0:7e:35:da:26:68"
// )
2018-09-13 16:14:34 +00:00
2018-09-28 07:13:45 +00:00
// const (
// ZONE_NETWORK = "192.168.35"
// ZONE_IFACE = "\\Device\\NPF_{51459A06-A513-4202-9D79-93A4E394566A}"
// ZONE_ADDRESS = "179"
// ZONE_MAC = "08:00:27:f0:dc:35"
// )
2018-09-21 16:18:59 +00:00
const (
2018-09-28 07:13:45 +00:00
ZONE_NETWORK = "192.168.1"
ZONE_IFACE = "\\Device\\NPF_{9A232FAC-6AA4-48CE-AAC8-878ABFBFDA5D}"
ZONE_ADDRESS = "221"
ZONE_MAC = "54-04-A6-38-BE-DA"
2018-09-21 16:18:59 +00:00
)
2018-09-01 06:07:15 +00:00
func Zone() *omd.Zone {
2018-10-08 12:49:37 +00:00
strings.Builder
2018-09-12 04:55:51 +00:00
return omd.NewZone(
ZONE_IFACE,
ZONE_MAC,
omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
fmt.Sprintf("%s.0/24", ZONE_NETWORK),
fmt.Sprintf("%s.%s", ZONE_NETWORK, ZONE_ADDRESS),
)
2018-09-01 06:07:15 +00:00
}
func Host(hostName string, address string, mac string) *omd.Host {
2018-09-12 04:55:51 +00:00
h := omd.NewHost(
Zone(),
omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
fmt.Sprintf("%s.%s", ZONE_NETWORK, address),
)
h.Name = hostName
h.Mac = mac
return h
2018-09-01 06:07:15 +00:00
}
2018-09-12 04:55:51 +00:00
func Port(host *omd.Host, port int) *omd.Port {
return omd.NewPort(
host,
omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
port,
)
2018-09-01 06:07:15 +00:00
}
2018-09-17 23:08:58 +00:00
func Service(port *omd.Port, metaCryptoTypeEnum omm.MetaCryptoTypeEnum, key string) *omd.Service {
return omd.NewService(
port,
omm.ToMetaCryptoType(metaCryptoTypeEnum),
key,
)
}
2018-09-01 06:07:15 +00:00
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,
}
}