Skip to content

Commit 2429a33

Browse files
committed
adding bogon check in non-iter func
1 parent 35a6ca2 commit 2429a33

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ipinfo/handler.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,25 @@ def getBatchDetails(
197197
batch_size = BATCH_MAX_SIZE
198198

199199
result = {}
200+
lookup_addresses = []
201+
202+
# check if bogon.
203+
for ip_address in ip_addresses:
204+
if isinstance(ip_address, IPv4Address) or isinstance(
205+
ip_address, IPv6Address
206+
):
207+
ip_address = ip_address.exploded
208+
209+
if ip_address and is_bogon(ip_address):
210+
details = {}
211+
details["ip"] = ip_address
212+
details["bogon"] = True
213+
return Details(details)
214+
else:
215+
lookup_addresses.append(ip_address)
200216

201217
# pre-populate with anything we've got in the cache, and keep around
202218
# the IPs not in the cache.
203-
lookup_addresses = []
204219
for ip_address in ip_addresses:
205220
# if the supplied IP address uses the objects defined in the
206221
# built-in module ipaddress extract the appropriate string notation

0 commit comments

Comments
 (0)