Skip to content

Commit 639dffa

Browse files
fixed bug in case firewall cannot connect to cloudflare, will now use fail safe server lists instead
1 parent 8b86ee6 commit 639dffa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cloudflare_middleware/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import ipaddress
44
import re
55

6+
import requests.exceptions
67
from CloudFlare import CloudFlare
78
from CloudFlare.exceptions import CloudFlareAPIError
89
from starlette.requests import Request
@@ -175,7 +176,8 @@ async def get_ip_ranges() -> tuple[list[str], list[str]]:
175176
ipv4_cidrs = response.get('result', {}).get('ipv4_cidrs', DEFAULT_IPV4)
176177
ipv6_cidrs = response.get('result', {}).get('ipv6_cidrs', [])
177178
return ipv4_cidrs, ipv6_cidrs
178-
179+
except requests.exceptions.ConnectionError:
180+
return [], []
179181
except CloudFlareAPIError:
180182
return [], []
181183

0 commit comments

Comments
 (0)