@@ -14,11 +14,11 @@ type netNode struct {
14
14
15
15
// Networks represents a set of subnets that we are iterating over.
16
16
type Networks struct {
17
- err error
18
- reader * Reader
19
- nodes []netNode
20
- lastNode netNode
21
- skipAliasedNetworks bool
17
+ err error
18
+ reader * Reader
19
+ nodes []netNode
20
+ lastNode netNode
21
+ includeAliasedNetworks bool
22
22
}
23
23
24
24
var (
@@ -29,23 +29,20 @@ var (
29
29
// NetworksOption are options for Networks and NetworksWithin.
30
30
type NetworksOption func (* Networks )
31
31
32
- // SkipAliasedNetworks is an option for Networks and NetworksWithin that
33
- // makes them not iterate over aliases of the IPv4 subtree in an IPv6
32
+ // IncludeAliasedNetworks is an option for Networks and NetworksWithin
33
+ // that makes them iterate over aliases of the IPv4 subtree in an IPv6
34
34
// database, e.g., ::ffff:0:0/96, 2001::/32, and 2002::/16.
35
- //
36
- // You most likely want to set this. The only reason it isn't the default
37
- // behavior is to provide backwards compatibility to existing users.
38
- func SkipAliasedNetworks (networks * Networks ) {
39
- networks .skipAliasedNetworks = true
35
+ func IncludeAliasedNetworks (networks * Networks ) {
36
+ networks .includeAliasedNetworks = true
40
37
}
41
38
42
39
// Networks returns an iterator that can be used to traverse all networks in
43
40
// the database.
44
41
//
45
42
// Please note that a MaxMind DB may map IPv4 networks into several locations
46
- // in an IPv6 database. This iterator will iterate over all of these locations
47
- // separately . To only iterate over the IPv4 networks once , use the
48
- // SkipAliasedNetworks option.
43
+ // in an IPv6 database. This iterator will only iterate over these once by
44
+ // default . To iterate over all the IPv4 network locations , use the
45
+ // IncludeAliasedNetworks option.
49
46
func (r * Reader ) Networks (options ... NetworksOption ) * Networks {
50
47
var networks * Networks
51
48
if r .Metadata .IPVersion == 6 {
@@ -122,7 +119,7 @@ func (n *Networks) Next() bool {
122
119
for node .pointer != n .reader .Metadata .NodeCount {
123
120
// This skips IPv4 aliases without hardcoding the networks that the writer
124
121
// currently aliases.
125
- if n . skipAliasedNetworks && n .reader .ipv4Start != 0 &&
122
+ if ! n . includeAliasedNetworks && n .reader .ipv4Start != 0 &&
126
123
node .pointer == n .reader .ipv4Start && ! isInIPv4Subtree (node .ip ) {
127
124
break
128
125
}
0 commit comments