From 235a059d9b02bdc7c7242fb4d30de34644af0cb0 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 13 Jun 2018 19:38:34 +0900 Subject: [PATCH] ing --- internal/discoverer/discoverer_test.go | 30 +++++++++++++++----------- internal/discoverer/ipv4/host.go | 2 ++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/internal/discoverer/discoverer_test.go b/internal/discoverer/discoverer_test.go index c552815..ae242d7 100644 --- a/internal/discoverer/discoverer_test.go +++ b/internal/discoverer/discoverer_test.go @@ -7,9 +7,9 @@ import ( "testing" logging "git.loafle.net/commons/logging-go" - occc "git.loafle.net/overflow/commons-go/core/constants" occu "git.loafle.net/overflow/commons-go/core/util" ocmd "git.loafle.net/overflow/commons-go/model/discovery" + ocmm "git.loafle.net/overflow/commons-go/model/meta" "git.loafle.net/overflow/container_discovery/internal/discoverer" ) @@ -18,19 +18,22 @@ var ( ExcludePatterns: []string{}, } z = &ocmd.Zone{ - Network: "192.168.1.0/24", - IPV4: "192.168.1.101", - Iface: "enp3s0", - Mac: "44:8a:5b:f1:f1:f3", + Network: "192.168.1.0/24", + MetaIPType: ocmm.ToMetaIPType(ocmm.MetaIPTypeEnumV4), + Address: "192.168.1.101", + Iface: "enp3s0", + Mac: "44:8a:5b:f1:f1:f3", } dh = &ocmd.DiscoverHost{ - FirstScanRangeV4: "192.168.1.1", - LastScanRangeV4: "192.168.1.254", + MetaIPType: ocmm.ToMetaIPType(ocmm.MetaIPTypeEnumV4), + FirstScanRange: "192.168.1.1", + LastScanRange: "192.168.1.254", } h = &ocmd.Host{ - Zone: z, - IPV4: "192.168.1.10", - Mac: "d0:50:99:97:5d:99", + Zone: z, + MetaIPType: ocmm.ToMetaIPType(ocmm.MetaIPTypeEnumV4), + Address: "192.168.1.10", + Mac: "d0:50:99:97:5d:99", } dp = &ocmd.DiscoverPort{ FirstScanRange: 1, @@ -43,7 +46,7 @@ var ( } p = &ocmd.Port{ Host: h, - PortType: occc.PortTypeTCP, + MetaPortType: ocmm.ToMetaPortType(ocmm.MetaPortTypeEnumTCP), PortNumber: json.Number(strconv.Itoa(80)), DiscoveredDate: occu.NowPtr(), } @@ -80,8 +83,9 @@ var ( } dha = &ocmd.DiscoverHost{ - FirstScanRangeV4: "192.168.1.0", - LastScanRangeV4: "192.168.1.255", + MetaIPType: ocmm.ToMetaIPType(ocmm.MetaIPTypeEnumV4), + FirstScanRange: "192.168.1.0", + LastScanRange: "192.168.1.255", DiscoverPort: &ocmd.DiscoverPort{ FirstScanRange: 1, LastScanRange: 50000, diff --git a/internal/discoverer/ipv4/host.go b/internal/discoverer/ipv4/host.go index 632b00c..e716fea 100644 --- a/internal/discoverer/ipv4/host.go +++ b/internal/discoverer/ipv4/host.go @@ -10,6 +10,7 @@ import ( "git.loafle.net/commons/util-go/net/cidr" occu "git.loafle.net/overflow/commons-go/core/util" ocmd "git.loafle.net/overflow/commons-go/model/discovery" + ocmm "git.loafle.net/overflow/commons-go/model/meta" "git.loafle.net/overflow/container_discovery/internal/pcap" "github.com/google/gopacket" "github.com/google/gopacket/layers" @@ -145,6 +146,7 @@ func handlePacketARP(zone *ocmd.Zone, hostRanges []net.IP, hosts map[string]*ocm } h := &ocmd.Host{ + MetaIPType: ocmm.ToMetaIPType(ocmm.MetaIPTypeEnumV4), Address: ip.String(), Mac: net.HardwareAddr(packet.SourceHwAddress).String(), Zone: zone,