90 lines
2.9 KiB
Go
90 lines
2.9 KiB
Go
|
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],
|
||
|
}
|
||
|
}
|