mirror of
https://github.com/itdoginfo/allow-domains.git
synced 2025-09-01 18:19:41 +00:00
Add CloudFront
This commit is contained in:
parent
219dc6b847
commit
76807d2e76
1 changed files with 32 additions and 0 deletions
|
@ -4,6 +4,7 @@ import ipaddress
|
|||
import urllib.request
|
||||
import os
|
||||
import shutil
|
||||
import json
|
||||
|
||||
BGP_TOOLS_URL = 'https://bgp.tools/table.txt'
|
||||
HEADERS = { 'User-Agent': 'itdog.info - hi@itdog.info' }
|
||||
|
@ -24,6 +25,7 @@ CLOUDFLARE = 'cloudflare.lst'
|
|||
HETZNER = 'hetzner.lst'
|
||||
OVH = 'ovh.lst'
|
||||
DO = 'do.lst'
|
||||
CLOUDFRONT = 'cloudfront.lst'
|
||||
|
||||
# From https://iplist.opencck.org/
|
||||
DISCORD_VOICE_V4='https://iplist.opencck.org/?format=text&data=cidr4&site=discord.gg&site=discord.media'
|
||||
|
@ -36,6 +38,8 @@ TELEGRAM_CIDR_URL = 'https://core.telegram.org/resources/cidr.txt'
|
|||
CLOUDFLARE_V4='https://www.cloudflare.com/ips-v4'
|
||||
CLOUDFLARE_V6='https://www.cloudflare.com/ips-v6'
|
||||
|
||||
AWS_IP_RANGES_URL='https://ip-ranges.amazonaws.com/ip-ranges.json'
|
||||
|
||||
subnet_list = []
|
||||
|
||||
def subnet_summarization(subnet_list):
|
||||
|
@ -100,6 +104,29 @@ def download_ready_split_subnets(url):
|
|||
|
||||
return ipv4_subnets, ipv6_subnets
|
||||
|
||||
def download_aws_cloudfront_subnets():
|
||||
ipv4_subnets = []
|
||||
ipv6_subnets = []
|
||||
|
||||
req = urllib.request.Request(AWS_IP_RANGES_URL, headers=HEADERS)
|
||||
try:
|
||||
with urllib.request.urlopen(req) as response:
|
||||
if response.status == 200:
|
||||
data = json.loads(response.read().decode('utf-8'))
|
||||
|
||||
for prefix in data.get('prefixes', []):
|
||||
if prefix.get('service') == 'CLOUDFRONT':
|
||||
ipv4_subnets.append(prefix['ip_prefix'])
|
||||
|
||||
for prefix in data.get('ipv6_prefixes', []):
|
||||
if prefix.get('service') == 'CLOUDFRONT':
|
||||
ipv6_subnets.append(prefix['ipv6_prefix'])
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error downloading AWS CloudFront ranges: {e}")
|
||||
|
||||
return ipv4_subnets, ipv6_subnets
|
||||
|
||||
def write_subnets_to_file(subnets, filename):
|
||||
with open(filename, 'w') as file:
|
||||
for subnet in subnets:
|
||||
|
@ -159,6 +186,11 @@ if __name__ == '__main__':
|
|||
write_subnets_to_file(ipv4_cloudflare, f'{IPv4_DIR}/{CLOUDFLARE}')
|
||||
write_subnets_to_file(ipv6_cloudflare, f'{IPv6_DIR}/{CLOUDFLARE}')
|
||||
|
||||
# AWS CloudFront
|
||||
ipv4_cloudfront, ipv6_cloudfront = download_aws_cloudfront_subnets()
|
||||
write_subnets_to_file(ipv4_cloudfront, f'{IPv4_DIR}/{CLOUDFRONT}')
|
||||
write_subnets_to_file(ipv6_cloudfront, f'{IPv6_DIR}/{CLOUDFRONT}')
|
||||
|
||||
# Legacy name
|
||||
copy_file_legacy(f'{IPv4_DIR}/{META}')
|
||||
copy_file_legacy(f'{IPv6_DIR}/{META}')
|
||||
|
|
Loading…
Add table
Reference in a new issue