Adding unsaved captures deletion
This commit is contained in:
parent
e04ef547c2
commit
2968d6fcb6
@ -113,7 +113,11 @@ export default {
|
|||||||
router.replace({ name: 'save-capture', params: { capture_token: capture_token } });
|
router.replace({ name: 'save-capture', params: { capture_token: capture_token } });
|
||||||
},
|
},
|
||||||
new_capture: function() {
|
new_capture: function() {
|
||||||
router.push({ name: 'generate-ap' })
|
axios.get('/api/misc/delete-captures', { timeout: 30000 })
|
||||||
|
.then(response => {
|
||||||
|
router.push({ name: 'generate-ap' })
|
||||||
|
})
|
||||||
|
.catch(err => (console.log(err)))
|
||||||
},
|
},
|
||||||
grep_keyword: function(kw, level){
|
grep_keyword: function(kw, level){
|
||||||
try {
|
try {
|
||||||
|
@ -39,6 +39,10 @@
|
|||||||
})
|
})
|
||||||
.catch(err => (console.log(err)))
|
.catch(err => (console.log(err)))
|
||||||
},
|
},
|
||||||
|
delete_captures: function() {
|
||||||
|
axios.get('/api/misc/delete-captures', { timeout: 30000 })
|
||||||
|
.catch(err => (console.log(err)))
|
||||||
|
},
|
||||||
goto_home: function() {
|
goto_home: function() {
|
||||||
var list_ssids = this.list_ssids
|
var list_ssids = this.list_ssids
|
||||||
var internet = this.internet
|
var internet = this.internet
|
||||||
@ -46,6 +50,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function() {
|
created: function() {
|
||||||
|
this.delete_captures();
|
||||||
setTimeout(function () { this.internet_check(); }.bind(this), 5000);
|
setTimeout(function () { this.internet_check(); }.bind(this), 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
from app.utils import read_config
|
from app.utils import read_config, delete_captures
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@ -11,6 +11,17 @@ import os
|
|||||||
misc_bp = Blueprint("misc", __name__)
|
misc_bp = Blueprint("misc", __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@misc_bp.route("/delete-captures", methods=["GET"])
|
||||||
|
def api_delete_captures():
|
||||||
|
"""
|
||||||
|
Delete the zombies capture folders (if any)
|
||||||
|
"""
|
||||||
|
if delete_captures():
|
||||||
|
return jsonify({"message": "Captures deleted", "status": True})
|
||||||
|
else:
|
||||||
|
return jsonify({"message": "Issue while removing captures", "status": False})
|
||||||
|
|
||||||
|
|
||||||
@misc_bp.route("/reboot", methods=["GET"])
|
@misc_bp.route("/reboot", methods=["GET"])
|
||||||
def api_reboot():
|
def api_reboot():
|
||||||
"""
|
"""
|
||||||
|
@ -7,6 +7,8 @@ import yaml
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
import shutil
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
def terminate_process(process):
|
def terminate_process(process):
|
||||||
@ -33,3 +35,16 @@ def read_config(path):
|
|||||||
config = yaml.load(open(os.path.join(dir, "config.yaml"), "r"),
|
config = yaml.load(open(os.path.join(dir, "config.yaml"), "r"),
|
||||||
Loader=yaml.SafeLoader)
|
Loader=yaml.SafeLoader)
|
||||||
return reduce(dict.get, path, config)
|
return reduce(dict.get, path, config)
|
||||||
|
|
||||||
|
|
||||||
|
def delete_captures():
|
||||||
|
"""
|
||||||
|
Delete potential zombies capture directories
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
for d in os.listdir("/tmp/"):
|
||||||
|
if re.match("[A-F0-9]{8}", d):
|
||||||
|
shutil.rmtree(os.path.join("/tmp/", d))
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user