This commit is contained in:
crusader 2017-12-04 15:30:56 +09:00
parent 467b1e0e59
commit a0c0fefa8d
10 changed files with 159 additions and 0 deletions

View File

@ -0,0 +1,10 @@
package model
type DiscoveryHost struct {
FirstScanRange string `json:"firstScanRange,omitempty"`
LastScanRange string `json:"lastScanRange,omitempty"`
ExcludeHosts []string `json:"excludeHosts,omitempty"`
IncludeHosts []string `json:"includeHosts,omitempty"`
DiscoveryPort *DiscoveryPort `json:"discoveryPort,omitempty"`
}

View File

@ -0,0 +1,28 @@
package model
type DiscoveryPort struct {
FirstScanRange int `json:"firstScanRange,omitempty"`
LastScanRange int `json:"lastScanRange,omitempty"`
ExcludePorts []int `json:"excludePorts,omitempty"`
IncludeTCP bool `json:"includeTCP,omitempty"`
IncludeUDP bool `json:"includeUDP,omitempty"`
DiscoveryService *DiscoveryService `json:"discoveryService,omitempty"`
}
func (dp *DiscoveryPort) Contains(port int) bool {
if dp.FirstScanRange > port {
return false
}
if dp.LastScanRange < port {
return false
}
for _, p := range dp.ExcludePorts {
if p == port {
return false
}
}
return true
}

View File

@ -0,0 +1,6 @@
package model
type DiscoveryService struct {
IncludeServices []string `json:"includeServices,omitempty"`
}

View File

@ -0,0 +1,7 @@
package model
type DiscoveryZone struct {
ExcludePatterns []string `json:"excludePatterns,omitempty"`
DiscoveryHost *DiscoveryHost `json:"discoveryHost,omitempty"`
}

View File

@ -0,0 +1,18 @@
package model
import (
"encoding/json"
"git.loafle.net/overflow/overflow_commons_go/util"
)
type Host struct {
Zone *Zone `json:"zone"`
ID json.Number `json:"id,Number,omitempty"`
IP string `json:"ip,omitempty"`
Mac string `json:"mac,omitempty"`
OS string `json:"os,omitempty"`
DiscoveredDate util.Timestamp `json:"discoveredDate,omitempty"`
}

View File

@ -0,0 +1,21 @@
package model
import (
"encoding/json"
"github.com/google/gopacket"
util "git.loafle.net/overflow/overflow_commons_go/util"
)
type Port struct {
Host *Host `json:"host,omitempty"`
ID json.Number `json:"id,Number,omitempty"`
PortType string `json:"portType,omitempty"`
PortNumber json.Number `json:"portNumber,omitempty"`
DiscoveredDate util.Timestamp `json:"discoveredDate,omitempty"`
UDPLayer gopacket.Layer `json:"-"`
}

View File

@ -0,0 +1,17 @@
package model
import (
"encoding/json"
util "git.loafle.net/overflow/overflow_commons_go/util"
)
type Service struct {
Port *Port `json:"port,omitempty"`
ID json.Number `json:"id,Number,omitempty"`
CryptoType string `json:"cryptoType,omitempty"`
ServiceName string `json:"serviceName,omitempty"`
DiscoveredDate util.Timestamp `json:"discoveredDate,omitempty"`
}

View File

@ -0,0 +1,20 @@
package model
import (
"encoding/json"
"sync"
"git.loafle.net/overflow/overflow_commons_go/util"
)
type Zone struct {
ID json.Number `json:"id,Number,omitempty"`
Network string `json:"network,omitempty"`
IP string `json:"ip,omitempty"`
Iface string `json:"iface,omitempty"`
Mac string `json:"mac,omitempty"`
DiscoveredDate util.Timestamp `json:"discoveredDate,omitempty"`
mtx sync.RWMutex `json:"-"`
}

View File

@ -0,0 +1,13 @@
package discovery
import (
discoveryM "git.loafle.net/overflow/overflow_commons_go/modules/discovery/model"
)
type DiscoveryService interface {
// use by probe
DiscoverZone(dz *discoveryM.DiscoveryZone) error
DiscoverHost(zone *discoveryM.Zone, dz *discoveryM.DiscoveryHost) error
DiscoverPort(host *discoveryM.Host, dz *discoveryM.DiscoveryPort) error
DiscoverService(port *discoveryM.Port, dz *discoveryM.DiscoveryService) error
}

View File

@ -0,0 +1,19 @@
package probe
import (
discoveryM "git.loafle.net/overflow/overflow_commons_go/modules/discovery/model"
)
type DiscoveryService interface {
// use by central
DiscoverZone(dz *discoveryM.DiscoveryZone) error
DiscoverHost(zone *discoveryM.Zone, dz *discoveryM.DiscoveryHost) error
DiscoverPort(host *discoveryM.Host, dz *discoveryM.DiscoveryPort) error
DiscoverService(port *discoveryM.Port, dz *discoveryM.DiscoveryService) error
// use by discovery
DiscoveredZone(zone *discoveryM.Zone)
DiscoveredHost(host *discoveryM.Host)
DiscoveredPort(port *discoveryM.Port)
DiscoveredService(service *discoveryM.Service)
}