File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ const CLOUDFRONT_URL = 'https://ip-ranges.amazonaws.com/ip-ranges.json';
9
9
const CLOUDFARE_V4_URL = 'https://www.cloudflare.com/ips-v4' ;
10
10
const CLOUDFARE_V6_URL = 'https://www.cloudflare.com/ips-v6' ;
11
11
12
+ const regIpV4 = / ^ ( \d + \. ? ) { 4 } \/ \d + / ;
13
+ const regIpV6 = / ^ ( ( [ \d a - f A - F ] + ) ? : ) + \/ \d + / ;
14
+
12
15
const internalIpRanges = {
13
16
14
17
interval_timeout : 1000 * 60 * 60 * 6 , // 6 hours
@@ -74,14 +77,14 @@ const internalIpRanges = {
74
77
return internalIpRanges . fetchUrl ( CLOUDFARE_V4_URL ) ;
75
78
} )
76
79
. then ( ( cloudfare_data ) => {
77
- let items = cloudfare_data . split ( '\n' ) ;
80
+ let items = cloudfare_data . split ( '\n' ) . filter ( ( line ) => regIpV4 . test ( line ) ) ;
78
81
ip_ranges = [ ... ip_ranges , ... items ] ;
79
82
} )
80
83
. then ( ( ) => {
81
84
return internalIpRanges . fetchUrl ( CLOUDFARE_V6_URL ) ;
82
85
} )
83
86
. then ( ( cloudfare_data ) => {
84
- let items = cloudfare_data . split ( '\n' ) ;
87
+ let items = cloudfare_data . split ( '\n' ) . filter ( ( line ) => regIpV6 . test ( line ) ) ;
85
88
ip_ranges = [ ... ip_ranges , ... items ] ;
86
89
} )
87
90
. then ( ( ) => {
You can’t perform that action at this time.
0 commit comments