@@ -26,7 +26,16 @@ var sonar = {
26
26
}
27
27
28
28
// Separate IP and range, target[0] is the IP and target[1] is the range
29
+ // If the range is not specified, we assume that only one IP should be scaned
29
30
target = target . split ( '/' ) ;
31
+ if ( target [ 1 ] === undefined ) {
32
+ target [ 1 ] = 32 ;
33
+ }
34
+
35
+ // Check the specified IP range, /31 subnets are excluded because those only have reserved and broadcast addresses
36
+ if ( target [ 1 ] < 0 || target [ 1 ] > 32 || target [ 1 ] == 31 ) {
37
+ return false ;
38
+ }
30
39
31
40
// This calls sonar.process_queue() every
32
41
setInterval ( function ( ) {
@@ -36,7 +45,7 @@ var sonar = {
36
45
if ( target [ 0 ] == "" ) {
37
46
sonar . enumerate_local_ips ( target [ 1 ] ) ;
38
47
} else {
39
- sonar . ip_to_range ( target [ 0 ] , target [ 1 ] ) ;
48
+ sonar . ip_to_range ( target [ 0 ] , target [ 1 ] ) ;
40
49
}
41
50
} ,
42
51
@@ -128,6 +137,12 @@ var sonar = {
128
137
return false ;
129
138
}
130
139
140
+ // If we're only going to scan one IP, queue it without calculating the range
141
+ if ( range == 32 ) {
142
+ sonar . ip_queue . push ( ip ) ;
143
+ return ;
144
+ }
145
+
131
146
var ip_min = [ 0 , 0 , 0 , 0 ] ;
132
147
var ip_max = [ 0 , 0 , 0 , 0 ] ;
133
148
var r = 0 ;
0 commit comments