diff --git a/model/meta/MetaCryptoType.go b/model/meta/MetaCryptoType.go index 0668726..bc2a90d 100644 --- a/model/meta/MetaCryptoType.go +++ b/model/meta/MetaCryptoType.go @@ -12,3 +12,83 @@ type MetaCryptoType struct { Key string `json:"key,omitempty"` CreateDate *util.Timestamp `json:"createDate,omitempty"` } + +type MetaCryptoTypeEnum int + +const ( + MetaCryptoTypeEnumNONE MetaCryptoTypeEnum = iota + 1 + MetaCryptoTypeEnumUNKNOWN + MetaCryptoTypeEnumAES + MetaCryptoTypeEnumCIPHER + MetaCryptoTypeEnumDES + MetaCryptoTypeEnumDSA + MetaCryptoTypeEnumECDSA + MetaCryptoTypeEnumELLIPTIC + MetaCryptoTypeEnumHMAC + MetaCryptoTypeEnumMD5 + MetaCryptoTypeEnumRAND + MetaCryptoTypeEnumRC4 + MetaCryptoTypeEnumRSA + MetaCryptoTypeEnumSHA1 + MetaCryptoTypeEnumSHA256 + MetaCryptoTypeEnumSUBTLE + MetaCryptoTypeEnumTLS + MetaCryptoTypeEnumX509 + MetaCryptoTypeEnumPKIX +) + +var ( + metaCryptoTypeEnumID = map[MetaCryptoTypeEnum]string{ + MetaCryptoTypeEnumNONE: "NONE", + MetaCryptoTypeEnumUNKNOWN: "UNKNOWN", + MetaCryptoTypeEnumAES: "AES", + MetaCryptoTypeEnumCIPHER: "CIPHER", + MetaCryptoTypeEnumDES: "DES", + MetaCryptoTypeEnumDSA: "DSA", + MetaCryptoTypeEnumECDSA: "ECDSA", + MetaCryptoTypeEnumELLIPTIC: "ELLIPTIC", + MetaCryptoTypeEnumHMAC: "HMAC", + MetaCryptoTypeEnumMD5: "MD5", + MetaCryptoTypeEnumRAND: "RAND", + MetaCryptoTypeEnumRC4: "RC4", + MetaCryptoTypeEnumRSA: "RSA", + MetaCryptoTypeEnumSHA1: "SHA1", + MetaCryptoTypeEnumSHA256: "SHA256", + MetaCryptoTypeEnumSUBTLE: "SUBTLE", + MetaCryptoTypeEnumTLS: "TLS", + MetaCryptoTypeEnumX509: "X509", + MetaCryptoTypeEnumPKIX: "PKIX", + } + + metaCryptoTypeEnumKey = map[string]MetaCryptoTypeEnum{ + "NONE": MetaCryptoTypeEnumNONE, + "UNKNOWN": MetaCryptoTypeEnumUNKNOWN, + "AES": MetaCryptoTypeEnumAES, + "CIPHER": MetaCryptoTypeEnumCIPHER, + "DES": MetaCryptoTypeEnumDES, + "DSA": MetaCryptoTypeEnumDSA, + "ECDSA": MetaCryptoTypeEnumECDSA, + "ELLIPTIC": MetaCryptoTypeEnumELLIPTIC, + "HMAC": MetaCryptoTypeEnumHMAC, + "MD5": MetaCryptoTypeEnumMD5, + "RAND": MetaCryptoTypeEnumRAND, + "RC4": MetaCryptoTypeEnumRC4, + "RSA": MetaCryptoTypeEnumRSA, + "SHA1": MetaCryptoTypeEnumSHA1, + "SHA256": MetaCryptoTypeEnumSHA256, + "SUBTLE": MetaCryptoTypeEnumSUBTLE, + "TLS": MetaCryptoTypeEnumTLS, + "X509": MetaCryptoTypeEnumX509, + "PKIX": MetaCryptoTypeEnumPKIX, + } +) + +func ToMetaCryptoTypeEnum(v *MetaCryptoType) MetaCryptoTypeEnum { + return metaCryptoTypeEnumKey[v.Key] +} + +func ToMetaCryptoType(v MetaCryptoTypeEnum) *MetaCryptoType { + return &MetaCryptoType{ + Key: metaCryptoTypeEnumID[v], + } +} diff --git a/model/meta/MetaIPType.go b/model/meta/MetaIPType.go index 4b9c50b..f3cbbae 100644 --- a/model/meta/MetaIPType.go +++ b/model/meta/MetaIPType.go @@ -16,8 +16,8 @@ type MetaIPType struct { type MetaIPTypeEnum int const ( - MetaIPTypeEnumV4 MetaIPTypeEnum = 1 - MetaIPTypeEnumV6 MetaIPTypeEnum = 2 + MetaIPTypeEnumV4 MetaIPTypeEnum = iota + 1 + MetaIPTypeEnumV6 ) var ( diff --git a/model/meta/MetaInfraType.go b/model/meta/MetaInfraType.go index 01f6616..d33ddd3 100644 --- a/model/meta/MetaInfraType.go +++ b/model/meta/MetaInfraType.go @@ -16,9 +16,9 @@ type MetaInfraType struct { type MetaInfraTypeEnum int const ( - MetaInfraTypeEnumZONE MetaInfraTypeEnum = 1 - MetaInfraTypeEnumHOST MetaInfraTypeEnum = 2 - MetaInfraTypeEnumService MetaInfraTypeEnum = 3 + MetaInfraTypeEnumZONE MetaInfraTypeEnum = iota + 1 + MetaInfraTypeEnumHOST + MetaInfraTypeEnumService ) var ( diff --git a/model/meta/MetaMemberStatus.go b/model/meta/MetaMemberStatus.go index 0fe8cfe..f9d7c06 100644 --- a/model/meta/MetaMemberStatus.go +++ b/model/meta/MetaMemberStatus.go @@ -16,10 +16,10 @@ type MetaMemberStatus struct { type MetaMemberStatusEnum int const ( - MetaMemberStatusEnumNOAUTH MetaMemberStatusEnum = 1 - MetaMemberStatusEnumNORMAL MetaMemberStatusEnum = 2 - MetaMemberStatusEnumDORMANCY MetaMemberStatusEnum = 3 - MetaMemberStatusEnumWITHDRAWAL MetaMemberStatusEnum = 4 + MetaMemberStatusEnumNOAUTH MetaMemberStatusEnum = iota + 1 + MetaMemberStatusEnumNORMAL + MetaMemberStatusEnumDORMANCY + MetaMemberStatusEnumWITHDRAWAL ) var ( diff --git a/model/meta/MetaNoAuthProbeStatus.go b/model/meta/MetaNoAuthProbeStatus.go index a39db6c..555f2ed 100644 --- a/model/meta/MetaNoAuthProbeStatus.go +++ b/model/meta/MetaNoAuthProbeStatus.go @@ -16,9 +16,9 @@ type MetaNoAuthProbeStatus struct { type NoAuthProbeStatusEnum int const ( - NoAuthProbeStatusEnumACCEPT NoAuthProbeStatusEnum = 1 - NoAuthProbeStatusEnumDENY NoAuthProbeStatusEnum = 2 - NoAuthProbeStatusEnumPROCESSING NoAuthProbeStatusEnum = 3 + NoAuthProbeStatusEnumACCEPT NoAuthProbeStatusEnum = iota + 1 + NoAuthProbeStatusEnumDENY + NoAuthProbeStatusEnumPROCESSING ) var ( diff --git a/model/meta/MetaPortType.go b/model/meta/MetaPortType.go index a4edbc6..7c3fde8 100644 --- a/model/meta/MetaPortType.go +++ b/model/meta/MetaPortType.go @@ -16,8 +16,8 @@ type MetaPortType struct { type MetaPortTypeEnum int const ( - MetaPortTypeEnumTCP MetaPortTypeEnum = 1 - MetaPortTypeEnumUDP MetaPortTypeEnum = 2 + MetaPortTypeEnumTCP MetaPortTypeEnum = iota + 1 + MetaPortTypeEnumUDP ) var ( diff --git a/model/meta/MetaProbeStatus.go b/model/meta/MetaProbeStatus.go index 471bb0a..b88ee05 100644 --- a/model/meta/MetaProbeStatus.go +++ b/model/meta/MetaProbeStatus.go @@ -16,8 +16,8 @@ type MetaProbeStatus struct { type MetaProbeStatusEnum int const ( - MetaProbeStatusEnumINITIAL MetaProbeStatusEnum = 1 - MetaProbeStatusEnumNORMAL MetaProbeStatusEnum = 2 + MetaProbeStatusEnumINITIAL MetaProbeStatusEnum = iota + 1 + MetaProbeStatusEnumNORMAL ) var ( diff --git a/model/meta/MetaTargetHostType.go b/model/meta/MetaTargetHostType.go index 65332b2..a1d2e52 100644 --- a/model/meta/MetaTargetHostType.go +++ b/model/meta/MetaTargetHostType.go @@ -7,7 +7,7 @@ type MetaTargetHostType struct { type MetaTargetHostTypeEnum int const ( - MetaTargetHostTypeEnumUNKNOWN MetaTargetHostTypeEnum = 100 + MetaTargetHostTypeEnumUNKNOWN MetaTargetHostTypeEnum = iota + 1 ) var ( diff --git a/model/meta/MetaTargetServiceType.go b/model/meta/MetaTargetServiceType.go index 78a3735..d52352b 100644 --- a/model/meta/MetaTargetServiceType.go +++ b/model/meta/MetaTargetServiceType.go @@ -7,7 +7,7 @@ type MetaTargetServiceType struct { type MetaTargetServiceTypeEnum int const ( - MetaTargetServiceTypeEnumUNKNOWN MetaTargetServiceTypeEnum = 1000 + MetaTargetServiceTypeEnumUNKNOWN MetaTargetServiceTypeEnum = iota + 1 ) var ( diff --git a/model/meta/MetaTargetZoneType.go b/model/meta/MetaTargetZoneType.go index af30a39..ab9d9a9 100644 --- a/model/meta/MetaTargetZoneType.go +++ b/model/meta/MetaTargetZoneType.go @@ -7,8 +7,8 @@ type MetaTargetZoneType struct { type MetaTargetZoneTypeEnum int const ( - MetaTargetZoneTypeEnumUNKNOWN MetaTargetZoneTypeEnum = 1 - MetaTargetZoneTypeEnumZONE MetaTargetZoneTypeEnum = 2 + MetaTargetZoneTypeEnumUNKNOWN MetaTargetZoneTypeEnum = iota + 1 + MetaTargetZoneTypeEnumZONE ) var (