ing
This commit is contained in:
parent
b3a85b5e26
commit
97184ea723
|
@ -1,7 +1,6 @@
|
|||
package __test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
omd "git.loafle.net/overflow/model/discovery"
|
||||
|
@ -23,31 +22,33 @@ const (
|
|||
// )
|
||||
|
||||
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_NETWORK, ZONE_ADDRESS),
|
||||
Mac: ZONE_MAC,
|
||||
}
|
||||
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),
|
||||
)
|
||||
}
|
||||
|
||||
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", ZONE_NETWORK, address),
|
||||
Mac: mac,
|
||||
Zone: Zone(),
|
||||
}
|
||||
h := omd.NewHost(
|
||||
Zone(),
|
||||
omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||
fmt.Sprintf("%s.%s", ZONE_NETWORK, address),
|
||||
)
|
||||
h.Name = hostName
|
||||
h.Mac = mac
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
func Port(host *omd.Host, port string) *omd.Port {
|
||||
return &omd.Port{
|
||||
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||
PortNumber: json.Number(port),
|
||||
Host: host,
|
||||
}
|
||||
func Port(host *omd.Host, port int) *omd.Port {
|
||||
return omd.NewPort(
|
||||
host,
|
||||
omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||
port,
|
||||
)
|
||||
}
|
||||
|
||||
func DiscoveryConfig() *omd.DiscoveryConfig {
|
||||
|
|
|
@ -130,13 +130,13 @@ func handlePacketARP(zone *omd.Zone, targetHosts []net.IP, hosts map[string]*omd
|
|||
return nil
|
||||
}
|
||||
|
||||
h := &omd.Host{
|
||||
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||
Address: ip.String(),
|
||||
Mac: net.HardwareAddr(packet.SourceHwAddress).String(),
|
||||
Zone: zone,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
}
|
||||
h := omd.NewHost(
|
||||
zone,
|
||||
omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||
ip.String(),
|
||||
)
|
||||
h.Mac = net.HardwareAddr(packet.SourceHwAddress).String()
|
||||
h.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
hosts[ip.String()] = h
|
||||
|
||||
|
|
|
@ -171,13 +171,13 @@ func handlePacketICMP4(zone *omd.Zone, targetHosts []net.IP, hosts map[string]*o
|
|||
return nil
|
||||
}
|
||||
|
||||
h := &omd.Host{
|
||||
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||
Address: ip.String(),
|
||||
Mac: net.HardwareAddr(ethLayer.SrcMAC).String(),
|
||||
Zone: zone,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
}
|
||||
h := omd.NewHost(
|
||||
zone,
|
||||
omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||
ip.String(),
|
||||
)
|
||||
h.Mac = ethLayer.SrcMAC.String()
|
||||
h.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
hosts[ip.String()] = h
|
||||
|
||||
|
|
|
@ -156,13 +156,13 @@ func handlePacketICMP6(zone *omd.Zone, targetHosts []net.IP, hosts map[string]*o
|
|||
return nil
|
||||
}
|
||||
|
||||
h := &omd.Host{
|
||||
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV6),
|
||||
Address: ip.String(),
|
||||
Mac: net.HardwareAddr(ethLayer.SrcMAC).String(),
|
||||
Zone: zone,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
}
|
||||
h := omd.NewHost(
|
||||
zone,
|
||||
omm.ToMetaIPType(omm.MetaIPTypeEnumV6),
|
||||
ip.String(),
|
||||
)
|
||||
h.Mac = ethLayer.SrcMAC.String()
|
||||
h.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
hosts[ip.String()] = h
|
||||
|
||||
|
|
|
@ -2,10 +2,8 @@ package mdns
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
@ -66,15 +64,17 @@ SERVICE_LOOP:
|
|||
switch metaIPTypeEnum {
|
||||
case omm.MetaIPTypeEnumV4:
|
||||
for _, ipv4 := range entry.AddrIPv4 {
|
||||
h := discoverySession.AddHost(
|
||||
h := omd.NewHost(
|
||||
discoverySession.Zone(),
|
||||
omm.ToMetaIPType(metaIPTypeEnum),
|
||||
ipv4.String(),
|
||||
)
|
||||
h.Name = hostName
|
||||
h.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
h = discoverySession.AddHost(
|
||||
"mDNS",
|
||||
&omd.Host{
|
||||
MetaIPType: omm.ToMetaIPType(metaIPTypeEnum),
|
||||
Name: hostName,
|
||||
Address: ipv4.String(),
|
||||
Zone: discoverySession.Zone(),
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
h,
|
||||
meta,
|
||||
)
|
||||
|
||||
|
@ -82,41 +82,47 @@ SERVICE_LOOP:
|
|||
continue ENTRY_LOOP
|
||||
}
|
||||
|
||||
p := discoverySession.AddPort(
|
||||
p := omd.NewPort(
|
||||
h,
|
||||
metaPortType,
|
||||
port,
|
||||
)
|
||||
p.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
p = discoverySession.AddPort(
|
||||
"mDNS",
|
||||
&omd.Port{
|
||||
MetaPortType: metaPortType,
|
||||
PortNumber: json.Number(strconv.Itoa(port)),
|
||||
Host: h,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
p,
|
||||
meta,
|
||||
)
|
||||
|
||||
s := omd.NewService(
|
||||
p,
|
||||
metaCryptoType,
|
||||
serviceName,
|
||||
)
|
||||
s.Name = name
|
||||
s.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
discoverySession.AddService(
|
||||
"mDNS",
|
||||
&omd.Service{
|
||||
MetaCryptoType: metaCryptoType,
|
||||
Key: serviceName,
|
||||
Name: name,
|
||||
Port: p,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
s,
|
||||
meta,
|
||||
)
|
||||
}
|
||||
|
||||
case omm.MetaIPTypeEnumV6:
|
||||
for _, ipv6 := range entry.AddrIPv6 {
|
||||
h := discoverySession.AddHost(
|
||||
h := omd.NewHost(
|
||||
discoverySession.Zone(),
|
||||
omm.ToMetaIPType(metaIPTypeEnum),
|
||||
ipv6.String(),
|
||||
)
|
||||
h.Name = hostName
|
||||
h.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
h = discoverySession.AddHost(
|
||||
"mDNS",
|
||||
&omd.Host{
|
||||
MetaIPType: omm.ToMetaIPType(metaIPTypeEnum),
|
||||
Name: hostName,
|
||||
Address: ipv6.String(),
|
||||
Zone: discoverySession.Zone(),
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
h,
|
||||
meta,
|
||||
)
|
||||
|
||||
|
@ -124,26 +130,30 @@ SERVICE_LOOP:
|
|||
continue ENTRY_LOOP
|
||||
}
|
||||
|
||||
p := discoverySession.AddPort(
|
||||
p := omd.NewPort(
|
||||
h,
|
||||
metaPortType,
|
||||
port,
|
||||
)
|
||||
p.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
p = discoverySession.AddPort(
|
||||
"mDNS",
|
||||
&omd.Port{
|
||||
MetaPortType: metaPortType,
|
||||
PortNumber: json.Number(strconv.Itoa(port)),
|
||||
Host: h,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
p,
|
||||
meta,
|
||||
)
|
||||
|
||||
s := omd.NewService(
|
||||
p,
|
||||
metaCryptoType,
|
||||
serviceName,
|
||||
)
|
||||
s.Name = name
|
||||
s.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
discoverySession.AddService(
|
||||
"mDNS",
|
||||
&omd.Service{
|
||||
MetaCryptoType: metaCryptoType,
|
||||
Key: serviceName,
|
||||
Name: name,
|
||||
Port: p,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
s,
|
||||
meta,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package snmp
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
@ -12,6 +12,7 @@ import (
|
|||
omd "git.loafle.net/overflow/model/discovery"
|
||||
omm "git.loafle.net/overflow/model/meta"
|
||||
omu "git.loafle.net/overflow/model/util"
|
||||
ouej "git.loafle.net/overflow/util-go/encoding/json"
|
||||
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
||||
"github.com/k-sone/snmpgo"
|
||||
)
|
||||
|
@ -94,8 +95,12 @@ func Scan(discoverySession session.DiscoverySession) error {
|
|||
}
|
||||
|
||||
func scanV2(target net.IP, discoverySession session.DiscoverySession, credential *omcc.SNMPCredential) bool {
|
||||
|
||||
address := fmt.Sprintf("%s:%s", target.String(), credential.Port.String())
|
||||
portNumber, err := ouej.NumberToInt(credential.Port)
|
||||
if nil != err {
|
||||
log.Print(err)
|
||||
return false
|
||||
}
|
||||
address := net.JoinHostPort(target.String(), credential.Port.String())
|
||||
timeout, _ := credential.Timeout.Int64()
|
||||
snmp, err := snmpgo.NewSNMP(snmpgo.SNMPArguments{
|
||||
Version: snmpgo.V2c,
|
||||
|
@ -138,40 +143,47 @@ func scanV2(target net.IP, discoverySession session.DiscoverySession, credential
|
|||
meta[val.Oid.String()] = val.Variable.String()
|
||||
}
|
||||
|
||||
h := discoverySession.AddHost(
|
||||
h := omd.NewHost(
|
||||
discoverySession.Zone(),
|
||||
discoverySession.Zone().MetaIPType,
|
||||
target.String(),
|
||||
)
|
||||
h.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
h = discoverySession.AddHost(
|
||||
"SNMP V2c",
|
||||
&omd.Host{
|
||||
MetaIPType: discoverySession.Zone().MetaIPType,
|
||||
Name: "",
|
||||
Address: target.String(),
|
||||
Zone: discoverySession.Zone(),
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
h,
|
||||
meta,
|
||||
)
|
||||
|
||||
p := discoverySession.AddPort("SNMP V2c",
|
||||
&omd.Port{
|
||||
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumUDP),
|
||||
PortNumber: credential.Port,
|
||||
Host: h,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
p := omd.NewPort(
|
||||
h,
|
||||
omm.ToMetaPortType(omm.MetaPortTypeEnumUDP),
|
||||
portNumber,
|
||||
)
|
||||
p.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
p = discoverySession.AddPort(
|
||||
"SNMP V2c",
|
||||
p,
|
||||
meta,
|
||||
)
|
||||
|
||||
discoverySession.AddService("SNMP V2c",
|
||||
&omd.Service{
|
||||
MetaCryptoType: omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumNONE),
|
||||
Key: "SNMP",
|
||||
Name: "SNMP V2c",
|
||||
Port: p,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
s := omd.NewService(
|
||||
p,
|
||||
omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumNONE),
|
||||
"SNMP",
|
||||
)
|
||||
s.Name = "SNMP V2c"
|
||||
s.ServiceType = omm.MetaServiceTypeEnumMonitoring.String()
|
||||
s.ServiceVersion = "2c"
|
||||
s.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
discoverySession.AddService(
|
||||
"SNMP V2c",
|
||||
s,
|
||||
meta,
|
||||
)
|
||||
|
||||
// log.Printf("Host: %v, Port: %v, Service: %v", h, p, s)
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package connection
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
|
@ -93,12 +92,12 @@ func tryConnect(discoverySession session.DiscoverySession, ports map[int]*omd.Po
|
|||
return
|
||||
}
|
||||
|
||||
p := &omd.Port{
|
||||
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||
PortNumber: json.Number(strconv.Itoa(port)),
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
}
|
||||
p.Host = targetHost
|
||||
p := omd.NewPort(
|
||||
targetHost,
|
||||
omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||
port,
|
||||
)
|
||||
p.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
ports[port] = p
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package syn
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
|
@ -129,12 +127,12 @@ func handlePacketTCP4(discoverySession session.DiscoverySession, host *omd.Host,
|
|||
}
|
||||
// olog.Logger().Debug("Discovery", zap.String("ip", host.Address), zap.Int("port", port))
|
||||
|
||||
p := &omd.Port{
|
||||
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||
PortNumber: json.Number(strconv.Itoa(port)),
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
}
|
||||
p.Host = host
|
||||
p := omd.NewPort(
|
||||
host,
|
||||
omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||
port,
|
||||
)
|
||||
p.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
ports[port] = p
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package connection
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
|
@ -93,12 +92,12 @@ func tryConnect(discoverySession session.DiscoverySession, ports map[int]*omd.Po
|
|||
return
|
||||
}
|
||||
|
||||
p := &omd.Port{
|
||||
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||
PortNumber: json.Number(strconv.Itoa(port)),
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
}
|
||||
p.Host = targetHost
|
||||
p := omd.NewPort(
|
||||
targetHost,
|
||||
omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||
port,
|
||||
)
|
||||
p.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
ports[port] = p
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package matcher
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
|
@ -145,13 +143,14 @@ func handlePacketUDP4(discoverySession session.DiscoverySession, host *omd.Host,
|
|||
return nil
|
||||
}
|
||||
|
||||
p := &omd.Port{
|
||||
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumUDP),
|
||||
PortNumber: json.Number(strconv.Itoa(port)),
|
||||
UDPLayer: udpLayer,
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
}
|
||||
p.Host = host
|
||||
p := omd.NewPort(
|
||||
host,
|
||||
omm.ToMetaPortType(omm.MetaPortTypeEnumUDP),
|
||||
port,
|
||||
)
|
||||
p.DiscoveredDate = omu.NowPtr()
|
||||
p.UDPLayer = udpLayer
|
||||
|
||||
ports[port] = p
|
||||
|
||||
return p
|
||||
|
|
|
@ -28,15 +28,17 @@ LOOP:
|
|||
continue LOOP
|
||||
}
|
||||
|
||||
h := omd.NewHost(
|
||||
discoverySession.Zone(),
|
||||
discoverySession.Zone().MetaIPType,
|
||||
rd.PresentationURL.URL.Host,
|
||||
)
|
||||
h.Name = rd.FriendlyName
|
||||
h.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
discoverySession.AddHost(
|
||||
"UPnP",
|
||||
&omd.Host{
|
||||
MetaIPType: discoverySession.Zone().MetaIPType,
|
||||
Name: rd.FriendlyName,
|
||||
Address: rd.PresentationURL.URL.Host,
|
||||
Zone: discoverySession.Zone(),
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
},
|
||||
h,
|
||||
map[string]string{
|
||||
"DeviceType": rd.DeviceType,
|
||||
"Manufacturer": rd.Manufacturer,
|
||||
|
|
|
@ -181,6 +181,7 @@ func (ds *ofDiscoverySession) InitWithRequest(request types.DiscoveryRequest) er
|
|||
ds.pCapScanner = _pCapScanner
|
||||
log.Print("Privileged mode")
|
||||
} else {
|
||||
log.Print(err)
|
||||
log.Print("Unprivileged mode")
|
||||
}
|
||||
|
||||
|
@ -243,18 +244,18 @@ func (ds *ofDiscoverySession) AddHost(discoveredBy string, host *omd.Host, meta
|
|||
modified = true
|
||||
}
|
||||
|
||||
if "HOST" == h.DeviceType && "" != host.DeviceType {
|
||||
h.DeviceType = host.DeviceType
|
||||
if omd.DefaultHostType == h.HostType && "" != host.HostType {
|
||||
h.HostType = host.HostType
|
||||
modified = true
|
||||
}
|
||||
|
||||
if h.DeviceVendor != host.DeviceVendor {
|
||||
h.DeviceVendor = host.DeviceVendor
|
||||
if omd.DefaultHostVendor == h.HostVendor && "" != host.HostVendor {
|
||||
h.HostVendor = host.HostVendor
|
||||
modified = true
|
||||
}
|
||||
|
||||
if h.DeviceModel != host.DeviceModel {
|
||||
h.DeviceModel = host.DeviceModel
|
||||
if omd.DefaultHostModel == h.HostModel && "" != host.HostModel {
|
||||
h.HostModel = host.HostModel
|
||||
modified = true
|
||||
}
|
||||
|
||||
|
@ -313,6 +314,21 @@ func (ds *ofDiscoverySession) AddService(discoveredBy string, service *omd.Servi
|
|||
|
||||
s, modified := ds.findService(service)
|
||||
|
||||
if omd.DefaultServiceType == s.ServiceType && "" != service.ServiceType {
|
||||
s.ServiceType = service.ServiceType
|
||||
modified = true
|
||||
}
|
||||
|
||||
if omd.DefaultServiceVendor == s.ServiceVendor && "" != service.ServiceVendor {
|
||||
s.ServiceVendor = service.ServiceVendor
|
||||
modified = true
|
||||
}
|
||||
|
||||
if omd.DefaultServiceVersion == s.ServiceVersion && "" != service.ServiceVersion {
|
||||
s.ServiceVersion = service.ServiceVersion
|
||||
modified = true
|
||||
}
|
||||
|
||||
discoveredBys, discoveredByModified := ds.appendDiscoveredBy(discoveredBy, s.DiscoveredBy)
|
||||
if discoveredByModified {
|
||||
s.DiscoveredBy = discoveredBys
|
||||
|
@ -422,11 +438,11 @@ func (ds *ofDiscoverySession) findHost(host *omd.Host) (h *omd.Host, modified bo
|
|||
modified = false
|
||||
var ok bool
|
||||
|
||||
if "" == host.DeviceType {
|
||||
host.DeviceType = "HOST"
|
||||
if "" == host.HostType {
|
||||
host.HostType = omd.DefaultHostType
|
||||
}
|
||||
if "" == host.OsType {
|
||||
host.OsType = "UNKNOWN"
|
||||
host.OsType = omd.DefaultOsType
|
||||
}
|
||||
|
||||
h, ok = ds.hosts[host.Address]
|
||||
|
@ -535,15 +551,15 @@ func (ds *ofDiscoverySession) addtionalHostMDNS(host *omd.Host, meta map[string]
|
|||
|
||||
_vendor, ok := meta["vendor"]
|
||||
if ok || "" != _vendor {
|
||||
h.DeviceVendor = _vendor
|
||||
h.HostVendor = _vendor
|
||||
modified = true
|
||||
}
|
||||
|
||||
_model, ok := meta["model"]
|
||||
if ok || "" != _model {
|
||||
h.DeviceModel = _model
|
||||
h.HostModel = _model
|
||||
if "Synology" == _vendor && strings.Contains(_model, "DS1817+") {
|
||||
h.DeviceType = "NAS"
|
||||
h.HostType = "NAS"
|
||||
}
|
||||
modified = true
|
||||
}
|
||||
|
@ -590,16 +606,16 @@ func (ds *ofDiscoverySession) addtionalServiceMDNS(service *omd.Service, meta ma
|
|||
case 515:
|
||||
if "printer" == service.Key {
|
||||
_h := service.Port.Host
|
||||
_h.DeviceType = "PRINTER"
|
||||
_h.HostType = "PRINTER"
|
||||
_h.Name = service.Name
|
||||
ds.AddHost("mDNS", _h, nil)
|
||||
ds.delegate(_h)
|
||||
}
|
||||
case 9100:
|
||||
if "pdl-datastream" == service.Key {
|
||||
_h := service.Port.Host
|
||||
_h.DeviceType = "PRINTER"
|
||||
_h.HostType = "PRINTER"
|
||||
_h.Name = service.Name
|
||||
ds.AddHost("mDNS", _h, nil)
|
||||
ds.delegate(_h)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,16 +77,20 @@ LOOP:
|
|||
}
|
||||
|
||||
if nil != discoveredMatcher {
|
||||
// log.Printf("discovered matcher: %s(%s) %v", discoveredMatcher.Name(), discoveredMatcher.Key(), discoveredMatcher)
|
||||
go discoverySession.AddService(
|
||||
s := omd.NewService(
|
||||
targetPort,
|
||||
discoveredConnector.metaCryptoType(),
|
||||
discoveredMatcher.Key(),
|
||||
)
|
||||
s.Name = discoveredMatcher.Name(matchCtx)
|
||||
s.ServiceType = discoveredMatcher.Type()
|
||||
s.ServiceVendor = discoveredMatcher.Vendor(matchCtx)
|
||||
s.ServiceVersion = discoveredMatcher.Version(matchCtx)
|
||||
s.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
discoverySession.AddService(
|
||||
"Service Matcher",
|
||||
&omd.Service{
|
||||
MetaCryptoType: discoveredConnector.metaCryptoType(),
|
||||
Key: discoveredMatcher.Key(),
|
||||
Name: discoveredMatcher.Name(matchCtx),
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
Port: targetPort,
|
||||
},
|
||||
s,
|
||||
matchCtx.GetAttributes(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -25,15 +25,22 @@ func scanUDP(discoverySession session.DiscoverySession, targetPort *omd.Port) er
|
|||
p := osm.NewPacket(targetPort.UDPLayer.LayerPayload(), len(targetPort.UDPLayer.LayerPayload()))
|
||||
|
||||
if err := _matcher.Match(matchCtx, 0, p); err == nil {
|
||||
s := &omd.Service{
|
||||
Key: _matcher.Key(),
|
||||
Name: _matcher.Name(matchCtx),
|
||||
Port: targetPort,
|
||||
MetaCryptoType: omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumNONE),
|
||||
DiscoveredDate: omu.NowPtr(),
|
||||
}
|
||||
s := omd.NewService(
|
||||
targetPort,
|
||||
omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumNONE),
|
||||
_matcher.Key(),
|
||||
)
|
||||
s.Name = _matcher.Name(matchCtx)
|
||||
s.ServiceType = _matcher.Type()
|
||||
s.ServiceVendor = _matcher.Vendor(matchCtx)
|
||||
s.ServiceVersion = _matcher.Version(matchCtx)
|
||||
s.DiscoveredDate = omu.NowPtr()
|
||||
|
||||
go discoverySession.AddService("Service Matcher", s, matchCtx.GetAttributes())
|
||||
discoverySession.AddService(
|
||||
"Service Matcher",
|
||||
s,
|
||||
matchCtx.GetAttributes(),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user