File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 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';
99const CLOUDFARE_V4_URL = 'https://www.cloudflare.com/ips-v4' ;
1010const CLOUDFARE_V6_URL = 'https://www.cloudflare.com/ips-v6' ;
1111
12+ const regIpV4 = / ^ ( \d + \. ? ) { 4 } \/ \d + / ;
13+ const regIpV6 = / ^ ( ( [ \d a - f A - F ] + ) ? : ) + \/ \d + / ;
14+
1215const internalIpRanges = {
1316
1417 interval_timeout : 1000 * 60 * 60 * 6 , // 6 hours
@@ -74,14 +77,14 @@ const internalIpRanges = {
7477 return internalIpRanges . fetchUrl ( CLOUDFARE_V4_URL ) ;
7578 } )
7679 . then ( ( cloudfare_data ) => {
77- let items = cloudfare_data . split ( '\n' ) ;
80+ let items = cloudfare_data . split ( '\n' ) . filter ( ( line ) => regIpV4 . test ( line ) ) ;
7881 ip_ranges = [ ... ip_ranges , ... items ] ;
7982 } )
8083 . then ( ( ) => {
8184 return internalIpRanges . fetchUrl ( CLOUDFARE_V6_URL ) ;
8285 } )
8386 . then ( ( cloudfare_data ) => {
84- let items = cloudfare_data . split ( '\n' ) ;
87+ let items = cloudfare_data . split ( '\n' ) . filter ( ( line ) => regIpV6 . test ( line ) ) ;
8588 ip_ranges = [ ... ip_ranges , ... items ] ;
8689 } )
8790 . then ( ( ) => {
You can’t perform that action at this time.
0 commit comments