ing
This commit is contained in:
parent
a84f4eab12
commit
57cb5cf1a9
|
@ -7,12 +7,12 @@ import (
|
||||||
omm "git.loafle.net/overflow/model/meta"
|
omm "git.loafle.net/overflow/model/meta"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// const (
|
||||||
ZONE_NETWORK = "192.168.1"
|
// ZONE_NETWORK = "192.168.1"
|
||||||
ZONE_IFACE = "enp3s0"
|
// ZONE_IFACE = "enp3s0"
|
||||||
ZONE_ADDRESS = "101"
|
// ZONE_ADDRESS = "101"
|
||||||
ZONE_MAC = "44:8a:5b:f1:f1:f3"
|
// ZONE_MAC = "44:8a:5b:f1:f1:f3"
|
||||||
)
|
// )
|
||||||
|
|
||||||
// const (
|
// const (
|
||||||
// ZONE_NETWORK = "192.168.1"
|
// ZONE_NETWORK = "192.168.1"
|
||||||
|
@ -21,6 +21,13 @@ const (
|
||||||
// ZONE_MAC = "30:9C:23:15:A3:09"
|
// ZONE_MAC = "30:9C:23:15:A3:09"
|
||||||
// )
|
// )
|
||||||
|
|
||||||
|
const (
|
||||||
|
ZONE_NETWORK = "192.168.35"
|
||||||
|
ZONE_IFACE = "wlp5s0"
|
||||||
|
ZONE_ADDRESS = "234"
|
||||||
|
ZONE_MAC = "d0:7e:35:da:26:68"
|
||||||
|
)
|
||||||
|
|
||||||
func Zone() *omd.Zone {
|
func Zone() *omd.Zone {
|
||||||
return omd.NewZone(
|
return omd.NewZone(
|
||||||
ZONE_IFACE,
|
ZONE_IFACE,
|
||||||
|
|
|
@ -131,7 +131,7 @@ LOOP:
|
||||||
|
|
||||||
canceled, ok := d.requestIds[req.RequestID()]
|
canceled, ok := d.requestIds[req.RequestID()]
|
||||||
delete(d.requestIds, req.RequestID())
|
delete(d.requestIds, req.RequestID())
|
||||||
if !ok || canceled {
|
if !ok || !canceled {
|
||||||
req.(*ofDiscoveryRequest).release()
|
req.(*ofDiscoveryRequest).release()
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ func (d *ofDiscoverer) hierarchyDiscover(s session.DiscoverySession) {
|
||||||
|
|
||||||
// post complexDiscover
|
// post complexDiscover
|
||||||
if nil != s.DiscoverPort() {
|
if nil != s.DiscoverPort() {
|
||||||
discoveredHosts := s.DiscoveredAllHosts(true)
|
discoveredHosts := s.DiscoveredAllHosts(false)
|
||||||
for _, h := range discoveredHosts {
|
for _, h := range discoveredHosts {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(h *omd.Host) {
|
go func(h *omd.Host) {
|
||||||
|
|
|
@ -16,6 +16,9 @@ import (
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var totalCount = 0
|
||||||
|
var count = 0
|
||||||
|
|
||||||
func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) error {
|
func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) error {
|
||||||
ps := discoverySession.PCapScanner()
|
ps := discoverySession.PCapScanner()
|
||||||
if nil == ps {
|
if nil == ps {
|
||||||
|
@ -25,7 +28,13 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) err
|
||||||
tcpChan := ps.OpenTCP(targetHost.Address)
|
tcpChan := ps.OpenTCP(targetHost.Address)
|
||||||
defer func() {
|
defer func() {
|
||||||
ps.CloseTCP(targetHost.Address, tcpChan)
|
ps.CloseTCP(targetHost.Address, tcpChan)
|
||||||
|
count = count - 1
|
||||||
|
log.Print("TCP -Count: ", count)
|
||||||
}()
|
}()
|
||||||
|
count = count + 1
|
||||||
|
log.Print("TCP +Count: ", count)
|
||||||
|
totalCount = totalCount + 1
|
||||||
|
log.Print("TCP Total Count: ", totalCount)
|
||||||
|
|
||||||
timerStopped := make(chan struct{})
|
timerStopped := make(chan struct{})
|
||||||
stopChan := make(chan struct{})
|
stopChan := make(chan struct{})
|
||||||
|
|
|
@ -2,9 +2,13 @@ package upnp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
omd "git.loafle.net/overflow/model/discovery"
|
omd "git.loafle.net/overflow/model/discovery"
|
||||||
|
omm "git.loafle.net/overflow/model/meta"
|
||||||
omu "git.loafle.net/overflow/model/util"
|
omu "git.loafle.net/overflow/model/util"
|
||||||
|
oun "git.loafle.net/overflow/util-go/net"
|
||||||
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
||||||
"github.com/huin/goupnp"
|
"github.com/huin/goupnp"
|
||||||
)
|
)
|
||||||
|
@ -20,6 +24,7 @@ func Scan(discoverySession session.DiscoverySession) error {
|
||||||
fmt.Println("DiscoverDevices: ", err)
|
fmt.Println("DiscoverDevices: ", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
metaIPTypeEnum := omm.ToMetaIPTypeEnum(discoverySession.Zone().MetaIPType)
|
||||||
|
|
||||||
LOOP:
|
LOOP:
|
||||||
for _, dev := range devs {
|
for _, dev := range devs {
|
||||||
|
@ -28,19 +33,29 @@ LOOP:
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
h := omd.NewHost(
|
pURL := rd.PresentationURL.URL
|
||||||
discoverySession.Zone(),
|
|
||||||
discoverySession.Zone().MetaIPType,
|
|
||||||
rd.PresentationURL.URL.Host,
|
|
||||||
)
|
|
||||||
h.Name = rd.FriendlyName
|
|
||||||
h.DiscoveredDate = omu.NowPtr()
|
|
||||||
|
|
||||||
discoverySession.AddHost(
|
ip := oun.ParseIP(pURL.Hostname())
|
||||||
"UPnP",
|
if nil == ip {
|
||||||
h,
|
continue LOOP
|
||||||
map[string]string{
|
}
|
||||||
|
|
||||||
|
switch metaIPTypeEnum {
|
||||||
|
case omm.MetaIPTypeEnumV4:
|
||||||
|
if 4 != ip.Version() {
|
||||||
|
continue LOOP
|
||||||
|
}
|
||||||
|
case omm.MetaIPTypeEnumV6:
|
||||||
|
if 6 != ip.Version() {
|
||||||
|
continue LOOP
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
continue LOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
meta := map[string]string{
|
||||||
"DeviceType": rd.DeviceType,
|
"DeviceType": rd.DeviceType,
|
||||||
|
"FriendlyName": rd.FriendlyName,
|
||||||
"Manufacturer": rd.Manufacturer,
|
"Manufacturer": rd.Manufacturer,
|
||||||
"ManufacturerURL": rd.ManufacturerURL.Str,
|
"ManufacturerURL": rd.ManufacturerURL.Str,
|
||||||
"ModelName": rd.ModelName,
|
"ModelName": rd.ModelName,
|
||||||
|
@ -49,7 +64,68 @@ LOOP:
|
||||||
"SerialNumber": rd.SerialNumber,
|
"SerialNumber": rd.SerialNumber,
|
||||||
"UDN": rd.UDN,
|
"UDN": rd.UDN,
|
||||||
"UPC": rd.UPC,
|
"UPC": rd.UPC,
|
||||||
},
|
}
|
||||||
|
|
||||||
|
h := omd.NewHost(
|
||||||
|
discoverySession.Zone(),
|
||||||
|
discoverySession.Zone().MetaIPType,
|
||||||
|
ip.String(),
|
||||||
|
)
|
||||||
|
h.Name = rd.ModelName
|
||||||
|
h.DiscoveredDate = omu.NowPtr()
|
||||||
|
|
||||||
|
discoverySession.AddHost(
|
||||||
|
"UPnP",
|
||||||
|
h,
|
||||||
|
meta,
|
||||||
|
)
|
||||||
|
|
||||||
|
portNumber, err := strconv.Atoi(pURL.Port())
|
||||||
|
if nil != err {
|
||||||
|
continue LOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
p := omd.NewPort(
|
||||||
|
h,
|
||||||
|
omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||||
|
portNumber,
|
||||||
|
)
|
||||||
|
p.DiscoveredDate = omu.NowPtr()
|
||||||
|
|
||||||
|
p = discoverySession.AddPort(
|
||||||
|
"UPnP",
|
||||||
|
p,
|
||||||
|
meta,
|
||||||
|
)
|
||||||
|
|
||||||
|
metaCryptoType := omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumNONE)
|
||||||
|
serviceType := omm.MetaServiceTypeEnumUNKNOWN.String()
|
||||||
|
serviceKey := "UNKNOWN"
|
||||||
|
|
||||||
|
switch strings.ToLower(pURL.Scheme) {
|
||||||
|
case "http":
|
||||||
|
serviceKey = "HTTP"
|
||||||
|
serviceType = omm.MetaServiceTypeEnumWeb.String()
|
||||||
|
case "https":
|
||||||
|
serviceKey = "HTTPS"
|
||||||
|
metaCryptoType = omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumTLS)
|
||||||
|
serviceType = omm.MetaServiceTypeEnumWeb.String()
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
s := omd.NewService(
|
||||||
|
p,
|
||||||
|
metaCryptoType,
|
||||||
|
serviceKey,
|
||||||
|
)
|
||||||
|
s.Name = pURL.Scheme
|
||||||
|
s.ServiceType = serviceType
|
||||||
|
s.DiscoveredDate = omu.NowPtr()
|
||||||
|
|
||||||
|
discoverySession.AddService(
|
||||||
|
"UPnP",
|
||||||
|
s,
|
||||||
|
meta,
|
||||||
)
|
)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
oa "git.loafle.net/overflow/annotation-go"
|
oa "git.loafle.net/overflow/annotation-go"
|
||||||
|
@ -31,5 +32,9 @@ func (s *MachineService) DestroyService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MachineService) Interfaces() ([]*omn.Interface, error) {
|
func (s *MachineService) Interfaces() ([]*omn.Interface, error) {
|
||||||
return nic.DiscoverInterfaces()
|
ifaces, err := nic.DiscoverInterfaces()
|
||||||
|
if nil != err {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
|
return ifaces, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user