mirror of
https://github.com/MikroWizard/mikroman.git
synced 2025-06-27 23:40:11 +02:00
MikroWizard Initial commit | MikroMan Welcome to the world :)
This commit is contained in:
commit
8c49b9a55d
96 changed files with 12274 additions and 0 deletions
39
py/api/api_scanner.py
Normal file
39
py/api/api_scanner.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# api_scanner.py: API for device scanner in network
|
||||
# MikroWizard.com , Mikrotik router management solution
|
||||
# Author: sepehr.ha@gmail.com
|
||||
|
||||
from flask import request
|
||||
|
||||
from libs.db import db_tasks,db_syslog
|
||||
from libs.webutil import app, login_required,buildResponse,get_myself,get_ip,get_agent
|
||||
import bgtasks
|
||||
import json
|
||||
import logging
|
||||
log = logging.getLogger("api.scanner")
|
||||
|
||||
@app.route('/api/scanner/scan', methods = ['POST'])
|
||||
@login_required(role='admin',perm={'device':'full'})
|
||||
def scan_network():
|
||||
"""Do scan requested network for given ip range to find mikrotik devices"""
|
||||
input = request.json
|
||||
start=input.get('start',False)
|
||||
end=input.get('end',False)
|
||||
port=input.get('port',8728)
|
||||
if not port:
|
||||
port=8728
|
||||
password=input.get('password',False)
|
||||
username=input.get('user',False)
|
||||
status=db_tasks.scanner_job_status().status
|
||||
|
||||
if not status:
|
||||
if start and end and port:
|
||||
db_syslog.add_syslog_event(get_myself(), "Scanner","start", get_ip(),get_agent(),json.dumps(input))
|
||||
bgtasks.scan_with_ip(start=start,end=end,port=port,password=password,username=username)
|
||||
return buildResponse({'status': True},200)
|
||||
else:
|
||||
return buildResponse({'status': status},200)
|
||||
else:
|
||||
return buildResponse({'status': status},200)
|
Loading…
Add table
Add a link
Reference in a new issue