@@ -25,8 +25,17 @@ type record struct {
2525// databases provided.
2626func records (
2727 networks , databases []string ,
28- includeAliasedNetworks bool ,
28+ includeAliasedNetworks ,
29+ includeNetworksWithoutData bool ,
2930) iter.Seq2 [* record , error ] {
31+ var opts []maxminddb.NetworksOption
32+ if includeAliasedNetworks {
33+ opts = append (opts , maxminddb .IncludeAliasedNetworks )
34+ }
35+ if includeNetworksWithoutData {
36+ opts = append (opts , maxminddb .IncludeNetworksWithoutData )
37+ }
38+
3039 return func (yield func (* record , error ) bool ) {
3140 for _ , glob := range databases {
3241 matches , err := filepath .Glob (glob )
@@ -46,7 +55,7 @@ func records(
4655 DatabasePath : path ,
4756 RequestedLookup : thisNetwork ,
4857 }
49- ok := recordsForNetwork (reader , includeAliasedNetworks , baseRecord , yield )
58+ ok := recordsForNetwork (reader , opts , baseRecord , yield )
5059 if ! ok {
5160 return
5261 }
@@ -62,7 +71,7 @@ func records(
6271// network containing a single address (i.e., /32 for IPv4 and /128 for IPv6).
6372func recordsForNetwork (
6473 reader * maxminddb.Reader ,
65- includeAliasedNetworks bool ,
74+ opts []maxminddb. NetworksOption ,
6675 record record ,
6776 yield func (* record , error ) bool ,
6877) bool {
@@ -89,11 +98,6 @@ func recordsForNetwork(
8998 network = netip .PrefixFrom (addr , bits )
9099 }
91100
92- var opts []maxminddb.NetworksOption
93- if includeAliasedNetworks {
94- opts = append (opts , maxminddb .IncludeAliasedNetworks )
95- }
96-
97101 for res := range reader .NetworksWithin (network , opts ... ) {
98102 record .Network = res .Prefix ()
99103
0 commit comments