/
address_type.go
47 lines (41 loc) · 1.41 KB
/
address_type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package models
const (
// AnySecurityGroup matches any security group in AddressType.
AnySecurityGroup = "any"
// LocalSecurityGroup matches the local security group in AddressType.
LocalSecurityGroup = "local"
// UnspecifiedSecurityGroup doesn't match against the security group in AddressType.
UnspecifiedSecurityGroup = ""
// IPv4ZeroValue is the zero IPv4 address.
IPv4ZeroValue = "0.0.0.0"
// IPv6ZeroValue is the zero IPv6 address.
IPv6ZeroValue = "::"
)
// AllIPv4Addresses returns an AddressType with a subnet of all possible IPv4 addresses.
func AllIPv4Addresses() *AddressType {
return &AddressType{
Subnet: &SubnetType{
IPPrefix: IPv4ZeroValue,
IPPrefixLen: 0,
},
}
}
// AllIPv6Addresses returns an AddressType with a subnet of all possible IPv6 addresses.
func AllIPv6Addresses() *AddressType {
return &AddressType{
Subnet: &SubnetType{
IPPrefix: IPv6ZeroValue,
IPPrefixLen: 0,
},
}
}
// IsSecurityGroupNameAReference checks if the Security Group name in an address
// is a reference to other security group.
func (m *AddressType) IsSecurityGroupNameAReference() bool {
return m.SecurityGroup != AnySecurityGroup &&
m.SecurityGroup != LocalSecurityGroup && m.SecurityGroup != UnspecifiedSecurityGroup
}
// IsSecurityGroupLocal checks if the address specifies the local Security Group.
func (m *AddressType) IsSecurityGroupLocal() bool {
return m.SecurityGroup == LocalSecurityGroup
}