diff options
author | ManeraKai <manerakai@protonmail.com> | 2022-04-16 17:17:24 +0300 |
---|---|---|
committer | ManeraKai <manerakai@protonmail.com> | 2022-04-16 17:17:24 +0300 |
commit | 9612b9eb29c9264d98701b36f1e98af10cb79321 (patch) | |
tree | 9cd0ffccbe6bcd4bc12939f7da59cc8311dfe5f8 /src/instances/cloudflare_ips.py | |
parent | update instances (diff) | |
download | libredirect-9612b9eb29c9264d98701b36f1e98af10cb79321.zip |
Separated script files #99
Diffstat (limited to 'src/instances/cloudflare_ips.py')
-rw-r--r-- | src/instances/cloudflare_ips.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/instances/cloudflare_ips.py b/src/instances/cloudflare_ips.py new file mode 100644 index 00000000..12a1fbe9 --- /dev/null +++ b/src/instances/cloudflare_ips.py @@ -0,0 +1,30 @@ +# Note: Run this script from the root of the repo + +import requests +import json +import subprocess +from colorama import Fore, Back, Style + +def init_cloudflare(): + r = requests.get('https://www.cloudflare.com/ips-v4') + myList = [] + for i in r.text.split('\n'): + out = subprocess.run( + ["sh", "./src/instances/get_possible_ips.sh", i], + capture_output=True, + text=True + ) + myList += out.stdout.splitlines() + print(Fore.GREEN + 'Fetched ' + + Fore.RED + 'Cloudflare IPs' + + Style.RESET_ALL) + + return myList + +cloudflare_ips = init_cloudflare() +print(cloudflare_ips) + +json_object = json.dumps(cloudflare_ips, ensure_ascii=False, indent=2) +with open('./src/instances/cloudflare_ips.json', 'w') as outfile: + outfile.write(json_object) +print(Fore.BLUE + 'wrote ' + Style.RESET_ALL + 'instances/cloudflare_ips.json') \ No newline at end of file |