diff --git a/app/config.py b/app/config.py
index 9324f107..94973950 100644
--- a/app/config.py
+++ b/app/config.py
@@ -20,58 +20,58 @@ aftersave = ""
try:
user, user_id, role, token, servers = funct.get_users_params()
-except:
+except Exception:
pass
if service == 'keepalived':
- title = "Working with Keepalived configs"
+ title = "Working with Keepalived configuration files"
action = "config.py?service=keepalived"
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
- format = 'conf'
+ file_format = 'conf'
servers = sql.get_dick_permit(keepalived=1)
elif service == 'nginx':
- title = "Working with Nginx configs"
+ title = "Working with Nginx configuration files"
action = "config.py?service=nginx"
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
- format = 'conf'
+ file_format = 'conf'
servers = sql.get_dick_permit(nginx=1)
else:
- title = "Working with HAProxy configs"
+ title = "Working with HAProxy configuration files"
action = "config.py"
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
- format = 'cfg'
+ file_format = 'cfg'
servers = sql.get_dick_permit()
if serv is not None:
- cfg = configs_dir + serv + "-" + funct.get_data('config') + "."+format
+ cfg = configs_dir + serv + "-" + funct.get_data('config') + "."+file_format
-if serv is not None and form.getvalue('open') is not None :
+if serv is not None and form.getvalue('open') is not None:
funct.check_is_server_in_group(serv)
if service == 'keepalived':
error = funct.get_config(serv, cfg, keepalived=1)
try:
funct.logging(serv, " Keepalived config has opened for ")
- except:
+ except Exception:
pass
elif service == 'nginx':
error = funct.get_config(serv, cfg, nginx=1)
try:
funct.logging(serv, " Nginx config has opened ")
- except:
+ except Exception:
pass
else:
error = funct.get_config(serv, cfg)
try:
funct.logging(serv, " HAProxy config has opened ")
- except:
+ except Exception:
pass
try:
conf = open(cfg, "r")
config_read = conf.read()
- conf.close
+ conf.close()
except IOError:
- error += ' Can\'t read import config file'
+ error += ' Cannot read import config file'
os.system("/bin/mv %s %s.old" % (cfg, cfg))
@@ -79,7 +79,7 @@ if serv is not None and form.getvalue('config') is not None:
funct.check_is_server_in_group(serv)
try:
funct.logging(serv, "config.py edited config")
- except:
+ except Exception:
pass
config = form.getvalue('config')
@@ -104,20 +104,20 @@ if serv is not None and form.getvalue('config') is not None:
os.system("/bin/rm -f " + configs_dir + "*.old")
-template = template.render(h2 = 1, title = title,
- role = role,
- action = action,
- user = user,
- select_id = "serv",
- serv = serv,
- aftersave = aftersave,
- config = config_read,
- cfg = cfg,
- selects = servers,
- stderr = stderr,
- error = error,
- note = 1,
- versions = funct.versions(),
- service = service,
- token = token)
+template = template.render(h2=1, title=title,
+ role=role,
+ action=action,
+ user=user,
+ select_id="serv",
+ serv=serv,
+ aftersave=aftersave,
+ config=config_read,
+ cfg=cfg,
+ selects=servers,
+ stderr=stderr,
+ error=error,
+ note=1,
+ versions=funct.versions(),
+ service=service,
+ token=token)
print(template)
diff --git a/app/create_db.py b/app/create_db.py
index 165d94a6..99b4c667 100644
--- a/app/create_db.py
+++ b/app/create_db.py
@@ -297,13 +297,13 @@ def update_db_v_3_8_1(**kwargs):
try:
cur.execute(i)
con.commit()
- except sqltool.Error as e:
+ except sqltool.Error:
pass
else:
if kwargs.get('silent') != 1:
print('Updating... go to version 3.12.0.0')
- return True
- cur.close()
+
+ cur.close()
con.close()
@@ -359,11 +359,10 @@ def update_db_v_3_13(**kwargs):
print('Updating... go to version 4.0.0')
else:
print("An error occurred:", e)
- return False
else:
print("Updating... go to version 4.0.0")
- return True
- cur.close()
+
+ cur.close()
con.close()
@@ -388,8 +387,8 @@ def update_db_v_4(**kwargs):
else:
if kwargs.get('silent') != 1:
print('Updating... one more for version 4.0.0')
- return True
- cur.close()
+
+ cur.close()
con.close()
@@ -407,11 +406,10 @@ def update_db_v_41(**kwargs):
print('Updating... one more for version 4.0.0')
else:
print("An error occurred:", e)
- return False
else:
print("Updating... one more for version 4.0.0")
- return True
- cur.close()
+
+ cur.close()
con.close()
@@ -429,11 +427,10 @@ def update_db_v_42(**kwargs):
print('Updating... go to version 4.2.3')
else:
print("An error occurred:", e)
- return False
else:
print("Updating... go to version 4.2.3")
- return True
- cur.close()
+
+ cur.close()
con.close()
@@ -451,9 +448,7 @@ def update_db_v_4_2_3(**kwargs):
print('Updating... go to version 4.3.0')
else:
print("An error occurred:", e)
- return False
- else:
- return True
+
cur.close()
con.close()
@@ -472,9 +467,7 @@ def update_db_v_4_3(**kwargs):
print('Updating... go to version 4.3.0')
else:
print("An error occurred:", e)
- return False
- else:
- return True
+
cur.close()
con.close()
@@ -498,9 +491,7 @@ def update_db_v_4_3_0(**kwargs):
print('Updating... go to version 4.3.1')
else:
print("An error occurred:", e)
- return False
- else:
- return True
+
cur.close()
con.close()
@@ -519,11 +510,10 @@ def update_db_v_4_3_1(**kwargs):
print('Updating... go to version 4.3.2')
else:
print("An error occurred:", e)
- return False
else:
print("DB was update to 4.3.1")
- return True
- cur.close()
+
+ cur.close()
con.close()
@@ -541,11 +531,10 @@ def update_db_v_4_3_2(**kwargs):
print('Updating... go to version 4.4.0')
else:
print("An error occurred:", e)
- return False
else:
print("Updating... go to version 4.4.0")
- return True
- cur.close()
+
+ cur.close()
con.close()
@@ -581,9 +570,7 @@ def update_db_v_4_4(**kwargs):
print('Updating... go to version 4.4.1')
else:
print("An error occurred:", e)
- return False
- else:
- return True
+
cur.close()
con.close()
@@ -607,9 +594,7 @@ def update_db_v_4_4_2(**kwargs):
print('Updating... go to version 4.4.1')
else:
print("Updating... go to version to 4.4.1")
- return False
- else:
- return True
+
cur.close()
con.close()
@@ -628,14 +613,11 @@ def update_db_v_4_4_2_1(**kwargs):
print('Updating... go to version 4.4.2')
else:
print("An error occurred:", e)
- cur.close()
- con.close()
- return False
else:
print("DB was update to 4.4.2")
- cur.close()
- con.close()
- return True
+
+ cur.close()
+ con.close()
def update_db_v_4_3_2_1(**kwargs):
@@ -688,9 +670,7 @@ def update_db_v_4_5(**kwargs):
print('Updating... go to version 4.5.0')
else:
print("Updating... go to version to 4.5.0")
- return False
- else:
- return True
+
cur.close()
con.close()
@@ -723,14 +703,13 @@ def update_db_v_4_5_1(**kwargs):
else:
if kwargs.get('silent') != 1:
print('DB was update to 4.5.0')
- return True
cur.close()
con.close()
def update_ver(**kwargs):
con, cur = get_cur()
- sql = """update version set version = '4.5.2.0'; """
+ sql = """update version set version = '4.5.3.0'; """
try:
cur.execute(sql)
con.commit()
diff --git a/app/funct.py b/app/funct.py
index cd1847a4..08fbe96a 100644
--- a/app/funct.py
+++ b/app/funct.py
@@ -19,12 +19,12 @@ def get_config_var(sec, var):
path_config = "haproxy-wi.cfg"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)
- except:
+ except Exception:
print('Content-type: text/html\n')
- print('
Check the config file, whether it exists and the path. Must be: app/haproxy-webintarface.config
')
+ print('Check the config file, whether it exists and the path. Must be: app/haproxy-wi.cfg
')
try:
return config.get(sec, var)
- except:
+ except Exception:
print('Content-type: text/html\n')
print('Check the config file. Presence section %s and parameter %s
' % (sec, var))
@@ -35,7 +35,7 @@ def get_data(type):
import sql
try:
now_utc = datetime.now(timezone(sql.get_setting('time_zone')))
- except:
+ except Exception:
now_utc = datetime.now(timezone('UTC'))
if type == 'config':
fmt = "%Y-%m-%d.%H:%M:%S"
@@ -50,6 +50,7 @@ def get_data(type):
def get_user_group(**kwargs):
import sql
import http.cookies
+
try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_group_id = cookie.get('group')
@@ -61,7 +62,7 @@ def get_user_group(**kwargs):
user_group = g[0]
else:
user_group = g[1]
- except:
+ except Exception:
user_group = ''
return user_group
@@ -79,13 +80,13 @@ def logging(serv, action, **kwargs):
try:
ip = cgi.escape(os.environ["REMOTE_ADDR"])
- except:
+ except Exception:
ip = ''
try:
user_uuid = cookie.get('uuid')
login = sql.get_user_name_by_uuid(user_uuid.value)
- except:
+ except Exception:
login = ''
if kwargs.get('alerting') == 1:
@@ -114,7 +115,7 @@ def logging(serv, action, **kwargs):
except IOError as e:
print('Can\'t write log. Please check log_path in config %e
' % e)
pass
-
+
def telegram_send_mess(mess, **kwargs):
import telebot
@@ -132,7 +133,7 @@ def telegram_send_mess(mess, **kwargs):
channel_name = telegram[2]
if token_bot == '' or channel_name == '':
- mess = " Fatal: Can't send message. Add Telegram chanel before use alerting at this servers group"
+ mess = " Fatal: Can't send message. Add Telegram channel before use alerting at this servers group"
print(mess)
logging('localhost', mess, haproxywi=1)
sys.exit()
@@ -144,7 +145,7 @@ def telegram_send_mess(mess, **kwargs):
bot.send_message(chat_id=channel_name, text=mess)
except Exception as e:
print(str(e))
- logging('localhost', str(e).decode(encoding='UTF-8'), haproxywi=1)
+ logging('localhost', str(e), haproxywi=1)
sys.exit()
@@ -233,6 +234,7 @@ def ssh_connect(serv, **kwargs):
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(serv)
servers = sql.select_servers(server=serv)
+ ssh_port = 22
for server in servers:
ssh_port = server[10]
@@ -316,7 +318,7 @@ def diff_config(oldcfg, cfg):
try:
user_uuid = cookie.get('uuid')
login = sql.get_user_name_by_uuid(user_uuid.value)
- except:
+ except Exception:
login = ''
output, stderr = subprocess_execute(cmd)
@@ -429,19 +431,19 @@ def rewrite_section(start_line, end_line, config, section):
def get_backends_from_config(serv, backends='', **kwargs):
configs_dir = get_config_var('configs', 'haproxy_save_configs_dir')
- format = 'cfg'
+ format_cfg = 'cfg'
try:
- cfg = configs_dir+get_files(dir=configs_dir, format=format)[0]
+ cfg = configs_dir+get_files(dir=configs_dir, format=format_cfg)[0]
except Exception as e:
logging('localhost', str(e), haproxywi=1)
try:
- cfg = configs_dir + serv + "-" + get_data('config') + '.'+format
- except:
+ cfg = configs_dir + serv + "-" + get_data('config') + '.'+format_cfg
+ except Exception:
logging('localhost', ' Cannot generate cfg path', haproxywi=1)
try:
error = get_config(serv, cfg)
- except:
+ except Exception:
logging('localhost', ' Cannot download config', haproxywi=1)
print('error: Cannot get backends')
sys.exit()
@@ -488,6 +490,7 @@ def install_haproxy(serv, **kwargs):
stats_password = sql.get_setting('stats_password')
proxy = sql.get_setting('proxy')
hapver = kwargs.get('hapver')
+ ssh_port = 22
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(serv)
if ssh_enable == 0:
diff --git a/app/options.py b/app/options.py
index d784471f..13b221c7 100644
--- a/app/options.py
+++ b/app/options.py
@@ -37,7 +37,7 @@ if form.getvalue('getcerts') is not None and serv is not None:
try:
funct.ssh_command(serv, commands, ip="1")
except Exception as e:
- print('error: Cannot connect to the server: ' + str(e))
+ print('error: Cannot connect to the server: ' + e.args[0])
if form.getvalue('checkSshConnect') is not None and serv is not None:
print(funct.ssh_command(serv, ["ls -1t"]))
@@ -48,8 +48,8 @@ if form.getvalue('getcert') is not None and serv is not None:
commands = ["cat " + cert_path + "/" + id]
try:
funct.ssh_command(serv, commands, ip="1")
- except:
- print('error: Can not connect to the server')
+ except Exception as e:
+ print('error: Can not connect to the server ' + e.args[0])
if serv and form.getvalue('ssl_cert'):
cert_local_dir = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('ssl_local_path')
@@ -107,8 +107,7 @@ if form.getvalue('ipbackend') is not None and form.getvalue('backend_server') is
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
backend = form.getvalue('ipbackend')
backend_server = form.getvalue('backend_server')
- cmd = 'echo "show servers state"|nc %s %s |grep "%s" |grep "%s" |awk \'{print $5":"$19}\' |head -1' % (
- serv, haproxy_sock_port, backend, backend_server)
+ cmd = 'echo "show servers state"|nc %s %s |grep "%s" |grep "%s" |awk \'{print $5":"$19}\' |head -1' % (serv, haproxy_sock_port, backend, backend_server)
output, stderr = funct.subprocess_execute(cmd)
print(output[0])
@@ -130,13 +129,11 @@ if form.getvalue('backend_ip') is not None:
MASTERS = sql.is_master(serv)
for master in MASTERS:
if master[0] is not None:
- cmd = 'echo "set server %s/%s addr %s port %s check-port %s" |nc %s %s' % (
- backend_backend, backend_server, backend_ip, backend_port, backend_port, master[0], haproxy_sock_port)
+ cmd = 'echo "set server %s/%s addr %s port %s check-port %s" |nc %s %s' % (backend_backend, backend_server, backend_ip, backend_port, backend_port, master[0], haproxy_sock_port)
output, stderr = funct.subprocess_execute(cmd)
print(output[0])
- cmd = 'echo "set server %s/%s addr %s port %s check-port %s" |nc %s %s' % (
- backend_backend, backend_server, backend_ip, backend_port, backend_port, serv, haproxy_sock_port)
+ cmd = 'echo "set server %s/%s addr %s port %s check-port %s" |nc %s %s' % (backend_backend, backend_server, backend_ip, backend_port, backend_port, serv, haproxy_sock_port)
output, stderr = funct.subprocess_execute(cmd)
if stderr != '':
@@ -147,8 +144,7 @@ if form.getvalue('backend_ip') is not None:
cfg = configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
error = funct.get_config(serv, cfg)
- cmd = 'string=`grep %s %s -n -A25 |grep "server %s" |head -1|awk -F"-" \'{print $1}\'` && sed -Ei "$( echo $string)s/((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5]):[0-9]+/%s:%s/g" %s' % (
- backend_backend, cfg, backend_server, backend_ip, backend_port, cfg)
+ cmd = 'string=`grep %s %s -n -A25 |grep "server %s" |head -1|awk -F"-" \'{print $1}\'` && sed -Ei "$( echo $string)s/((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5]):[0-9]+/%s:%s/g" %s' % (backend_backend, cfg, backend_server, backend_ip, backend_port, cfg)
output, stderr = funct.subprocess_execute(cmd)
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save='save')
@@ -187,8 +183,7 @@ if form.getvalue('maxconn_frontend') is not None:
cfg = configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
error = funct.get_config(serv, cfg)
- cmd = 'string=`grep %s %s -n -A5 |grep maxcon -n |awk -F":" \'{print $2}\'|awk -F"-" \'{print $1}\'` && sed -Ei "$( echo $string)s/[0-9]+/%s/g" %s' % (
- frontend, cfg, maxconn, cfg)
+ cmd = 'string=`grep %s %s -n -A5 |grep maxcon -n |awk -F":" \'{print $2}\'|awk -F"-" \'{print $1}\'` && sed -Ei "$( echo $string)s/[0-9]+/%s/g" %s' % (frontend, cfg, maxconn, cfg)
output, stderr = funct.subprocess_execute(cmd)
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save='save')
print('success: Maxconn for %s has been set to %s ' % (frontend, maxconn))
@@ -419,7 +414,7 @@ if form.getvalue('action_service') is not None:
elif action == "restart":
cmd = "sudo systemctl restart %s --now" % serv
output, stderr = funct.subprocess_execute(cmd)
- funct.logging('localhost', ' The service ' + serv + 'was ' + action + 'ed', haproxywi=1, login=1)
+ funct.logging('localhost', ' The service ' + serv + ' was ' + action + 'ed', haproxywi=1, login=1)
if act == "overviewHapserverBackends":
from jinja2 import Environment, FileSystemLoader
@@ -429,29 +424,29 @@ if act == "overviewHapserverBackends":
service = form.getvalue('service')
if service == 'haproxy':
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
- format = 'cfg'
+ format_file = 'cfg'
elif service == 'nginx':
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
- format = 'conf'
+ format_file = 'conf'
try:
- sections = funct.get_sections(configs_dir + funct.get_files(dir=configs_dir, format=format)[0], service=service)
+ sections = funct.get_sections(configs_dir + funct.get_files(dir=configs_dir, format=format_file)[0], service=service)
except Exception as e:
funct.logging('localhost', str(e), haproxywi=1)
try:
- cfg = configs_dir + serv + "-" + funct.get_data('config') + '.' + format
- except:
- funct.logging('localhost', ' Cannot generate cfg path', haproxywi=1)
+ cfg = configs_dir + serv + "-" + funct.get_data('config') + '.' + format_file
+ except Exception as e:
+ funct.logging('localhost', ' Cannot generate cfg path ' + str(e), haproxywi=1)
try:
if service == 'nginx':
error = funct.get_config(serv, cfg, nginx=1)
else:
error = funct.get_config(serv, cfg)
- except:
- funct.logging('localhost', ' Cannot download config', haproxywi=1)
+ except Exception as e:
+ funct.logging('localhost', ' Cannot download config ' + str(e), haproxywi=1)
try:
sections = funct.get_sections(cfg, service=service)
- except:
- funct.logging('localhost', ' Cannot get sections from config file', haproxywi=1)
+ except Exception as e:
+ funct.logging('localhost', ' Cannot get sections from config file ' + str(e), haproxywi=1)
sections = 'Cannot get backends'
template = template.render(backends=sections, serv=serv, service=service)
@@ -465,15 +460,15 @@ if act == "overviewHapservers":
commands = ["ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % config_path]
try:
print(funct.ssh_command(serv, commands))
- except:
- print('error: Cannot get last date')
+ except Exception as e:
+ print('error: Cannot get last date ' + str(e))
if act == "overview":
import asyncio
-
+ import http.cookies
+ from jinja2 import Environment, FileSystemLoader
async def async_get_overview(serv1, serv2):
- server_status = ()
commands2 = ["ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l"]
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Process_num"' % (serv2, sql.get_setting('haproxy_sock_port'))
keepalived = sql.select_keealived(serv2)
@@ -502,8 +497,6 @@ if act == "overview":
async def get_runner_overview():
- import http.cookies
- from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True,
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
@@ -526,24 +519,22 @@ if act == "overview":
if act == "overviewwaf":
import asyncio
-
+ import http.cookies
+ from jinja2 import Environment, FileSystemLoader
async def async_get_overviewWaf(serv1, serv2):
- haproxy_dir = sql.get_setting('haproxy_dir')
- server_status = ()
- commands = ["ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l"]
- commands1 = ["cat %s/waf/modsecurity.conf |grep SecRuleEngine |grep -v '#' |awk '{print $2}'" % haproxy_dir]
+ haproxy_path = sql.get_setting('haproxy_dir')
+ commands0 = ["ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l"]
+ commands1 = ["cat %s/waf/modsecurity.conf |grep SecRuleEngine |grep -v '#' |awk '{print $2}'" % haproxy_path]
server_status = (serv1, serv2,
- funct.ssh_command(serv2, commands),
+ funct.ssh_command(serv2, commands0),
funct.ssh_command(serv2, commands1).strip(),
sql.select_waf_metrics_enable_server(serv2))
return server_status
async def get_runner_overviewWaf():
- import http.cookies
- from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True,
extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
template = env.get_template('overivewWaf.html')
@@ -569,8 +560,6 @@ if act == "overviewServers":
async def async_get_overviewServers(serv1, serv2, service):
- server_status = ()
-
if service == 'haproxy':
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Ver\|CurrConns\|Maxco\|MB\|Uptime:"' % (
serv2, sql.get_setting('haproxy_sock_port'))
@@ -780,7 +769,7 @@ if serv is not None and act == "showMap":
node = node.strip(' \t\n\r')
node = node + ":" + bind[0]
G.add_node(node, pos=(k, i), label_pos=(k, i + 100))
- except:
+ except Exception:
pass
if "server " in line or "use_backend" in line or "default_backend" in line and "stats" not in line and "#" not in line:
@@ -851,8 +840,7 @@ if form.getvalue('servaction') is not None:
if enable != "show":
print(
- ' ' % (
- enable, backend, serv, serv))
+ ' ' % (enable, backend, serv, serv))
print(funct.ssh_command(serv, command, show_log="1"))
action = 'runtimeapi.py ' + enable + ' ' + backend
@@ -968,8 +956,7 @@ if form.getvalue('master'):
funct.install_nginx(slave)
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port +
- " ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + " SYN_FLOOD=" + syn_flood + " HOST=" + str(
- master) +
+ " ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + " SYN_FLOOD=" + syn_flood + " HOST=" + str(master) +
" USER=" + str(ssh_user_name) + " PASS=" + str(ssh_user_password) + " KEY=" + str(ssh_key_name)]
output, error = funct.subprocess_execute(commands[0])
@@ -985,7 +972,7 @@ if form.getvalue('master'):
l = l.split('"')[1]
print(l + " ")
break
- except:
+ except Exception:
print(output)
break
else:
@@ -1017,7 +1004,7 @@ if form.getvalue('master'):
l = l.split('"')[1]
print(l + " ")
break
- except:
+ except Exception:
print(output)
break
else:
@@ -1402,13 +1389,15 @@ if form.getvalue('metrics_hapwi_cpu'):
if form.getvalue('new_metrics'):
serv = form.getvalue('server')
- metric = sql.select_metrics(serv)
+ time_range = form.getvalue('time_range')
+ metric = sql.select_metrics(serv, time_range=time_range)
metrics = {'chartData': {}}
metrics['chartData']['labels'] = {}
labels = ''
curr_con = ''
curr_ssl_con = ''
sess_rate = ''
+ server = ''
for i in metric:
label = str(i[5])
@@ -1431,7 +1420,8 @@ if form.getvalue('new_metrics'):
if form.getvalue('new_waf_metrics'):
serv = form.getvalue('server')
- metric = sql.select_waf_metrics(serv)
+ time_range = form.getvalue('time_range')
+ metric = sql.select_waf_metrics(serv, time_range=time_range)
metrics = {'chartData': {}}
metrics['chartData']['labels'] = {}
labels = ''
@@ -1463,12 +1453,11 @@ if form.getvalue('get_exporter_v'):
print(funct.check_service(serv, form.getvalue('get_exporter_v')))
if form.getvalue('bwlists'):
- list = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
- 'group') + "/" + form.getvalue('color') + "/" + form.getvalue('bwlists')
+ list_path = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + form.getvalue('color') + "/" + form.getvalue('bwlists')
try:
- file = open(list, "r")
+ file = open(list_path, "r")
file_read = file.read()
- file.close
+ file.close()
print(file_read)
except IOError:
print('error: Cat\'n read ' + form.getvalue('color') + ' list , ')
@@ -1477,28 +1466,26 @@ if form.getvalue('bwlists_create'):
color = form.getvalue('color')
list_name = form.getvalue('bwlists_create').split('.')[0]
list_name += '.lst'
- list = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
- 'group') + "/" + color + "/" + list_name
+ list_path = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + color + "/" + list_name
try:
- open(list, 'a').close()
- print(color)
+ open(list_path, 'a').close()
+ print('success: ')
try:
- funct.logging(server[1], 'has created ' + color + ' list ' + list_name, haproxywi=1, login=1)
- except:
+ funct.logging(serv, 'has created ' + color + ' list ' + list_name, haproxywi=1, login=1)
+ except Exception:
pass
except IOError as e:
- print('error: Cat\'n create new ' + color + ' list. %s , ' % e)
+ print('error: Cannot create new ' + color + ' list. %s , ' % e)
if form.getvalue('bwlists_save'):
color = form.getvalue('color')
bwlists_save = form.getvalue('bwlists_save')
- list = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
- 'group') + "/" + color + "/" + bwlists_save
+ list_path = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + color + "/" + bwlists_save
try:
- with open(list, "w") as file:
+ with open(list_path, "w") as file:
file.write(form.getvalue('bwlists_content'))
except IOError as e:
- print('error: Cat\'n save ' + color + ' list. %s , ' % e)
+ print('error: Cannot save ' + color + ' list. %s , ' % e)
path = sql.get_setting('haproxy_dir') + "/" + color
servers = []
@@ -1518,14 +1505,15 @@ if form.getvalue('bwlists_save'):
for serv in servers:
funct.ssh_command(serv, ["sudo mkdir " + path])
funct.ssh_command(serv, ["sudo chown $(whoami) " + path])
- error = funct.upload(serv, path + "/" + bwlists_save, list, dir='fullpath')
+ error = funct.upload(serv, path + "/" + bwlists_save, list_path, dir='fullpath')
+
if error:
print('error: Upload fail: %s , ' % error)
else:
print('success: Edited ' + color + ' list was uploaded to ' + serv + ' , ')
try:
funct.logging(serv, 'has edited ' + color + ' list ' + bwlists_save, haproxywi=1, login=1)
- except:
+ except Exception:
pass
haproxy_enterprise = sql.get_setting('haproxy_enterprise')
@@ -1540,11 +1528,10 @@ if form.getvalue('bwlists_save'):
funct.ssh_command(serv, ["sudo systemctl reload " + haproxy_service_name])
if form.getvalue('get_lists'):
- list = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
- 'group') + "/" + form.getvalue('color')
- lists = funct.get_files(dir=list, format="lst")
- for list in lists:
- print(list)
+ list_path = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + form.getvalue('color')
+ lists = funct.get_files(dir=list_path, format="lst")
+ for l in lists:
+ print(l)
if form.getvalue('get_ldap_email'):
username = form.getvalue('get_ldap_email')
@@ -1574,7 +1561,7 @@ if form.getvalue('get_ldap_email'):
results = [entry for dn, entry in result if isinstance(entry, dict)]
try:
print('["' + results[0][ldap_search_field][0].decode("utf-8") + '","' + domain + '"]')
- except:
+ except Exception:
print('error: user not found')
finally:
l.unbind()
@@ -1621,6 +1608,7 @@ if form.getvalue('newuser') is not None:
if form.getvalue('userdel') is not None:
userdel = form.getvalue('userdel')
user = sql.select_users(id=userdel)
+ username = ''
for u in user:
username = u[1]
if sql.delete_user(userdel):
@@ -1646,11 +1634,11 @@ if form.getvalue('updateuser') is not None:
if form.getvalue('updatepassowrd') is not None:
password = form.getvalue('updatepassowrd')
- id = form.getvalue('id')
- user = sql.select_users(id=id)
+ user_id = form.getvalue('id')
+ user = sql.select_users(id=user_id)
for u in user:
username = u[1]
- sql.update_user_password(password, id)
+ sql.update_user_password(password, user_id)
funct.logging('user ' + username, ' has changed password ', haproxywi=1, login=1)
print("Ok")
@@ -1802,7 +1790,7 @@ if form.getvalue('sshdel') is not None:
cmd = 'rm -f %s' % ssh_key_name
try:
funct.subprocess_execute(cmd)
- except:
+ except Exception:
pass
if sql.delete_ssh(sshdel):
print("Ok")
@@ -1927,27 +1915,27 @@ if form.getvalue('updatesettings') is not None:
print("Ok")
if form.getvalue('getusergroups'):
- id = form.getvalue('getusergroups')
+ group_id = form.getvalue('getusergroups')
groups = []
- u_g = sql.select_user_groups(id=id)
+ u_g = sql.select_user_groups(id=group_id)
for g in u_g:
groups.append(g[0])
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
template = env.get_template('/show_user_groups.html')
- template = template.render(groups=sql.select_groups(), user_groups=groups, id=id)
+ template = template.render(groups=sql.select_groups(), user_groups=groups, id=group_id)
print(template)
if form.getvalue('changeUserGroupId') is not None:
- id = form.getvalue('changeUserGroupId')
+ group_id = form.getvalue('changeUserGroupId')
groups = form.getvalue('changeUserGroups')
user = form.getvalue('changeUserGroupsUser')
- if sql.delete_user_groups(id):
+ if sql.delete_user_groups(group_id):
for group in groups:
if group[0] == ',':
continue
- sql.update_user_groups(groups=group[0], id=id)
+ sql.update_user_groups(groups=group[0], id=group_id)
funct.logging('localhost', ' has upgraded groups for user: ' + user, haproxywi=1, login=1)
@@ -1957,14 +1945,14 @@ if form.getvalue('getcurrentusergroup') is not None:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
group = cookie.get('group')
- id = sql.get_user_id_by_uuid(user_id.value)
- groups = sql.select_user_groups_with_names(id=id)
+ group_id = sql.get_user_id_by_uuid(user_id.value)
+ groups = sql.select_user_groups_with_names(id=group_id)
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True)
template = env.get_template('/show_user_current_group.html')
- template = template.render(groups=groups, group=group.value, id=id)
+ template = template.render(groups=groups, group=group.value, id=group_id)
print(template)
if form.getvalue('newsmon') is not None:
@@ -1981,7 +1969,7 @@ if form.getvalue('newsmon') is not None:
try:
port = int(port)
- except:
+ except Exception:
print('SMON error: port must number')
sys.exit()
if port > 65535 or port < 0:
@@ -2007,10 +1995,10 @@ if form.getvalue('newsmon') is not None:
if form.getvalue('smondel') is not None:
user_group = funct.get_user_group(id=1)
- id = form.getvalue('smondel')
+ smon_id = form.getvalue('smondel')
if funct.check_user_group():
- if sql.delete_smon(id, user_group):
+ if sql.delete_smon(smon_id, user_group):
print('Ok')
funct.logging('SMON', ' Has been delete server from SMON ', haproxywi=1, login=1)
@@ -2026,7 +2014,7 @@ if form.getvalue('showsmon') is not None:
print(template)
if form.getvalue('updateSmonIp') is not None:
- id = form.getvalue('id')
+ smon_id = form.getvalue('id')
ip = form.getvalue('updateSmonIp')
port = form.getvalue('updateSmonPort')
en = form.getvalue('updateSmonEn')
@@ -2038,7 +2026,7 @@ if form.getvalue('updateSmonIp') is not None:
try:
port = int(port)
- except:
+ except Exception:
print('SMON error: port must number')
sys.exit()
if port > 65535 or port < 0:
@@ -2051,7 +2039,7 @@ if form.getvalue('updateSmonIp') is not None:
print('SMON error: Cannot be HTTP with 443 port')
sys.exit()
- if sql.update_smon(id, ip, port, body, telegram, group, desc, en):
+ if sql.update_smon(smon_id, ip, port, body, telegram, group, desc, en):
print("Ok")
funct.logging('SMON', ' Has been update the server ' + ip + ' to SMON ', haproxywi=1, login=1)
@@ -2086,7 +2074,7 @@ if form.getvalue('alert_consumer'):
message = sql.select_alerts(user_group)
for m in message:
print(m[0] + ': ' + m[1] + ' date: ' + m[2] + ';')
- except:
+ except Exception:
pass
if form.getvalue('waf_rule_id'):
@@ -2107,7 +2095,7 @@ if form.getvalue('waf_rule_id'):
try:
funct.logging('WAF', ' Has been ' + en_for_log + ' WAF rule: ' + rule_file + ' for the server ' + serv,
haproxywi=1, login=1)
- except:
+ except Exception:
pass
print(funct.ssh_command(serv, cmd))
@@ -2153,7 +2141,7 @@ if form.getvalue('lets_domain'):
l = l.split('"')[1]
print(l + " ")
break
- except:
+ except Exception:
print(output)
break
else:
@@ -2218,3 +2206,26 @@ if form.getvalue('actionvpn') is not None:
except IOError as e:
print(e.args[0])
funct.logging('localhost', e.args[0], haproxywi=1)
+
+if form.getvalue('scan_ports') is not None:
+ serv_id = form.getvalue('scan_ports')
+ server = sql.select_servers(id=serv_id)
+
+ for s in server:
+ ip = s[2]
+
+ cmd = "sudo nmap -sS %s |grep -E '^[[:digit:]]'|sed 's/ */ /g'" % ip
+ cmd1 = "sudo nmap -sS %s |head -5|tail -3" % ip
+
+ stdout, stderr = funct.subprocess_execute(cmd)
+ stdout1, stderr1 = funct.subprocess_execute(cmd1)
+
+ if stderr != '':
+ print(stderr)
+ else:
+ from jinja2 import Environment, FileSystemLoader
+
+ env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
+ template = env.get_template('ajax/scan_ports.html')
+ template = template.render(ports=stdout, info=stdout1)
+ print(template)
diff --git a/app/scripts/install_haproxy.sh b/app/scripts/install_haproxy.sh
index 0aeada27..1aa2ee28 100644
--- a/app/scripts/install_haproxy.sh
+++ b/app/scripts/install_haproxy.sh
@@ -24,6 +24,10 @@ done
export ANSIBLE_HOST_KEY_CHECKING=False
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
+export ACTION_WARNINGS=False
+export LOCALHOST_WARNING=False
+export COMMAND_WARNINGS=False
+
PWD=`pwd`
PWD=$PWD/scripts/ansible/
echo $HOST > $PWD/$HOST
diff --git a/app/scripts/install_keepalived.sh b/app/scripts/install_keepalived.sh
index 8ff2e93b..9ae7bf4d 100644
--- a/app/scripts/install_keepalived.sh
+++ b/app/scripts/install_keepalived.sh
@@ -23,6 +23,10 @@ done
export ANSIBLE_HOST_KEY_CHECKING=False
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
+export ACTION_WARNINGS=False
+export LOCALHOST_WARNING=False
+export COMMAND_WARNINGS=False
+
PWD=`pwd`
PWD=$PWD/scripts/ansible/
echo $HOST > $PWD/$HOST
diff --git a/app/scripts/install_nginx.sh b/app/scripts/install_nginx.sh
index 0a55e424..b6ea929f 100644
--- a/app/scripts/install_nginx.sh
+++ b/app/scripts/install_nginx.sh
@@ -32,6 +32,9 @@ fi
export ANSIBLE_HOST_KEY_CHECKING=False
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
export ACTION_WARNINGS=False
+export LOCALHOST_WARNING=False
+export COMMAND_WARNINGS=False
+
PWD=`pwd`
PWD=$PWD/scripts/ansible/
echo $HOST > $PWD/$HOST
@@ -44,7 +47,9 @@ fi
if [ $? -gt 0 ]
then
- echo "error: Can't install Nginx service "
- exit 1
+ echo "error: Can't install Nginx service "
+ exit 1
+else
+ echo "ok"
fi
rm -f $PWD/$HOST
diff --git a/app/scripts/install_nginx_exporter.sh b/app/scripts/install_nginx_exporter.sh
index 15efc0e9..66d63a59 100644
--- a/app/scripts/install_nginx_exporter.sh
+++ b/app/scripts/install_nginx_exporter.sh
@@ -30,7 +30,9 @@ fi
export ANSIBLE_HOST_KEY_CHECKING=False
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
export ACTION_WARNINGS=False
-export ANSIBLE_DEPRECATION_WARNINGS=False
+export LOCALHOST_WARNING=False
+export COMMAND_WARNINGS=False
+
PWD=`pwd`
PWD=$PWD/scripts/ansible/
echo $HOST > $PWD/$HOST
diff --git a/app/templates/add.html b/app/templates/add.html
index 169b92b5..d85994fc 100644
--- a/app/templates/add.html
+++ b/app/templates/add.html
@@ -795,11 +795,15 @@
- Server for upload
- New blacklist
+ New blacklist
+ Server for uploading
Existing blacklists
+
+ Name: {{ input('new_blacklist_name') }}
+ Create
+
Choose server
@@ -809,10 +813,6 @@
{% endfor %}
-
- Name: {{ input('new_blacklist_name') }}
- Create
-
{% for list in black_lists %}
{{ list }}
@@ -824,11 +824,15 @@
- Server for upload
- New whitelist
+ New whitelist
+ Server for uploading
Existing whitelists
+
+ Name: {{ input('new_whitelist_name') }}
+ Create
+
Choose server
@@ -838,10 +842,6 @@
{% endfor %}
-
- Name: {{ input('new_whitelist_name') }}
- Create
-
{% for list in white_lists %}
{{ list }}
diff --git a/app/templates/ajax/smon_dashboard.html b/app/templates/ajax/smon_dashboard.html
index 1f7e1fdf..c3e1a3fd 100644
--- a/app/templates/ajax/smon_dashboard.html
+++ b/app/templates/ajax/smon_dashboard.html
@@ -1,7 +1,7 @@
+
+ scan
+
{% set id = 'desc-' + server.0|string() %}
{% if server.11 != "None" %}
diff --git a/app/templates/metrics.html b/app/templates/metrics.html
index 36f66a59..76d5cc48 100644
--- a/app/templates/metrics.html
+++ b/app/templates/metrics.html
@@ -29,16 +29,24 @@ th, tr, td {
{% include 'include/getstarted.html' %}
{% else %}
-
-
+
+ Time range:
+
+ 30 minutes
+ 1 hour
+ 3 hours
+ 6 hours
+ 12 hours
+
+
+
+
-
{% for s in servers %}
{% endfor %}
-
{% endif %}
{% endif %}
diff --git a/app/templates/sections.html b/app/templates/sections.html
index a2319300..c1015211 100644
--- a/app/templates/sections.html
+++ b/app/templates/sections.html
@@ -5,14 +5,8 @@
- Choose a section
WAF mode
-
+
Metrics
@@ -85,7 +86,17 @@
-
+
+ Time range:
+
+ 30 minutes
+ 1 hour
+ 3 hours
+ 6 hours
+ 12 hours
+
+
+
{% for s in servers %}
@@ -104,6 +115,18 @@
}
showWafMetrics();
showOverviewWaf(ip, hostnamea);
+ $( function() {
+ $("#time-range").on('selectmenuchange', function () {
+ removeData()
+ let metrics = new Promise(
+ (resolve, reject) => {
+ {% for s in servers %}
+ getWafChartData('{{s.0}}')
+ {% endfor %}
+ });
+ metrics.then();
+ });
+ });
You can read the description and watch a video about WAF
here
diff --git a/inc/add.js b/inc/add.js
index 55ed4a48..fe8eec8b 100644
--- a/inc/add.js
+++ b/inc/add.js
@@ -1313,8 +1313,7 @@ function createList(color) {
toastr.info(data);
} else if (data.indexOf('success') != '-1' ) {
toastr.clear();
- toastr.success('WAF service has installed');
- showOverviewWaf(ip, hostnamea)
+ toastr.success('List has been created');
setTimeout(function () {
location.reload();
}, 2500);
@@ -1383,7 +1382,7 @@ function saveList(action, list, color) {
for (i = 0; i < data.length; i++) {
if (data[i]) {
- if (data[i].indexOf('error:') != '-1') {
+ if (data[i].indexOf('error: ') != '-1') {
toastr.error(data[i]);
} else {
toastr.success(data[i]);
diff --git a/inc/metrics.js b/inc/metrics.js
index 53ef72e0..6aca2e5d 100644
--- a/inc/metrics.js
+++ b/inc/metrics.js
@@ -4,6 +4,7 @@ function getChartData(server) {
data: {
new_metrics: '1',
server: server,
+ time_range: $( "#time-range option:selected" ).val(),
token: $('#token').val()
},
type: "POST",
@@ -19,6 +20,13 @@ function getChartData(server) {
}
});
}
+function removeData() {
+ for (i = 0; i < charts.length; i++) {
+ chart = charts[i];
+ chart.destroy();
+ }
+}
+var charts = []
function renderChart(data, labels, server) {
var ctx = document.getElementById(server)
var myChart = new Chart(ctx, {
@@ -85,6 +93,7 @@ function renderChart(data, labels, server) {
}
}
});
+ charts.push(myChart);
}
function getWafChartData(server) {
@@ -93,6 +102,7 @@ function getWafChartData(server) {
data: {
new_waf_metrics: '1',
server: server,
+ time_range: $( "#time-range option:selected" ).val(),
token: $('#token').val()
},
type: "POST",
@@ -158,8 +168,9 @@ function renderWafChart(data, labels, server) {
}
}
});
+ charts.push(myChart);
}
-
+console.log(charts);
$("#secIntervals").css("display", "none");
function loadMetrics() {
diff --git a/inc/script.js b/inc/script.js
index 5014d503..f2c8cd9e 100644
--- a/inc/script.js
+++ b/inc/script.js
@@ -308,7 +308,7 @@ function showStats() {
},
type: "POST",
success: function( data ) {
- if (data.indexOf('error:') != '-1') {
+ if (data.indexOf('error:') != '-1' && data.indexOf('Internal error:') == '-1') {
toastr.error(data);
} else {
toastr.clear();
diff --git a/inc/style.css b/inc/style.css
index 5e074b99..6ca8ba79 100644
--- a/inc/style.css
+++ b/inc/style.css
@@ -394,7 +394,7 @@ pre {
font-weight: bold;
}
.serverUp {
- background-color: #5CB85C;
+ background-color: #5ad05a;
}
.serverNone {
background-color: #ddd;
@@ -421,7 +421,7 @@ pre {
font-size: 13px;
}
.serverDown {
- background-color: red;
+ background-color: #be2424;
}
.padding10 {
padding: 10px 10px 10px 0;
@@ -745,6 +745,27 @@ label {
.div-server {
height: 95px;
}
+.div-server-head-up {
+ border-top: 3px solid #5ad05a !important;
+}
+.div-server-head-down {
+ border-top: 3px solid #be2424 !important;
+}
+.div-server-head-dis {
+ border-top: 3px solid #aaa !important;
+}
+.div-server-head-up, .div-server-head-down, .div-server-head-dis {
+ padding-top: 7px;
+}
+.add-proxy-listen-head {
+ border-top: 3px solid #02869b;
+}
+.add-proxy-frontend-head {
+ border-top: 3px solid #00a4bd;
+}
+.add-proxy-backend-head {
+ border-top: 3px solid #00b8d7;
+}
.div-backends {
width: 89.3%;
}
@@ -862,6 +883,7 @@ label {
background-color: #fbfbfb;;
margin: 10px;
padding-left: 15px;
+ padding-top: 0;
border: 1px solid #A4C7F5;
}
#good_services {
@@ -947,15 +969,17 @@ label {
}
.div-server {
margin-bottom: 30px !important;
- width: 43%;
+ width: 300px;
height: 100px;
}
+ .server-desc {
+ width: 300px;
+ }
}
@media (max-width: 1280px) {
.div-server {
margin-bottom: 30px !important;
- width: 90%;
- height: 70px;
+ height: 100px;
}
#ssl_name {
width: 100px;
diff --git a/inc/users.js b/inc/users.js
index 0d28f419..5597e7ba 100644
--- a/inc/users.js
+++ b/inc/users.js
@@ -173,6 +173,7 @@ $( function() {
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
+ $("#ajax").html('')
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') {
toastr.error(data);
} else if (data.indexOf('success') != '-1' ){
@@ -205,6 +206,7 @@ $( function() {
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
+ $("#ajax").html('')
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') {
toastr.clear();
toastr.error(data);
@@ -222,7 +224,7 @@ $( function() {
} );
});
$('#grafna_install').click(function() {
- $("#ajaxmon").html('')
+ $("#ajaxmon").html('');
$("#ajaxmon").html(wait_mess);
$.ajax( {
url: "options.py",
@@ -233,6 +235,7 @@ $( function() {
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
+ $("#ajaxmon").html('');
if (data.indexOf('FAILED') != '-1') {
toastr.clear();
toastr.error(data);;
@@ -261,6 +264,7 @@ $( function() {
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
+ $("#ajaxmon").html('');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') {
toastr.clear();
toastr.error(data);
@@ -291,6 +295,7 @@ $( function() {
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
+ $("#ajaxmon").html('');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') {
toastr.error(data);
} else if (data.indexOf('success') != '-1' ){
@@ -2046,4 +2051,36 @@ function OpenVpnSess(id, action) {
}
}
} );
-}
\ No newline at end of file
+}
+function scanPorts(id) {
+ $.ajax({
+ url: "options.py",
+ data: {
+ scan_ports: id,
+ token: $('#token').val()
+ },
+ type: "POST",
+ success: function (data) {
+ data = data.replace(/\s+/g, ' ');
+ if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
+ toastr.error(data);
+ } else {
+ toastr.clear();
+ $("#show_scans_ports_body").html(data);
+ $("#show_scans_ports" ).dialog({
+ resizable: false,
+ height: "auto",
+ width: 360,
+ modal: true,
+ title: "Openned ports",
+ buttons: {
+ Close: function() {
+ $( this ).dialog( "close" );
+ $("#show_scans_ports_body").html('');
+ }
+ }
+ });
+ }
+ }
+ } );
+}
diff --git a/inc/waf.js b/inc/waf.js
index 626949b5..5ce5d7fc 100644
--- a/inc/waf.js
+++ b/inc/waf.js
@@ -80,6 +80,7 @@ function installWaf(ip1) {
}
function changeWafMode(id) {
var waf_mode = $('#'+id+' option:selected').val();
+ console.log('1')
var server_hostname = id.split('_')[0];
$.ajax( {
url: "options.py",
@@ -105,14 +106,12 @@ $( function() {
});
});
function waf_rules_en(id) {
+ console.log('1')
var enable = 0;
if ($('#rule_id-'+id).is(':checked')) {
enable = '1';
}
var serv = findGetParameter('serv')
- console.log(serv)
- console.log(id)
- console.log(enable)
$.ajax( {
url: "options.py",
data: {
@@ -134,4 +133,4 @@ function waf_rules_en(id) {
}
}
} );
-}
\ No newline at end of file
+}