This commit is contained in:
crusader 2018-09-17 22:55:38 +09:00
parent ec00e90410
commit 46db6509b0
5 changed files with 93 additions and 4 deletions

View File

@ -28,7 +28,7 @@ type Host struct {
HostModel string `json:"hostModel,omitempty"` HostModel string `json:"hostModel,omitempty"`
Meta map[string]map[string]string `json:"meta,omitempty"` Meta map[string]map[string]string `json:"meta,omitempty"`
DiscoveredBy []string `json:"discoveredBy,omitempty"` DiscoveredBy []*meta.MetaDiscovererType `json:"discoveredBy,omitempty"`
DiscoveredDate *util.Timestamp `json:"discoveredDate,omitempty"` DiscoveredDate *util.Timestamp `json:"discoveredDate,omitempty"`
Zone *Zone `json:"zone,omitempty"` Zone *Zone `json:"zone,omitempty"`

View File

@ -14,7 +14,7 @@ type Port struct {
PortNumber json.Number `json:"portNumber,omitempty"` PortNumber json.Number `json:"portNumber,omitempty"`
Meta map[string]map[string]string `json:"meta,omitempty"` Meta map[string]map[string]string `json:"meta,omitempty"`
DiscoveredBy []string `json:"discoveredBy,omitempty"` DiscoveredBy []*meta.MetaDiscovererType `json:"discoveredBy,omitempty"`
DiscoveredDate *util.Timestamp `json:"discoveredDate,omitempty"` DiscoveredDate *util.Timestamp `json:"discoveredDate,omitempty"`
Host *Host `json:"host,omitempty"` Host *Host `json:"host,omitempty"`

View File

@ -26,7 +26,7 @@ type Service struct {
ServiceVersion string `json:"serviceVersion,omitempty"` ServiceVersion string `json:"serviceVersion,omitempty"`
Meta map[string]map[string]string `json:"meta,omitempty"` Meta map[string]map[string]string `json:"meta,omitempty"`
DiscoveredBy []string `json:"discoveredBy,omitempty"` DiscoveredBy []*meta.MetaDiscovererType `json:"discoveredBy,omitempty"`
DiscoveredDate *util.Timestamp `json:"discoveredDate,omitempty"` DiscoveredDate *util.Timestamp `json:"discoveredDate,omitempty"`
Port *Port `json:"port,omitempty"` Port *Port `json:"port,omitempty"`

View File

@ -15,7 +15,7 @@ type Zone struct {
Mac string `json:"mac,omitempty"` Mac string `json:"mac,omitempty"`
Meta map[string]map[string]string `json:"meta,omitempty"` Meta map[string]map[string]string `json:"meta,omitempty"`
DiscoveredBy []string `json:"discoveredBy,omitempty"` DiscoveredBy []*meta.MetaDiscovererType `json:"discoveredBy,omitempty"`
DiscoveredDate *util.Timestamp `json:"discoveredDate,omitempty"` DiscoveredDate *util.Timestamp `json:"discoveredDate,omitempty"`
mtx sync.RWMutex `json:"-"` mtx sync.RWMutex `json:"-"`

View File

@ -0,0 +1,89 @@
package meta
import (
"encoding/json"
"git.loafle.net/overflow/model/util"
)
type MetaDiscovererType struct {
ID json.Number `json:"id,Number,omitempty"`
Name string `json:"name,omitempty"`
Key string `json:"key,omitempty"`
CreateDate *util.Timestamp `json:"createDate,omitempty"`
}
type MetaDiscovererTypeEnum int
const (
MetaDiscovererTypeEnumUNKNOWN MetaDiscovererTypeEnum = iota + 1
MetaDiscovererTypeEnumARP
MetaDiscovererTypeEnumICMP
MetaDiscovererTypeEnumMDNS
MetaDiscovererTypeEnumNDP
MetaDiscovererTypeEnumSNMP
MetaDiscovererTypeEnumTCPACK
MetaDiscovererTypeEnumTCPFIN
MetaDiscovererTypeEnumTCPNULL
MetaDiscovererTypeEnumTCPXmas
MetaDiscovererTypeEnumTCPSyn
MetaDiscovererTypeEnumTCPConnection
MetaDiscovererTypeEnumTCPMatcher
MetaDiscovererTypeEnumUDPConnection
MetaDiscovererTypeEnumUDPMatcher
MetaDiscovererTypeEnumUPnP
)
var (
metaDiscovererTypeEnumID = map[MetaDiscovererTypeEnum]string{
MetaDiscovererTypeEnumUNKNOWN: "UNKNOWN",
MetaDiscovererTypeEnumARP: "ARP",
MetaDiscovererTypeEnumICMP: "ICMP",
MetaDiscovererTypeEnumMDNS: "MDNS",
MetaDiscovererTypeEnumNDP: "NDP",
MetaDiscovererTypeEnumSNMP: "SNMP",
MetaDiscovererTypeEnumTCPACK: "TCPACK",
MetaDiscovererTypeEnumTCPFIN: "TCPFIN",
MetaDiscovererTypeEnumTCPNULL: "TCPNULL",
MetaDiscovererTypeEnumTCPXmas: "TCPXmas",
MetaDiscovererTypeEnumTCPSyn: "TCPSyn",
MetaDiscovererTypeEnumTCPConnection: "TCPConnection",
MetaDiscovererTypeEnumTCPMatcher: "TCPMatcher",
MetaDiscovererTypeEnumUDPConnection: "UDPConnection",
MetaDiscovererTypeEnumUDPMatcher: "UDPMatcher",
MetaDiscovererTypeEnumUPnP: "UPnP",
}
metaDiscovererTypeEnumKey = map[string]MetaDiscovererTypeEnum{
"UNKNOWN": MetaDiscovererTypeEnumUNKNOWN,
"ARP": MetaDiscovererTypeEnumARP,
"ICMP": MetaDiscovererTypeEnumICMP,
"MDNS": MetaDiscovererTypeEnumMDNS,
"NDP": MetaDiscovererTypeEnumNDP,
"SNMP": MetaDiscovererTypeEnumSNMP,
"TCPACK": MetaDiscovererTypeEnumTCPACK,
"TCPFIN": MetaDiscovererTypeEnumTCPFIN,
"TCPNULL": MetaDiscovererTypeEnumTCPNULL,
"TCPXmas": MetaDiscovererTypeEnumTCPXmas,
"TCPSyn": MetaDiscovererTypeEnumTCPSyn,
"TCPConnection": MetaDiscovererTypeEnumTCPConnection,
"TCPMatcher": MetaDiscovererTypeEnumTCPMatcher,
"UDPConnection": MetaDiscovererTypeEnumUDPConnection,
"UDPMatcher": MetaDiscovererTypeEnumUDPMatcher,
"UPnP": MetaDiscovererTypeEnumUPnP,
}
)
func (e MetaDiscovererTypeEnum) String() string {
return metaDiscovererTypeEnumID[e]
}
func ToMetaDiscovererTypeEnum(v *MetaDiscovererType) MetaDiscovererTypeEnum {
return metaDiscovererTypeEnumKey[v.Key]
}
func ToMetaDiscovererType(v MetaDiscovererTypeEnum) *MetaDiscovererType {
return &MetaDiscovererType{
Key: metaDiscovererTypeEnumID[v],
}
}