Skip to content

Commit 466d992

Browse files
committed
Update with CloudFlare ipv6 ranges
1 parent 5826ca8 commit 466d992

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.la
2+
*.lo
3+
*.o
4+
*.slo
5+
.libs/

mod_cloudflare.c

+27-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,32 @@
4040
module AP_MODULE_DECLARE_DATA cloudflare_module;
4141

4242
#define CF_DEFAULT_IP_HEADER "CF-Connecting-IP"
43-
#define CF_DEFAULT_TRUSTED_PROXY {"204.93.240.0/24","204.93.177.0/24","199.27.128.0/21","173.245.48.0/20","103.21.244.0/22","103.22.200.0/22","103.31.4.0/22","141.101.64.0/18","108.162.192.0/18","190.93.240.0/20","188.114.96.0/20","197.234.240.0/22","198.41.128.0/17","162.158.0.0/15"}
44-
#define CF_DEFAULT_TRUSTED_PROXY_COUNT 14
43+
/* CloudFlare IP Ranges from https://www.cloudflare.com/ips */
44+
static const char* CF_DEFAULT_TRUSTED_PROXY[] = {
45+
/* IPv4 Address Ranges */
46+
"204.93.240.0/24",
47+
"204.93.177.0/24",
48+
"199.27.128.0/21",
49+
"173.245.48.0/20",
50+
"103.21.244.0/22",
51+
"103.22.200.0/22",
52+
"103.31.4.0/22",
53+
"141.101.64.0/18",
54+
"108.162.192.0/18",
55+
"190.93.240.0/20",
56+
"188.114.96.0/20",
57+
"197.234.240.0/22",
58+
"198.41.128.0/17",
59+
"162.158.0.0/15",
60+
/* IPv6 Address Ranges */
61+
"2400:cb00::/32",
62+
"2606:4700::/32",
63+
"2803:f800::/32",
64+
"2405:b500::/32",
65+
"2405:8100::/32",
66+
};
67+
static const size_t CF_DEFAULT_TRUSTED_PROXY_COUNT =
68+
sizeof(CF_DEFAULT_TRUSTED_PROXY)/sizeof(char *);
4569

4670
typedef struct {
4771
/** A proxy IP mask to match */
@@ -159,7 +183,7 @@ static apr_status_t set_cf_default_proxies(apr_pool_t *p, cloudflare_config_t *c
159183
apr_status_t rv;
160184
cloudflare_proxymatch_t *match;
161185
int i;
162-
char *proxies[] = CF_DEFAULT_TRUSTED_PROXY;
186+
char **proxies = CF_DEFAULT_TRUSTED_PROXY;
163187

164188
for (i=0; i<CF_DEFAULT_TRUSTED_PROXY_COUNT; i++) {
165189
char *ip = apr_pstrdup(p, proxies[i]);

0 commit comments

Comments
 (0)