File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -30,19 +30,20 @@ const checkIpRanges = (ip, ranges = []) => {
30
30
}
31
31
return ip ;
32
32
} ;
33
+ const getType = address => ( isIPv4 ( address ) ? 'ipv4' : 'ipv6' ) ;
33
34
const blocklist = new BlockList ( ) ;
34
35
for ( const range of ranges ) {
35
36
if ( range . includes ( '/' ) ) {
36
37
const [ net , prefix ] = range . split ( '/' ) ;
37
38
const addr = transformIp ( net ) ;
38
- blocklist . addSubnet ( addr , Number ( prefix ) , isIPv4 ( addr ) ? 'ipv4' : 'ipv6' ) ;
39
+ blocklist . addSubnet ( addr , Number ( prefix ) , getType ( addr ) ) ;
39
40
} else {
40
41
const addr = transformIp ( range ) ;
41
- blocklist . addAddress ( addr , isIPv4 ( addr ) ? 'ipv4' : 'ipv6' ) ;
42
+ blocklist . addAddress ( addr , getType ( addr ) ) ;
42
43
}
43
44
}
44
45
const client = transformIp ( ip ) ;
45
- return blocklist . check ( client , isIPv4 ( client ) ? 'ipv4' : 'ipv6' ) ;
46
+ return blocklist . check ( client , getType ( client ) ) ;
46
47
} ;
47
48
48
49
// Checks that the request is authorized for this app and checks user
You can’t perform that action at this time.
0 commit comments