Skip to content

Commit 58ca962

Browse files
committed
fixed queuing of reserved address
1 parent 79db80b commit 58ca962

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

example.htm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
sonar.start(true, 2000 );
1313

1414
// It's also possible to specify a target or subnet size
15-
//sonar.start(true, 2000, 192.168.0.1/24);
16-
//sonar.start(true, 2000, /24);
15+
//sonar.start(true, 2000, "192.168.0.1/24");
16+
//sonar.start(true, 2000, "/24");
1717
</script>
1818
</body>
1919
</html>

sonar.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ var sonar = {
134134

135135
for( var tmp = 0; tmp < 4; tmp++ ) {
136136

137-
// Calculate the number of bits that change of each part
137+
// Calculate the number of bits that change of the current part
138138
if ( range > 8 + 8 * tmp){
139139
r = 0;
140140
} else {
@@ -150,23 +150,26 @@ var sonar = {
150150
}
151151

152152
if( sonar.debug ) {
153-
alert( '[DEBUG][The samallest IP adress to be scaned is:]' + ip_min[0] + '.' + ip_min[1] + '.' + ip_min[2] + '.' + ip_min[3]);
153+
alert( '[DEBUG][The samallest IP adress to be scaned is:]' + ip_min[0] + '.' + ip_min[1] + '.' + ip_min[2] + '.' + (ip_min[3] + 1));
154154
alert( '[DEBUG][The largest IP adress to be scaned is:]' + ip_max[0] + '.' + ip_max[1] + '.' + ip_max[2] + '.' + ip_max[3]);
155155
}
156156

157157
// Queue IP address range
158158
var ip_parts = ip_min.slice();
159+
var d = ip_min[3] + 1;
159160
for( var a = ip_min[0]; a <= ip_max[0]; a++ ) {
160161
ip_parts[0] = a;
161162
for( var b = ip_min[1]; b <= ip_max[1]; b++ ) {
162163
ip_parts[1] = b;
163164
for( var c = ip_min[2]; c <= ip_max[2]; c++ ) {
164165
ip_parts[2] = c;
165-
for( var d = ip_min[3]; d <= ip_max[3]; d++ ) {
166+
while( d <= ip_max[3] ) {
166167
ip_parts[3] = d;
167168
var tmp_ip = ip_parts[0] + '.' + ip_parts[1] + '.' + ip_parts[2] + '.' + ip_parts[3];
168169
sonar.ip_queue.push( tmp_ip );
170+
d++;
169171
}
172+
d = ip_min[3]
170173
}
171174
}
172175
}

0 commit comments

Comments
 (0)