-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (18 loc) · 768 Bytes
/
main.py
File metadata and controls
26 lines (18 loc) · 768 Bytes
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
#!/usr/bin/env python3
"""
Author: Dan Wadleigh <dan@codecharacter.dev>
Date: 6/27/2022 (version 2.0)
Purpose: Take an IP address from command line and check if it's in a CIDR list.
Python Performance Package (pending dev):
- from flux.capacitor import GigaWatts //default=1.21
- from flux.capacitor import MilesPerHour //default=88
"""
from ipcheck import iparg, cidrdata, checkip
def main():
"""Main logic for ipcheck program"""
ipv4_addr = iparg.get_ipv4_arg()
json_url = "https://stat.ripe.net/data/country-resource-list/data.json?resource=US&v4_format=prefix"
cidr_ranges = cidrdata.get_cidr_data(json_url)
checkip.check_ipv4_in_cidr_ranges(ipv4_addr, cidr_ranges["data"]["resources"]["ipv4"])
if __name__ == "__main__":
main()