Fixed APScan select bug + Attack status bug

- fixed: APScan select wasn't working when Multiple AP selection was disbaled.
- fixed: Attack stati wasn't shown
- improved: design of select,deselect all buttons
This commit is contained in:
Stefan Kremser
2017-05-15 19:36:44 +02:00
parent 98deeb503b
commit 3128dbe83f
5 changed files with 23 additions and 15 deletions

View File

@@ -226,7 +226,8 @@ String APScan::getResultsJSON() {
void APScan::sort() { void APScan::sort() {
if (debug) Serial.println("sorting APs "); if (debug) Serial.println("sorting APs ");
//bubble sort /* I know, it's bubble sort... but it works and that's the main thing! ;) (feel free to improve it tho) */
for (int i = 0; i < results - 1; i++) { for (int i = 0; i < results - 1; i++) {
Serial.println("--------------"); Serial.println("--------------");
for (int h = 0; h < results - i - 1; h++) { for (int h = 0; h < results - i - 1; h++) {
@@ -269,8 +270,8 @@ void APScan::sort() {
void APScan::select(int num) { void APScan::select(int num) {
if (debug) Serial.println("select " + (String)num + " - " + !selected[num]); if (debug) Serial.println("select " + (String)num + " - " + !selected[num]);
if(num < 0) { if(num < 0) {
if (num == -1){ if(num == -1){
if (settings.multiAPs) { if(settings.multiAPs) {
selectedSum = results; selectedSum = results;
for (int i = 0; i < results; i++) selected[i] = true; for (int i = 0; i < results; i++) selected[i] = true;
} }
@@ -281,13 +282,13 @@ void APScan::select(int num) {
} else if(!settings.multiAPs) { } else if(!settings.multiAPs) {
for (int i = 0; i < maxAPScanResults; i++){ for (int i = 0; i < maxAPScanResults; i++){
if(i != num) selected[i] = false; if(i != num) selected[i] = false;
selected[num] = !selected[num]; else selected[num] = !selected[num];
selectedSum = 1;
} }
selectedSum = 1;
} else { } else {
selected[num] = !selected[num]; if(selected[num]) selectedSum--;
if (selected[num]) selectedSum--;
else selectedSum++; else selectedSum++;
selected[num] = !selected[num];
} }
} }

View File

@@ -255,14 +255,14 @@ void Attack::start(int num) {
} }
void Attack::stop(int num) { void Attack::stop(int num) {
if (isRunning[num]) { if(isRunning[num]) {
if (debug) Serial.println("stopping " + (String)attackNames[num] + " attack..."); if (debug) Serial.println("stopping " + (String)attackNames[num] + " attack...");
if (num == 0) attackMode = "START"; if (num == 0) attackMode = "START";
isRunning[num] = false; isRunning[num] = false;
stati[num] = "ready";
prevTime[num] = millis(); prevTime[num] = millis();
refreshLed(); refreshLed();
} }
stati[num] = "ready";
} }
void Attack::stopAll() { void Attack::stopAll() {

File diff suppressed because one or more lines are too long

View File

@@ -31,6 +31,11 @@
<span id="networksFound">0</span> <span id="networksFound">0</span>
<br /> <br />
MAC: <span id="apMAC"></span> MAC: <span id="apMAC"></span>
<span id="selectAllBtns">
<br />
<button class="marginNull button-primary left" onclick="select(-2)">deselect all</button>
<button class="marginNull button-primary right" onclick="select(-1)">select all</button>
</span>
</p> </p>
<br /> <br />

View File

@@ -3,6 +3,7 @@ var networkInfo = getE('networksFound');
var scanInfo = getE('scanInfo'); var scanInfo = getE('scanInfo');
var apMAC = getE('apMAC'); var apMAC = getE('apMAC');
var startStopScan = getE('startStopScan'); var startStopScan = getE('startStopScan');
var selectAllBtns = getE('selectAllBtns');
var autoScan = false; var autoScan = false;
function toggleScan(onoff) { function toggleScan(onoff) {
@@ -32,12 +33,13 @@ function getResults() {
networkInfo.innerHTML = res.aps.length; networkInfo.innerHTML = res.aps.length;
apMAC.innerHTML = ""; apMAC.innerHTML = "";
if (res.multiAPs == 1) selectAllBtns.style.visibility = 'visible';
else selectAllBtns.style.visibility = 'hidden';
var tr = ''; var tr = '';
if (res.aps.length > 0) { if (res.aps.length > 0) {
tr += '<tr><th>Ch</th><th>SSID</th><th>RSSI</th><th>Encrypt.</th>'; tr += '<tr><th>Ch</th><th>SSID</th><th>RSSI</th><th>Encrypt.</th>';
tr += '<th>Select</th></tr>'
if (res.multiAPs == 1) tr += '<th><button class="marginNull button-primary" onclick="select(-1)">select</button>&nbsp|&nbsp<button class="marginNull button-primary" onclick="select(-2)">deselect</button>&nbspall</th></tr>';
else tr += '<th>Select</th></tr>'
} }
for (var i = 0; i < res.aps.length; i++) { for (var i = 0; i < res.aps.length; i++) {