@@ -147,34 +147,32 @@ async def handle_event(self, event):
147
147
148
148
# Get CIDRs from the base domain of the protected domain
149
149
base_dns = await self .helpers .dns .resolve (base_domain )
150
- if base_dns :
151
- # Skip if base domain has same IPs as protected domain
152
- if set (str (ip ) for ip in base_dns ) == self .domain_ips .get (domain , set ()):
153
- self .debug (f"Base domain { base_domain } has same IPs as protected domain, skipping CIDR collection" )
154
- else :
155
- if base_domain not in self .bypass_candidates :
156
- self .bypass_candidates [base_domain ] = set ()
157
- self .debug (f"Created new CIDR set for { provider_name } base domain: { base_domain } " )
158
-
159
- for ip in base_dns :
160
- self .debug (f"Getting ASN info for IP { ip } from { provider_name } base domain { base_domain } " )
161
- asns = await self .helpers .asn .ip_to_subnets (str (ip ))
162
- if asns :
163
- for asn_info in asns :
164
- subnets = asn_info .get ("subnets" )
165
- if isinstance (subnets , str ):
166
- subnets = [subnets ]
167
- if subnets :
168
- for cidr in subnets :
169
- self .bypass_candidates [base_domain ].add (cidr )
170
- self .debug (
171
- f"Added CIDR { cidr } from { provider_name } base domain { base_domain } "
172
- f"(ASN{ asn_info .get ('asn' , 'Unknown' )} - { asn_info .get ('name' , 'Unknown' )} )"
173
- )
174
- else :
175
- self .warning (f"No ASN info found for IP { ip } " )
176
- else :
150
+ if not base_dns :
177
151
self .debug (f"WARNING: No DNS resolution for { provider_name } base domain { base_domain } " )
152
+ if base_dns and (set (str (ip ) for ip in base_dns ) == self .domain_ips .get (domain , set ())):
153
+ self .debug (f"Base domain { base_domain } has same IPs as protected domain, skipping CIDR collection" )
154
+ else :
155
+ if base_domain not in self .bypass_candidates :
156
+ self .bypass_candidates [base_domain ] = set ()
157
+ self .debug (f"Created new CIDR set for { provider_name } base domain: { base_domain } " )
158
+
159
+ for ip in base_dns :
160
+ self .debug (f"Getting ASN info for IP { ip } from { provider_name } base domain { base_domain } " )
161
+ asns = await self .helpers .asn .ip_to_subnets (str (ip ))
162
+ if asns :
163
+ for asn_info in asns :
164
+ subnets = asn_info .get ("subnets" )
165
+ if isinstance (subnets , str ):
166
+ subnets = [subnets ]
167
+ if subnets :
168
+ for cidr in subnets :
169
+ self .bypass_candidates [base_domain ].add (cidr )
170
+ self .debug (
171
+ f"Added CIDR { cidr } from { provider_name } base domain { base_domain } "
172
+ f"(ASN{ asn_info .get ('asn' , 'Unknown' )} - { asn_info .get ('name' , 'Unknown' )} )"
173
+ )
174
+ else :
175
+ self .warning (f"No ASN info found for IP { ip } " )
178
176
179
177
else :
180
178
if "cdn-ip" in event .tags :
@@ -254,6 +252,7 @@ async def finish(self):
254
252
255
253
# Then collect non-CloudFlare IPs
256
254
for domain , ips in self .domain_ips .items ():
255
+ self .debug (f"Checking IP { ips } from domain { domain } " )
257
256
if domain not in self .protected_domains : # If it's not a protected domain
258
257
for ip in ips :
259
258
# Validate that this is actually an IP address before processing
@@ -275,7 +274,7 @@ async def finish(self):
275
274
n_ip_str = str (neighbor_ip )
276
275
if n_ip_str == ip or n_ip_str in cloudflare_ips or n_ip_str in all_ips :
277
276
continue
278
- asns_neighbor = await self .helpers .asn .get (n_ip_str )
277
+ asns_neighbor = await self .helpers .asn .ip_to_subnets (n_ip_str )
279
278
if not asns_neighbor :
280
279
continue
281
280
# Check if any ASN matches
0 commit comments