ing
This commit is contained in:
parent
e107b6b207
commit
d178262d08
|
@ -25,7 +25,6 @@ type DiscoveryData struct {
|
|||
Type DiscoveryDataType
|
||||
Result interface{}
|
||||
Error error
|
||||
Time util.Timestamp
|
||||
}
|
||||
|
||||
func (dd *DiscoveryData) Release() {
|
||||
|
@ -276,7 +275,6 @@ func retainDiscoveryData(discoveryDataType DiscoveryDataType, t util.Timestamp,
|
|||
}
|
||||
|
||||
discoveryData.Type = discoveryDataType
|
||||
discoveryData.Time = t
|
||||
discoveryData.Result = result
|
||||
discoveryData.Error = err
|
||||
|
||||
|
@ -287,7 +285,6 @@ func releaseDiscoveryData(discoveryData *DiscoveryData) {
|
|||
discoveryData.Type = DiscoveryDataTypeNone
|
||||
discoveryData.Result = nil
|
||||
discoveryData.Error = nil
|
||||
discoveryData.Time = util.Timestamp{}
|
||||
|
||||
discoveryDataPool.Put(discoveryData)
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
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"
|
||||
"git.loafle.net/overflow/container_discovery/internal/discoverer"
|
||||
)
|
||||
|
@ -44,6 +45,7 @@ var (
|
|||
Host: h,
|
||||
PortType: occc.PortTypeTCP,
|
||||
PortNumber: json.Number(strconv.Itoa(80)),
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
ds = &ocmd.DiscoverService{
|
||||
IncludeServices: []string{
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
|
||||
"git.loafle.net/commons/logging-go"
|
||||
"git.loafle.net/commons/util-go/net/cidr"
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/layers"
|
||||
|
||||
occu "git.loafle.net/overflow/commons-go/core/util"
|
||||
ocmd "git.loafle.net/overflow/commons-go/model/discovery"
|
||||
"git.loafle.net/overflow/container_discovery/internal/pcap"
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/layers"
|
||||
)
|
||||
|
||||
func ScanHost(zone *ocmd.Zone, dh *ocmd.DiscoverHost, resultChan chan interface{}, errChan chan error, stopChan chan struct{}) {
|
||||
|
@ -145,10 +145,12 @@ func handlePacketARP(zone *ocmd.Zone, hostRanges []net.IP, hosts map[string]*ocm
|
|||
return nil
|
||||
}
|
||||
|
||||
h := &ocmd.Host{}
|
||||
h.IPV4 = ip.String()
|
||||
h.Mac = net.HardwareAddr(packet.SourceHwAddress).String()
|
||||
h.Zone = zone
|
||||
h := &ocmd.Host{
|
||||
IPV4: ip.String(),
|
||||
Mac: net.HardwareAddr(packet.SourceHwAddress).String(),
|
||||
Zone: zone,
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
|
||||
hosts[ip.String()] = h
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
"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"
|
||||
"git.loafle.net/overflow/container_discovery/internal/pcap"
|
||||
|
||||
|
@ -142,6 +143,7 @@ func handlePacketTCP(host *ocmd.Host, dp *ocmd.DiscoverPort, ports map[int]*ocmd
|
|||
p := &ocmd.Port{
|
||||
PortType: occc.PortTypeTCP,
|
||||
PortNumber: json.Number(strconv.Itoa(port)),
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
p.Host = host
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
"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"
|
||||
"git.loafle.net/overflow/container_discovery/internal/pcap"
|
||||
|
||||
|
@ -159,6 +160,7 @@ func handlePacketUDP(host *ocmd.Host, dp *ocmd.DiscoverPort, ports map[int]*ocmd
|
|||
PortType: occc.PortTypeUDP,
|
||||
PortNumber: json.Number(strconv.Itoa(port)),
|
||||
UDPLayer: udpLayer,
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
p.Host = host
|
||||
ports[port] = p
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
cuej "git.loafle.net/commons/util-go/encoding/json"
|
||||
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"
|
||||
"github.com/google/gopacket/layers"
|
||||
)
|
||||
|
@ -24,8 +25,9 @@ func ScanService(port *ocmd.Port, ds *ocmd.DiscoverService, resultChan chan inte
|
|||
sName := fmt.Sprintf("Not Supported Service. Perhaps %s[%d]", dName, portNumber)
|
||||
s := &ocmd.Service{
|
||||
ServiceName: sName,
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
Port: port,
|
||||
}
|
||||
s.Port = port
|
||||
resultChan <- s
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +38,9 @@ func ScanService(port *ocmd.Port, ds *ocmd.DiscoverService, resultChan chan inte
|
|||
sName := fmt.Sprintf("Not Supported Service. Perhaps %s[%d]", dName, portNumber)
|
||||
s := &ocmd.Service{
|
||||
ServiceName: sName,
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
Port: port,
|
||||
}
|
||||
s.Port = port
|
||||
resultChan <- s
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
csm "git.loafle.net/commons/service_matcher-go"
|
||||
cuej "git.loafle.net/commons/util-go/encoding/json"
|
||||
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"
|
||||
"git.loafle.net/overflow/container_discovery/internal/matcher"
|
||||
)
|
||||
|
@ -104,6 +105,7 @@ LOOP:
|
|||
s = &ocmd.Service{
|
||||
ServiceName: m.Name(),
|
||||
CryptoType: occc.ToCryptoType(sc.CryptoType()),
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
break LOOP
|
||||
}
|
||||
|
@ -155,6 +157,7 @@ LOOP:
|
|||
s = &ocmd.Service{
|
||||
ServiceName: m.Name(),
|
||||
CryptoType: occc.ToCryptoType(sc.CryptoType()),
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
break LOOP
|
||||
}
|
||||
|
@ -212,6 +215,7 @@ LOOP:
|
|||
s = &ocmd.Service{
|
||||
ServiceName: m.Name(),
|
||||
CryptoType: occc.ToCryptoType(sc.CryptoType()),
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
break
|
||||
}
|
||||
|
@ -225,6 +229,7 @@ LOOP:
|
|||
s = &ocmd.Service{
|
||||
ServiceName: m.Name(),
|
||||
CryptoType: occc.ToCryptoType(sc.CryptoType()),
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
break
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
csm "git.loafle.net/commons/service_matcher-go"
|
||||
cuej "git.loafle.net/commons/util-go/encoding/json"
|
||||
occu "git.loafle.net/overflow/commons-go/core/util"
|
||||
ocmd "git.loafle.net/overflow/commons-go/model/discovery"
|
||||
"git.loafle.net/overflow/container_discovery/internal/matcher"
|
||||
)
|
||||
|
@ -26,8 +27,10 @@ func scanServiceUDP(port *ocmd.Port, ds *ocmd.DiscoverService, resultChan chan i
|
|||
if m.Match(mi, 0, p) {
|
||||
s := &ocmd.Service{
|
||||
ServiceName: m.Name(),
|
||||
Port: port,
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
s.Port = port
|
||||
|
||||
resultChan <- s
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
occu "git.loafle.net/overflow/commons-go/core/util"
|
||||
ocmd "git.loafle.net/overflow/commons-go/model/discovery"
|
||||
)
|
||||
|
||||
|
@ -57,6 +58,7 @@ func scanZone(dz *ocmd.DiscoverZone, resultChan chan interface{}, errChan chan e
|
|||
Iface: i.Name,
|
||||
Mac: i.HardwareAddr.String(),
|
||||
IPV4: strings.Split(addr.String(), "/")[0],
|
||||
DiscoveredDate: occu.NowPtr(),
|
||||
}
|
||||
|
||||
resultChan <- z
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
cda "git.loafle.net/commons/di-go/annotation"
|
||||
cdr "git.loafle.net/commons/di-go/registry"
|
||||
occu "git.loafle.net/overflow/commons-go/core/util"
|
||||
ocmd "git.loafle.net/overflow/commons-go/model/discovery"
|
||||
ocscd "git.loafle.net/overflow/commons-go/service/container/discovery"
|
||||
ocs "git.loafle.net/overflow/container-go/service"
|
||||
|
@ -131,10 +132,10 @@ func (s *DiscoveryService) handleDiscovery(requesterID string, discoveryFunc fun
|
|||
switch data.Type {
|
||||
case discoverer.DiscoveryDataTypeStart:
|
||||
logging.Logger().Debugf("DiscoveryService.DiscoveryStart")
|
||||
s.ProbeService.Send("DiscoveryService.DiscoveryStart", requesterID, data.Time)
|
||||
s.ProbeService.Send("DiscoveryService.DiscoveryStart", requesterID, occu.Now())
|
||||
case discoverer.DiscoveryDataTypeStop:
|
||||
logging.Logger().Debugf("DiscoveryService.DiscoveryStop")
|
||||
s.ProbeService.Send("DiscoveryService.DiscoveryStop", requesterID, data.Time)
|
||||
s.ProbeService.Send("DiscoveryService.DiscoveryStop", requesterID, occu.Now())
|
||||
data.Release()
|
||||
return nil
|
||||
case discoverer.DiscoveryDataTypeError:
|
||||
|
|
Loading…
Reference in New Issue
Block a user