pull/161/head
Pavel Loginov 2019-10-21 09:00:16 +03:00
parent 52aec4ae5b
commit 55693e05d4
23 changed files with 501 additions and 550 deletions

View File

@ -193,11 +193,6 @@ def update_db_v_31(**kwargs):
con.commit()
except sqltool.Error as e:
pass
# if kwargs.get('silent') != 1:
# if e.args[0] == 'column param is not unique' or e == "1060 (42S21): column param is not unique ":
# print('Updating... go to version 3.2')
# else:
# print("An error occurred:", e)
else:
if kwargs.get('silent') != 1:
print('Updating... go to version 3.2')
@ -440,7 +435,7 @@ def update_db_v_3_5_3(**kwargs):
def update_ver(**kwargs):
con, cur = get_cur()
sql = """update version set version = '3.5.7'; """
sql = """update version set version = '3.5.7.1'; """
try:
cur.execute(sql)
con.commit()
@ -497,7 +492,6 @@ def update_all():
update_ver()
def update_all_silent():
update_db_v_31(silent=1)
update_db_v_3_2(silent=1)
@ -517,7 +511,6 @@ def update_all_silent():
update_ver()
if __name__ == "__main__":
create_table()
update_all()

View File

@ -602,10 +602,16 @@ def show_backends(serv, **kwargs):
def get_files(dir = get_config_var('configs', 'haproxy_save_configs_dir'), format = 'cfg', **kwargs):
import glob
if format == 'log':
file = []
else:
file = set()
return_files = set()
for files in glob.glob(os.path.join(dir,'*.'+format)):
if format == 'log':
file += [(files.split('/')[5], files.split('/')[5])]
else:
file.add(files.split('/')[-1])
files = sorted(file, reverse=True)

View File

@ -1,32 +0,0 @@
#!/usr/bin/env python3
import http.cookies
import cgi
import os
import funct, sql
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('ihap.html')
print('Content-type: text/html\n')
funct.check_login()
funct.page_for_admin(level = 2)
try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
user = sql.get_user_name_by_uuid(user_id.value)
servers = sql.get_dick_permit()
token = sql.get_token(user_id.value)
except:
pass
output_from_parsed_template = template.render(h2 = 1, title = "Installation HAProxy",
role = sql.get_user_role_by_uuid(user_id.value),
user = user,
select_id = "haproxyaddserv",
selects = servers,
versions = funct.versions(),
token = token)
print(output_from_parsed_template)

View File

@ -4,7 +4,7 @@ import cgi
import os, sys
import funct
import sql
import ovw
import asyncio
form = cgi.FieldStorage()
serv = form.getvalue('serv')
@ -102,17 +102,21 @@ if serv and form.getvalue('ssl_cert'):
os.system("mv %s %s" % (name, cert_local_dir))
funct.logging(serv, "add.py#ssl upload new ssl cert %s" % name)
if form.getvalue('backend') is not None:
funct.show_backends(serv)
if form.getvalue('ip') is not None and serv is not None:
commands = [ "sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'" ]
funct.ssh_command(serv, commands, ip="1")
if form.getvalue('showif'):
commands = ["sudo ip link|grep 'UP' | awk '{print $2}' |awk -F':' '{print $1}'"]
funct.ssh_command(serv, commands, ip="1")
if form.getvalue('action_hap') is not None and serv is not None:
action = form.getvalue('action_hap')
@ -124,6 +128,7 @@ if form.getvalue('action_hap') is not None and serv is not None:
else:
print("Bad config, check please")
if form.getvalue('action_waf') is not None and serv is not None:
serv = form.getvalue('serv')
action = form.getvalue('action_waf')
@ -131,16 +136,123 @@ if form.getvalue('action_waf') is not None and serv is not None:
commands = [ "sudo systemctl %s waf" % action ]
funct.ssh_command(serv, commands)
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'))
server_status = (serv1,
serv2,
funct.server_status(funct.subprocess_execute(cmd)),
sql.select_servers(server=serv2, keep_alive=1),
funct.ssh_command(serv2, commands2),
sql.select_waf_servers(serv2))
return server_status
async def get_runner_overview():
import http.cookies
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
servers = []
template = env.get_template('overview.html')
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
futures = [async_get_overview(server[1], server[2]) for server in sql.get_dick_permit()]
for i, future in enumerate(asyncio.as_completed(futures)):
result = await future
servers.append(result)
servers_sorted = sorted(servers, key=funct.get_key)
template = template.render(service_status=servers_sorted, role=sql.get_user_role_by_uuid(user_id.value))
print(template)
if act == "overview":
ovw.get_overview()
ioloop = asyncio.get_event_loop()
ioloop.run_until_complete(get_runner_overview())
ioloop.close()
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 ]
server_status = (serv1,serv2, funct.ssh_command(serv2, commands), funct.ssh_command(serv2, commands1).strip(), sql.select_waf_metrics_enable_server(serv2))
return server_status
async def get_runner_overviewWaf(url):
import http.cookies
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
template = env.get_template('overivewWaf.html')
servers = []
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
futures = [async_get_overviewWaf(server[1], server[2]) for server in sql.get_dick_permit()]
for i, future in enumerate(asyncio.as_completed(futures)):
result = await future
servers.append(result)
servers_sorted = sorted(servers, key=funct.get_key)
template = template.render(service_status=servers_sorted, role=sql.get_user_role_by_uuid(user_id.value), url=url)
print(template)
if act == "overviewwaf":
ovw.get_overviewWaf(form.getvalue('page'))
ioloop = asyncio.get_event_loop()
ioloop.run_until_complete(get_runner_overviewWaf(form.getvalue('page')))
ioloop.close()
async def async_get_overviewServers(serv1, serv2):
server_status = ()
commands = [ "top -u haproxy -b -n 1 -w 67 |grep -e 'haproxy\|PID\|Cpu\|KiB' |grep -v Swap" ]
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Ver\|CurrConns\|Maxco\|MB\|Uptime:"' % (serv2, sql.get_setting('haproxy_sock_port'))
out = funct.subprocess_execute(cmd)
out1 = ""
for k in out:
if "Ncat:" not in k:
for r in k:
out1 += r
out1 += "<br />"
else:
out1 = "Can\'t connect to HAproxy"
server_status = (serv1,serv2, out1, funct.ssh_command(serv2, commands))
return server_status
async def get_runner_overviewServers(**kwargs):
import http.cookies
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
template = env.get_template('overviewServers.html')
servers = []
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
role = sql.get_user_role_by_uuid(user_id.value)
futures = [async_get_overviewServers(kwargs.get('server1'), kwargs.get('server2'))]
for i, future in enumerate(asyncio.as_completed(futures)):
result = await future
servers.append(result)
servers_sorted = sorted(servers, key=funct.get_key)
template = template.render(service_status=servers_sorted, role=role, id=kwargs.get('id'))
print(template)
if act == "overviewServers":
id = form.getvalue('id')
name = form.getvalue('name')
ovw.get_overviewServers(ip=serv,name=name,id=form.getvalue('id'))
ioloop = asyncio.get_event_loop()
ioloop.run_until_complete(get_runner_overviewServers(server1=name, server2=serv, id=id))
ioloop.close()
if act == "overviewHapwi":
@ -178,6 +290,7 @@ if form.getvalue('action'):
q = requests.post('http://'+serv+':'+stats_port+'/'+stats_page, headers=headers, data=postdata, auth=(haproxy_user, haproxy_pass))
if serv is not None and act == "stats":
import requests
from requests_toolbelt.utils import dump
@ -204,6 +317,7 @@ if serv is not None and act == "stats":
data = response.content
print(data.decode('utf-8'))
if serv is not None and form.getvalue('rows') is not None:
rows = form.getvalue('rows')
waf = form.getvalue('waf')
@ -236,6 +350,7 @@ if serv is not None and form.getvalue('rows') is not None:
funct.ssh_command(syslog_server, commands, show_log="1")
if serv is not None and form.getvalue('rows1') is not None:
rows = form.getvalue('rows1')
grep = form.getvalue('grep')
@ -263,6 +378,7 @@ if serv is not None and form.getvalue('rows1') is not None:
funct.show_log(output)
print(stderr)
if form.getvalue('viewlogs') is not None:
viewlog = form.getvalue('viewlogs')
log_path = funct.get_config_var('main', 'log_path')
@ -287,8 +403,112 @@ if form.getvalue('viewlogs') is not None:
funct.show_log(output)
print(stderr)
if serv is not None and act == "showMap":
ovw.get_map(serv)
from datetime import datetime
from pytz import timezone
import networkx as nx
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
stats_port= sql.get_setting('stats_port')
haproxy_config_path = sql.get_setting('haproxy_config_path')
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
date = funct.get_data('config')
cfg = hap_configs_dir + serv + "-" + date + ".cfg"
print('<center>')
print("<h4>Map from %s</h4><br />" % serv)
G = nx.DiGraph()
error = funct.get_config(serv, cfg)
if error:
print('<div class="alert alert-danger">'+error+'</div>')
try:
conf = open(cfg, "r")
except IOError:
print('<div class="alert alert-danger">Can\'t read import config file</div>')
node = ""
line_new2 = [1,""]
i,k = 800, 800
j, m = 0, 0
for line in conf:
if line.startswith('listen') or line.startswith('frontend'):
if "stats" not in line:
node = line
i = i - 750
if line.find("backend") == 0:
node = line
i = i - 700
G.add_node(node,pos=(k,i),label_pos=(k,i+100))
if "bind" in line or (line.startswith('listen') and ":" in line) or (line.startswith('frontend') and ":" in line):
try:
bind = line.split(":")
if stats_port not in bind[1]:
bind[1] = bind[1].strip(' ')
bind = bind[1].split("crt")
node = node.strip(' \t\n\r')
node = node + ":" + bind[0]
G.add_node(node,pos=(k,i),label_pos=(k,i+100))
except:
pass
if "server " in line or "use_backend" in line or "default_backend" in line and "stats" not in line and "#" not in line:
if "timeout" not in line and "default-server" not in line and "#" not in line and "stats" not in line:
i = i - 1050
j = j + 1
if "check" in line:
line_new = line.split("check")
else:
line_new = line.split("if ")
if "server" in line:
line_new1 = line_new[0].split("server")
line_new[0] = line_new1[1]
line_new2 = line_new[0].split(":")
line_new[0] = line_new2[0]
line_new[0] = line_new[0].strip(' \t\n\r')
line_new2[1] = line_new2[1].strip(' \t\n\r')
if j % 2 == 0:
G.add_node(line_new[0],pos=(k+230,i-335),label_pos=(k+225,i-180))
else:
G.add_node(line_new[0],pos=(k-230,i-0),label_pos=(k-225,i+180))
if line_new2[1] != "":
G.add_edge(node, line_new[0], port=line_new2[1])
else:
G.add_edge(node,line_new[0])
os.system("/bin/rm -f " + cfg)
pos=nx.get_node_attributes(G,'pos')
pos_label=nx.get_node_attributes(G,'label_pos')
edge_labels = nx.get_edge_attributes(G,'port')
try:
plt.figure(10,figsize=(10,15))
nx.draw(G, pos, with_labels=False, font_weight='bold', width=3, alpha=0.1,linewidths=5)
nx.draw_networkx_nodes(G,pos, node_color="skyblue", node_size=100, alpha=0.8, node_shape="p")
nx.draw_networkx_labels(G,pos=pos_label, alpha=1, font_color="green", font_size=10)
nx.draw_networkx_edges(G,pos, width=0.5,alpha=0.5, edge_color="#5D9CEB",arrows=False)
nx.draw_networkx_edge_labels(G, pos,label_pos=0.5,font_color="blue", labels=edge_labels, font_size=8)
plt.savefig("map.png")
plt.show()
except Exception as e:
print('<div class="alert alert-danger">' + str(e) + '</div>')
cmd = "rm -f "+os.path.dirname(os.getcwd())+"/map*.png && mv map.png "+os.path.dirname(os.getcwd())+"/map"+date+".png"
output, stderr = funct.subprocess_execute(cmd)
print(stderr)
print('<img src="/map%s.png" alt="map">' % date)
if form.getvalue('servaction') is not None:
server_state_file = sql.get_setting('server_state_file')
@ -310,6 +530,7 @@ if form.getvalue('servaction') is not None:
action = 'edit.py ' + enable + ' ' + backend
funct.logging(serv, action)
if act == "showCompareConfigs":
import glob
from jinja2 import Environment, FileSystemLoader
@ -321,6 +542,7 @@ if act == "showCompareConfigs":
template = template.render(serv=serv, right=right, left=left, return_files=funct.get_files())
print(template)
if serv is not None and form.getvalue('right') is not None:
from jinja2 import Environment, FileSystemLoader
left = form.getvalue('left')
@ -336,6 +558,7 @@ if serv is not None and form.getvalue('right') is not None:
print(template)
print(stderr)
if serv is not None and act == "configShow":
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
@ -360,6 +583,7 @@ if serv is not None and act == "configShow":
if form.getvalue('configver') is None:
os.system("/bin/rm -f " + cfg)
if form.getvalue('master'):
master = form.getvalue('master')
slave = form.getvalue('slave')
@ -390,6 +614,7 @@ if form.getvalue('master'):
os.system("rm -f %s" % script)
sql.update_server_master(master, slave)
if form.getvalue('masteradd'):
master = form.getvalue('masteradd')
slave = form.getvalue('slaveadd')
@ -412,9 +637,11 @@ if form.getvalue('masteradd'):
os.system("rm -f %s" % script)
if form.getvalue('haproxyaddserv'):
funct.install_haproxy(form.getvalue('haproxyaddserv'), syn_flood=form.getvalue('syn_flood'), hapver=form.getvalue('hapver'))
if form.getvalue('installwaf'):
funct.waf_install(form.getvalue('installwaf'))
@ -422,9 +649,11 @@ if form.getvalue('installwaf'):
if form.getvalue('update_haproxy_wi'):
funct.update_haproxy_wi()
if form.getvalue('metrics_waf'):
sql.update_waf_metrics_enable(form.getvalue('metrics_waf'), form.getvalue('enable'))
if form.getvalue('table_metrics'):
import http.cookies
from jinja2 import Environment, FileSystemLoader
@ -498,6 +727,7 @@ if form.getvalue('get_hap_v'):
output = funct.check_haproxy_version(serv)
print(output)
if form.getvalue('bwlists'):
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+form.getvalue('color')+"/"+form.getvalue('bwlists')
try:
@ -508,6 +738,7 @@ if form.getvalue('bwlists'):
except IOError:
print('<div class="alert alert-danger" style="margin:0">Cat\'n read '+form.getvalue('color')+' list</div>')
if form.getvalue('bwlists_create'):
list_name = form.getvalue('bwlists_create').split('.')[0]
list_name += '.lst'
@ -518,6 +749,7 @@ if form.getvalue('bwlists_create'):
except IOError as e:
print('<div class="alert alert-danger" style="margin:0">Cat\'n create new '+form.getvalue('color')+' list. %s </div>' % e)
if form.getvalue('bwlists_save'):
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+form.getvalue('color')+"/"+form.getvalue('bwlists_save')
try:
@ -539,12 +771,14 @@ if form.getvalue('bwlists_save'):
if form.getvalue('bwlists_restart') == 'restart':
funct.ssh_command(server[2], ["sudo " + sql.get_setting('restart_command')])
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)
if form.getvalue('get_ldap_email'):
username = form.getvalue('get_ldap_email')
import ldap

View File

@ -1,210 +0,0 @@
import funct
import os
import sql
import asyncio
import http.cookies
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
listhap = sql.get_dick_permit()
servers = []
server_status = ()
async def async_get_overview(serv1, serv2):
# haproxy_config_path = sql.get_setting('haproxy_config_path')
# commands = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ]
commands2 = [ "ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l" ]
# commands2 = "ps ax |grep keep_alive.py |grep -v grep |wc -l"
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Process_num"' % (serv2, haproxy_sock_port)
server_status = (serv1,
serv2,
funct.server_status(funct.subprocess_execute(cmd)),
sql.select_servers(server=serv2, keep_alive=1),
funct.ssh_command(serv2, commands2),
sql.select_waf_servers(serv2))
return server_status
async def get_runner_overview():
template = env.get_template('overview.html')
futures = [async_get_overview(server[1], server[2]) for server in listhap]
for i, future in enumerate(asyncio.as_completed(futures)):
result = await future
servers.append(result)
servers_sorted = sorted(servers, key=funct.get_key)
template = template.render(service_status=servers_sorted, role=sql.get_user_role_by_uuid(user_id.value))
print(template)
def get_overview():
ioloop = asyncio.get_event_loop()
ioloop.run_until_complete(get_runner_overview())
ioloop.close()
async def async_get_overviewWaf(serv1, serv2):
haproxy_dir = sql.get_setting('haproxy_dir')
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 ]
server_status = (serv1,serv2, funct.ssh_command(serv2, commands), funct.ssh_command(serv2, commands1).strip(), sql.select_waf_metrics_enable_server(serv2))
return server_status
async def get_runner_overviewWaf(url):
template = env.get_template('overivewWaf.html')
futures = [async_get_overviewWaf(server[1], server[2]) for server in listhap]
for i, future in enumerate(asyncio.as_completed(futures)):
result = await future
servers.append(result)
servers_sorted = sorted(servers, key=funct.get_key)
template = template.render(service_status=servers_sorted, role=sql.get_user_role_by_uuid(user_id.value), url=url)
print(template)
def get_overviewWaf(url):
ioloop = asyncio.get_event_loop()
ioloop.run_until_complete(get_runner_overviewWaf(url))
ioloop.close()
async def async_get_overviewServers(serv1, serv2):
commands = [ "top -u haproxy -b -n 1 -w 67 |grep -e 'haproxy\|PID\|Cpu\|KiB' |grep -v Swap" ]
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Ver\|CurrConns\|Maxco\|MB\|Uptime:"' % (serv2, haproxy_sock_port)
out = funct.subprocess_execute(cmd)
out1 = ""
for k in out:
if "Ncat:" not in k:
for r in k:
out1 += r
out1 += "<br />"
else:
out1 = "Can\'t connect to HAproxy"
server_status = (serv1,serv2, out1, funct.ssh_command(serv2, commands))
return server_status
async def get_runner_overviewServers(**kwargs):
template = env.get_template('overviewServers.html')
user_id = cookie.get('uuid')
role = sql.get_user_role_by_uuid(user_id.value)
futures = [async_get_overviewServers(kwargs.get('server1'), kwargs.get('server2'))]
for i, future in enumerate(asyncio.as_completed(futures)):
result = await future
servers.append(result)
servers_sorted = sorted(servers, key=funct.get_key)
template = template.render(service_status=servers_sorted, role=role, id=kwargs.get('id'))
print(template)
def get_overviewServers(**kwargs):
server1 = kwargs.get('name')
server2 = kwargs.get('ip')
id = kwargs.get('id')
ioloop = asyncio.get_event_loop()
ioloop.run_until_complete(get_runner_overviewServers(server1=server1, server2=server2, id=id))
ioloop.close()
def get_map(serv):
from datetime import datetime
from pytz import timezone
import networkx as nx
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
stats_port= sql.get_setting('stats_port')
haproxy_config_path = sql.get_setting('haproxy_config_path')
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
date = funct.get_data('config')
cfg = hap_configs_dir + serv + "-" + date + ".cfg"
print('<center>')
print("<h4>Map from %s</h4><br />" % serv)
G = nx.DiGraph()
error = funct.get_config(serv, cfg)
if error:
print('<div class="alert alert-danger">'+error+'</div>')
try:
conf = open(cfg, "r")
except IOError:
print('<div class="alert alert-danger">Can\'t read import config file</div>')
node = ""
line_new2 = [1,""]
i,k = 800, 800
j, m = 0, 0
for line in conf:
if line.startswith('listen') or line.startswith('frontend'):
if "stats" not in line:
node = line
i = i - 750
if line.find("backend") == 0:
node = line
i = i - 700
G.add_node(node,pos=(k,i),label_pos=(k,i+100))
if "bind" in line or (line.startswith('listen') and ":" in line) or (line.startswith('frontend') and ":" in line):
try:
bind = line.split(":")
if stats_port not in bind[1]:
bind[1] = bind[1].strip(' ')
bind = bind[1].split("crt")
node = node.strip(' \t\n\r')
node = node + ":" + bind[0]
G.add_node(node,pos=(k,i),label_pos=(k,i+100))
except:
pass
if "server " in line or "use_backend" in line or "default_backend" in line and "stats" not in line and "#" not in line:
if "timeout" not in line and "default-server" not in line and "#" not in line and "stats" not in line:
i = i - 1050
j = j + 1
if "check" in line:
line_new = line.split("check")
else:
line_new = line.split("if ")
if "server" in line:
line_new1 = line_new[0].split("server")
line_new[0] = line_new1[1]
line_new2 = line_new[0].split(":")
line_new[0] = line_new2[0]
line_new[0] = line_new[0].strip(' \t\n\r')
line_new2[1] = line_new2[1].strip(' \t\n\r')
if j % 2 == 0:
G.add_node(line_new[0],pos=(k+230,i-335),label_pos=(k+225,i-180))
else:
G.add_node(line_new[0],pos=(k-230,i-0),label_pos=(k-225,i+180))
if line_new2[1] != "":
G.add_edge(node, line_new[0], port=line_new2[1])
else:
G.add_edge(node,line_new[0])
os.system("/bin/rm -f " + cfg)
pos=nx.get_node_attributes(G,'pos')
pos_label=nx.get_node_attributes(G,'label_pos')
edge_labels = nx.get_edge_attributes(G,'port')
try:
plt.figure(10,figsize=(10,15))
nx.draw(G, pos, with_labels=False, font_weight='bold', width=3, alpha=0.1,linewidths=5)
nx.draw_networkx_nodes(G,pos, node_color="skyblue", node_size=100, alpha=0.8, node_shape="p")
nx.draw_networkx_labels(G,pos=pos_label, alpha=1, font_color="green", font_size=10)
nx.draw_networkx_edges(G,pos, width=0.5,alpha=0.5, edge_color="#5D9CEB",arrows=False)
nx.draw_networkx_edge_labels(G, pos,label_pos=0.5,font_color="blue", labels=edge_labels, font_size=8)
plt.savefig("map.png")
plt.show()
except Exception as e:
print('<div class="alert alert-danger">' + str(e) + '</div>')
cmd = "rm -f "+os.path.dirname(os.getcwd())+"/map*.png && mv map.png "+os.path.dirname(os.getcwd())+"/map"+date+".png"
output, stderr = funct.subprocess_execute(cmd)
print(stderr)
print('<img src="/map%s.png" alt="map">' % date)

View File

@ -1,32 +0,0 @@
#!/usr/bin/env python3
import cgi
import os
import funct
import sql
import http
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('settings.html')
form = cgi.FieldStorage()
print('Content-type: text/html\n')
funct.check_login()
funct.page_for_admin()
try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
user = sql.get_user_name_by_uuid(user_id.value)
settings = sql.get_setting('', all=1)
token = sql.get_token(user_id.value)
except:
pass
template = template.render(h2 = 1, title = "Settings",
role = sql.get_user_role_by_uuid(user_id.value),
user = user,
settings = settings,
versions = funct.versions(),
token = token)
print(template)

View File

@ -1405,13 +1405,13 @@ def check_token():
sys.exit()
def check_group(group):
def check_group(group, role_id):
import http.cookies
import os
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
user_group = get_user_group_by_uuid(user_id.value)
if user_group == group or user_group == '1':
if user_group == group or user_group == '1' or role_id == 1:
return True
else:
funct.logging(new_user, ' tried to change user group', haproxywi=1, login=1)
@ -1430,8 +1430,8 @@ if form.getvalue('newuser') is not None:
if password is None or role is None or group is None:
print(error_mess)
else:
if check_group(group):
role_id = get_role_id_by_name(role)
if check_group(group, role_id):
if funct.is_admin(level=role_id):
if add_user(new_user, email, password, role, group, activeuser):
show_update_user(new_user, page)
@ -1452,8 +1452,8 @@ if form.getvalue('updateuser') is not None:
if new_user is None or role is None or group is None:
print(error_mess)
else:
if check_group(group):
role_id = get_role_id_by_name(role)
if check_group(group, role_id):
if funct.is_admin(level=role_id):
update_user(new_user, email, role, group, id, activeuser)
else:

View File

@ -17,6 +17,8 @@
<li><a href="#servers">Servers</a></li>
<li><a href="#ssh">SSH credentials</a></li>
<li><a href="#checker">Checker</a></li>
<li><a href="#settings">Settings</a></li>
<li><a href="#updatehapwi">Update</a></li>
{% if user %}
<a href=/app/login.py?logout=logout title="Logout, user name: {{ user }}" class="login"> Logout</a>
{% else %}
@ -507,6 +509,92 @@
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=checker" title="Servers description" target="_blank">here</a>
</div>
</div>
<div id="settings">
<table id="settings">
<tr class="overviewHead">
<td class="padding10 first-collumn" style="width: 10%;">
Parameter
</td>
<td>
Value
</td>
<td>
Description
</td>
</tr>
{% set section = namespace(section='') %}
{% for set in settings %}
{% if section.section|string() != set.2|string() %}
<th colspan="3"><h3>{{ set.2 }} section</h3></th>
{% endif %}
{% set section.section = set.2 %}
<tr class="{{ loop.cycle('odd', 'even') }}">
<td class="addName">
<a href="#{{set.0}}" title="{{set.0}}" style="color: #000;">{{set.0}}</a>
</td>
<td class="addOption">
{% if set.0 == 'ldap_password' %}
{% if set.1 == 'None' %}
<input type="password" name="{{set.0}}" id="{{set.0}}" value="" title="" size="25" class="form-control">
{% else %}
<input type="password" name="{{set.0}}" id="{{set.0}}" value="{{set.1}}" title="" size="25" class="form-control">
{% endif %}
{% else %}
{% if set.1 == 'None' %}
<input type="text" name="{{set.0}}" id="{{set.0}}" value="" title="" size="25" class="form-control">
{% else %}
<input type="text" name="{{set.0}}" id="{{set.0}}" value="{{set.1}}" title="" size="25" class="form-control">
{% endif %}
{% endif %}
</td>
<td class="addOption">
{{set.3}}
</td>
</tr>
{% endfor %}
</table>
</div>
<div id="updatehapwi">
{% set current_ver = versions.0 %}
{% set new_ver = versions.1 %}
{% set current_ver_without_dots = versions.2 %}
{% set new_ver_without_dots = versions.3 %}
<table class="overview">
<tr class="overviewHead">
<td class="padding10 first-collumn" style="width: 25%;">Currnet version</td>
<td class="padding10">Last version</td>
<td></td>
</tr>
<tr>
<td class="padding10 first-collumn">
<b>{{current_ver}}</b>
</td>
<td class="padding10">
<b>{{new_ver}}</b>
</td>
<td>
{% if new_ver_without_dots > current_ver_without_dots and new_ver != "Sorry cannot get current version" %}
<a class="ui-button ui-widget ui-corner-all" id="update_haproxy_wi" title="Update HAProxy">Update</a>
{% endif %}
</td>
</table>
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
<b style="font-size: 20px; display: block; padding-bottom: 10px;">Note:</b>
For update you have to use HAProxy-WI repository. How start use repository read <a href="https://haproxy-wi.org/installation.py" title="HAProxy-WI installation" target="_blank">here</a>
<br />
<br />
If server uses proxy to connection Internet add proxy settings in yum.conf
<br />
<br />
Read more about update in <a href="https://haproxy-wi.org/updates.py" title="Doc" target="_blank">docs</a>
and <a href="https://haproxy-wi.org/changelog.py" title="Changelog" target="_blank">changelog</a>
</div>
<div id="ajax-update"></div>
</div>
</div>
<div id="user-add-table" style="display: none;">
<table class="overview">

View File

@ -74,7 +74,6 @@
<li><a href="/app/add.py#userlist" title="Add userlist" class="add-userlist head-submenu" id="add7">User list</a></li>
<li><a href="/app/lists.py" title="Manage black and white lists" class="lists head-submenu">Lists</a> </li>
<li><a href="/app/waf.py" title="Web application firewall" class="waf head-submenu">WAF</a> </li>
<li><a href="/app/ihap.py" title="Installation HAProxy" class="hap head-submenu">Installation</a> </li>
{% endif %}
</ul>
</li>
@ -90,9 +89,10 @@
<li class="p_menu">
<a title="Servers manage" class="runtime">Servers</a>
<ul class="v_menu">
<li><a href=/app/servers.py#users title="Actions with users" class="users head-submenu">Users</a></li>
<li><a href=/app/servers.py#servers title="Server manage" class="runtime head-submenu">Servers</a></li>
<li><a href=/app/servers.py#ssh title="Manage SSH credentials" class="admin head-submenu">SSH credentials</a></li>
<li><a href="/app/servers.py#users" title="Actions with users" class="users head-submenu">Users</a></li>
<li><a href="/app/servers.py#servers" title="Server manage" class="runtime head-submenu">Servers</a></li>
<li><a href="/app/servers.py#ssh" title="Manage SSH credentials" class="admin head-submenu">SSH credentials</a></li>
<li><a href="/app/servers.py#installhaproxy" title="Installation HAProxy" class="hap head-submenu">Installation</a> </li>
</ul>
</li>
{% endif %}
@ -100,13 +100,13 @@
<li class="p_menu">
<a title="Admin area" class="admin">Admin area</a>
<ul class="v_menu">
<li><a href=/app/users.py#users title="Actions with users" class="users head-submenu">Users</a></li>
<li><a href=/app/users.py#groups title="Actions with groups" class="group head-submenu">Groups</a></li>
<li><a href=/app/users.py#servers title="Actions with servers" class="runtime head-submenu">Servers</a></li>
<li><a href=/app/users.py#ssh title="Manage SSH credentials" class="admin head-submenu">SSH credentials</a></li>
<li><a href=/app/settings.py title="HAproxy-WI settings" class="settings head-submenu">Settings</a></li>
<li><a href=/app/viewlogs.py title="View internal logs" class="logs head-submenu">Internal logs</a></li>
<li><a href=/app/update.py title="View internal logs" class="upload head-submenu">Update</a></li>
<li><a href="/app/users.py#users" title="Actions with users" class="users head-submenu">Users</a></li>
<li><a href="/app/users.py#groups" title="Actions with groups" class="group head-submenu">Groups</a></li>
<li><a href="/app/users.py#servers" title="Actions with servers" class="runtime head-submenu">Servers</a></li>
<li><a href="/app/users.py#ssh" title="Manage SSH credentials" class="admin head-submenu">SSH credentials</a></li>
<li><a href="/app/users.py#settings" title="HAproxy-WI settings" class="settings head-submenu">Settings</a></li>
<li><a href="/app/viewlogs.py" title="View internal logs" class="logs head-submenu">Internal logs</a></li>
<li><a href="/app/users.py#updatehapwi" title="Update HAProxy-WI" class="upload updatehapwi head-submenu">Update</a></li>
</ul>
</li>
{% endif %}
@ -216,7 +216,7 @@
</div>
<div id="show-updates" style="display: none;">
<div>
There is a new version HAProxy-WI. Check the <a href="/app/update.py">Update page</a>
There is a new version HAProxy-WI. Check the <a href="/app/users.py#updatehapwi">Update page</a>
</div>
</div>
<div class="footer">

View File

@ -1,5 +1,6 @@
{% extends "base.html" %}
{% block content %}
<script src="/inc/jquery-linenumbers.js"></script>
<center>
<h3>Choose server</h3>
<p>
@ -102,5 +103,6 @@
if (cur_url[1].split('&')[1] == 'showConfig') {
showConfig();
}
$('textarea').linenumbers({col_width: '25px'});
</script>
{% endblock %}

View File

@ -47,7 +47,7 @@
</tr>
</table>
<table>
<table class="overview">
<caption><h3>Or add VRRP to exist</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">Master</td>
@ -55,6 +55,7 @@
<td>VRRP interface</td>
<td>VRRP IP</td>
<td><span title="If checked Haproxy-WI will restart Keepalived">Restart Keepalived(?)</span></td>
<td style="width: 11%;"></td>
<td></td>
</tr>
<tr>
@ -66,7 +67,7 @@
{% endfor %}
</select>
</td>
<td style="width: 23%;">
<td>
<select id="slave-add">
<option disable selected>Choose master</option>
{% for select in selects %}
@ -74,15 +75,16 @@
{% endfor %}
</select>
</td>
<td style="width: 15%;">
<td>
<input type="text" id="interface-add" class="form-control">
</td>
<td style="width: 16%;">
<td>
<input type="text" id="vrrp-ip-add" class="form-control">
</td>
<td style="width: 25%;">
<td>
<label for="kp"></label><input type="checkbox" id="kp">
</td>
<td></td>
<td>
<a class="ui-button ui-widget ui-corner-all" id="add-vrrp" title="Add HA configuration">Add</a>
</td>

View File

@ -1,36 +0,0 @@
{% extends "base.html" %}
{% block content %}
<script src="/inc/users.js"></script>
<table class="overview">
<tr class="overviewHead">
<td class="padding10 first-collumn" style="width: 35%;">Version</td>
<td class="padding10 first-collumn" style="width: 35%;">Server</td>
<td>SYN flood protect</td>
<td></td>
</tr>
<tr>
<td class="padding10 first-collumn" style="width: 20%;">
<select id="hapver" name="hapver" required>
<option disabled>Choose HAProxy version</option>
<option value="2.0.4-1">2.0.4-1</option>
<option value="2.0.6-1">2.0.6-1</option>
<option value="2.0.7-1" selected>2.0.7-1</option>
</select>
</td>
<td class="padding10 first-collumn">
<select autofocus required name="{{select_id}}" id="{{select_id}}">
<option disabled selected>Choose server</option>
{% for select in selects %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endfor %}
</select>
</td>
<td>
<label for="syn_flood" title="Enable SYN flood protect"><input type="checkbox" id="syn_flood" checked>
</td>
<td>
<a class="ui-button ui-widget ui-corner-all" id="install" title="Install HAProxy">Install</a>
</td>
</table>
<div id="ajax"></div>
{% endblock %}

View File

@ -18,6 +18,7 @@
<li><a href="#servers">Servers</a></li>
<li><a href="#ssh">SSH credentials</a></li>
<li><a href="#checker">Checker</a></li>
<li><a href="#installhaproxy">Install HAProxy</a></li>
{% if user %}
<a href=/app/login.py?logout=logout title="Logout, user name: {{ user }}" class="login"> Logout</a>
{% else %}
@ -376,6 +377,41 @@
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=checker" title="Servers description" target="_blank">here</a>
</div>
</div>
<div id="installhaproxy">
<table class="overview">
<tr class="overviewHead">
<td class="padding10 first-collumn" style="width: 35%;">Version</td>
<td class="padding10 first-collumn" style="width: 35%;">Server</td>
<td>SYN flood protect</td>
<td></td>
</tr>
<tr>
<td class="padding10 first-collumn" style="width: 20%;">
<select id="hapver" name="hapver" required>
<option disabled>Choose HAProxy version</option>
<option value="2.0.4-1">2.0.4-1</option>
<option value="2.0.6-1">2.0.6-1</option>
<option value="2.0.7-1" selected>2.0.7-1</option>
</select>
</td>
<td class="padding10 first-collumn">
<select autofocus required name="haproxyaddserv" id="haproxyaddserv">
<option disabled selected>Choose server</option>
{% for select in servers %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endfor %}
</select>
</td>
<td>
<label for="syn_flood" title="Enable SYN flood protect"><input type="checkbox" id="syn_flood" checked>
</td>
<td>
<a class="ui-button ui-widget ui-corner-all" id="install" title="Install HAProxy">Install</a>
</td>
</tr>
</table>
<div id="ajax"></div>
</div>
</div>
<div id="group_error" style="display: none;">
<div class="alert alert-danger">
@ -592,6 +628,9 @@
$("button").button( "disable" );
$("input").attr( "readonly", "readonly" );
$('.delete').remove()
$('#hapver').selectmenu('enable');
$('#haproxyaddserv').selectmenu('enable');
$('#syn_flood').checkboxradio('enable');
}, 500 );
}

View File

@ -1,49 +0,0 @@
{% extends "base.html" %}
{% block content %}
<script src="/inc/users.js"></script>
<div id="ajax"></div>
<table id="settings">
<tr class="overviewHead">
<td class="padding10 first-collumn" style="width: 10%;">
Parameter
</td>
<td>
Value
</td>
<td>
Description
</td>
</tr>
{% set section = namespace(section='') %}
{% for set in settings %}
{% if section.section|string() != set.2|string() %}
<th colspan="3"><h3>{{ set.2 }} section</h3></th>
{% endif %}
{% set section.section = set.2 %}
<tr class="{{ loop.cycle('odd', 'even') }}">
<td class="addName">
<a href="#{{set.0}}" title="{{set.0}}" style="color: #000;">{{set.0}}</a>
</td>
<td class="addOption">
{% if set.0 == 'ldap_password' %}
{% if set.1 == 'None' %}
<input type="password" name="{{set.0}}" id="{{set.0}}" value="" title="" size="25" class="form-control">
{% else %}
<input type="password" name="{{set.0}}" id="{{set.0}}" value="{{set.1}}" title="" size="25" class="form-control">
{% endif %}
{% else %}
{% if set.1 == 'None' %}
<input type="text" name="{{set.0}}" id="{{set.0}}" value="" title="" size="25" class="form-control">
{% else %}
<input type="text" name="{{set.0}}" id="{{set.0}}" value="{{set.1}}" title="" size="25" class="form-control">
{% endif %}
{% endif %}
</td>
<td class="addOption">
{{set.3}}
</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@ -1,39 +0,0 @@
{% extends "base.html" %}
{% block content %}
{% set current_ver = versions.0 %}
{% set new_ver = versions.1 %}
{% set current_ver_without_dots = versions.2 %}
{% set new_ver_without_dots = versions.3 %}
<script src="/inc/users.js"></script>
<table class="overview">
<tr class="overviewHead">
<td class="padding10 first-collumn" >Currnet version</td>
<td class="padding10 first-collumn" style="width: 350px;">Last version</td>
<td></td>
</tr>
<tr>
<td class="padding10 first-collumn">
<b>{{current_ver}}</b>
</td>
<td class="padding10 first-collumn" style="width: 350px;">
<b>{{new_ver}}</b>
</td>
<td>
{% if new_ver_without_dots > current_ver_without_dots and new_ver != "Sorry cannot get current version" %}
<a class="ui-button ui-widget ui-corner-all" id="update_haproxy_wi" title="Update HAProxy">Update</a>
{% endif %}
</td>
</table>
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
<b style="font-size: 20px; display: block; padding-bottom: 10px;">Note:</b>
For update you have to use HAProxy-WI repository. If do not use repositiry then use update.sh script in HAProxy-WI home directory <br />
<br />
If server uses proxy to connection Internet add proxy settings in yum.conf
<br />
<br />
Read more about update in <a href="https://haproxy-wi.org/updates.py" title="Doc" target="_blank">docs</a>
and <a href="https://haproxy-wi.org/changelog.py" title="Changelog" target="_blank">changelog</a>
</div>
<div id="ajax"></div>
{% endblock %}

View File

@ -1,27 +0,0 @@
#!/usr/bin/env python3
import http.cookies
import os
import funct, sql
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('update.html')
print('Content-type: text/html\n')
funct.check_login()
funct.page_for_admin(level = 2)
try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
user = sql.get_user_name_by_uuid(user_id.value)
token = sql.get_token(user_id.value)
except:
pass
output_from_parsed_template = template.render(h2 = 1, title = "Check updates",
role = sql.get_user_role_by_uuid(user_id.value),
user = user,
versions = funct.versions(),
token = token)
print(output_from_parsed_template)

View File

@ -23,12 +23,13 @@ try:
users = sql.select_users()
servers = sql.get_dick_permit()
token = sql.get_token(user_id.value)
settings = sql.get_setting('', all=1)
ldap_enable = sql.get_setting('ldap_enable')
except:
pass
output_from_parsed_template = template.render(title = "Admin area: users manage",
template = template.render(title = "Admin area: users manage",
role = sql.get_user_role_by_uuid(user_id.value),
user = user,
users = users,
@ -40,5 +41,6 @@ output_from_parsed_template = template.render(title = "Admin area: users manage"
telegrams = sql.select_telegram(),
token = token,
versions = funct.versions(),
settings = settings,
ldap_enable = ldap_enable)
print(output_from_parsed_template)
print(template)

View File

@ -59,13 +59,7 @@ except:
pass
def get_files():
file = []
for files in glob.glob(os.path.join(log_path,'*.log*')):
file += [(files.split('/')[5], files.split('/')[5])]
return sorted(file, reverse=True)
selects = get_files()
selects = funct.get_files(log_path, format="log")
selects.append(['haproxy-wi.error.log','error.log'])
selects.append(['haproxy-wi.access.log','access.log'])
output_from_parsed_template = template.render(h2 = 1,

2
inc/jquery-linenumbers.js vendored Normal file
View File

@ -0,0 +1,2 @@
!function($){$.fn.linenumbers=function(t){var e=$.extend({col_width:"65px",start:1,digits:3},t);return $("[data-name='linenumbers']").remove(),this.each(function(){var t=$(this).prop("offsetWidth"),r=$(this).prop("offsetHeight"),s=parseInt(t)-parseInt(e.col_width);$(this).before('<textarea data-name="linenumbers" style="width:35px;height:'+r+'px;white-space:pre;overflow:hidden;" disabled="disabled"></textarea>'),$(this).css({width:s+"px",height:r+"px"}),$(this).after('<div style="clear:both;"></div>');var n=$(this).parent().find('textarea[disabled="disabled"]');$(this).bind("blur focus change keyup keydown",function(){var t="\n"+$(this).val();t=t.match(/[^\n]*\n[^\n]*/gi);var r="",s="",a="";for(i=0;i<e.digits;i++)s+=" ";$.each(t,function(t,i){0!=t&&(r+="\n"),lencheck=t+e.start+"!",a=s.substr(lencheck.length-1),r+=a+(t+e.start)+":"}),$(n).val(r),$(n).scrollTop($(this).scrollTop())}),$(this).scroll(function(){$(n).scrollTop($(this).scrollTop())}),$(this).trigger("keyup")})}}(jQuery),$("textarea").linenumbers();
//# sourceMappingURL=./jquery-linenumbers.min.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["jquery-linenumbers.js"],"names":["$","fn","linenumbers","in_opts","opt","extend","col_width","start","digits","remove","this","each","textarea_width","prop","textarea_height","new_textarea_width","parseInt","before","css","width","height","float","after","lnbox","parent","find","bind","lines","val","match","line_number_output","max_spacers","spacers","i","k","v","lencheck","substr","length","scrollTop","scroll","trigger","jQuery"],"mappings":"CAAA,SAAUA,GACNA,EAAEC,GAAGC,YAAc,SAASC,GAExB,GAAIC,GAAMJ,EAAEK,QACRC,UAAW,OACXC,MAAO,EACPC,OAAQ,GACVL,EAIF,OAFAH,GAAE,6BAA6BS,SAExBC,KAAKC,KAAK,WAEb,GAAIC,GAAiBZ,EAAEU,MAAMG,KAAK,eAC9BC,EAAkBd,EAAEU,MAAMG,KAAK,gBAC/BE,EAAqBC,SAASJ,GAAgBI,SAASZ,EAAIE,UAE/DN,GAAEU,MAAMO,OAAO,kDAAkDF,EAAmB,aAAaD,EAAgB,+BAAkCC,EAAmB,wEAEtKf,EAAEU,MAAMQ,KAAKC,MAAQJ,EAAmB,KAAKK,OAASN,EAAgB,KAAKO,MAAQ,UAEnFrB,EAAEU,MAAMY,MAAM,kCAEd,IAAIC,GAAQvB,EAAEU,MAAMc,SAASC,KAAK,gCAElCzB,GAAEU,MAAMgB,KAAK,kCAAkC,WAE3C,GAAIC,GAAQ,KAAK3B,EAAEU,MAAMkB,KACzBD,GAAQA,EAAME,MAAM,mBAEpB,IAAIC,GAAmB,GAEnBC,EAAc,GAAQC,EAAU,EACpC,KAAIC,EAAE,EAAEA,EAAE7B,EAAII,OAAOyB,IACjBF,GAAe,GAGnB/B,GAAEW,KAAKgB,EAAM,SAASO,EAAEC,GAEd,GAAHD,IACCJ,GAAsB,MAG1BM,SAAWF,EAAE9B,EAAIG,MAAM,IACvByB,EAAUD,EAAYM,OAAOD,SAASE,OAAO,GAE7CR,GAAsBE,GAASE,EAAE9B,EAAIG,OAAO,MAGhDP,EAAEuB,GAAOK,IAAIE,GAEb9B,EAAEuB,GAAOgB,UAAUvC,EAAEU,MAAM6B,eAG/BvC,EAAEU,MAAM8B,OAAO,WACXxC,EAAEuB,GAAOgB,UAAUvC,EAAEU,MAAM6B,eAG/BvC,EAAEU,MAAM+B,QAAQ,aAGzBC,QACH1C,EAAE,YAAYE","file":"jquery-linenumbers.min.js"}

View File

@ -9,6 +9,7 @@ $( function() {
var link2 = link.split('/')[2]
if (cur_url[0] == link2) {
$(this).parent().css('display', 'contents');
$(this).parent().css('font-size', '13px');
$(this).parent().css('top', '0');
$(this).parent().css('left', '0');
$(this).parent().children().css('margin-left', '-20px');
@ -762,6 +763,42 @@ $( function() {
});
$( "#tabs" ).tabs( "option", "active", 1 );
} );
$( ".runtime" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).find('a').css('padding-left', '20px')
$(this).children(".runtime").css('padding-left', '30px');
$(this).children(".runtime").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 2 );
} );
$( ".admin" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).children(".admin").css('padding-left', '30px');
$(this).children(".admin").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 3 );
} );
$( ".settings" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).find('a').css('padding-left', '20px')
$(this).children(".settings").css('padding-left', '30px');
$(this).children(".settings").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 5 );
} );
$( ".updatehapwi" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).find('a').css('padding-left', '20px')
$(this).children(".updatehapwi").css('padding-left', '30px');
$(this).children(".updatehapwi").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 6 );
} );
} else {
$( ".runtime" ).on( "click", function() {
$('.menu li ul li').each(function () {
@ -772,38 +809,6 @@ $( function() {
});
$( "#tabs" ).tabs( "option", "active", 1 );
} );
}
if (cur_url[0] == "/app/servers.py") {
$( ".admin" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).children(".admin").css('padding-left', '30px');
$(this).children(".admin").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 2 );
} );
}
if (cur_url[0] == "/app/users.py") {
$( ".runtime" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).find('a').css('padding-left', '20px')
$(this).children(".runtime").css('padding-left', '30px');
$(this).children(".runtime").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 2 );
} );
}
// $( ".role" ).on( "click", function() {
// $('.menu li ul li').each(function () {
// $(this).find('a').css('border-left', '0px solid #5D9CEB');
// $(this).find('a').css('padding-left', '20px')
// $(this).children(".role").css('padding-left', '30px');
// $(this).children(".role").css('border-left', '4px solid #5D9CEB');
// });
// $( "#tabs" ).tabs( "option", "active", 3 );
// } );
$( ".admin" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('border-left', '0px solid #5D9CEB');
@ -811,8 +816,18 @@ $( function() {
$(this).children(".admin").css('padding-left', '30px');
$(this).children(".admin").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 3 );
$( "#tabs" ).tabs( "option", "active", 2 );
} );
$( ".hap" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
$(this).find('a').css('border-left', '0px solid #5D9CEB');
$(this).children(".hap").css('padding-left', '30px');
$(this).children(".hap").css('border-left', '4px solid #5D9CEB');
});
$( "#tabs" ).tabs( "option", "active", 4 );
} );
}
}
});
function sleep(ms) {

View File

@ -6,7 +6,6 @@ body {
font-size: 1.3em;
line-height: 1.42857143;
color: #000;
/* background-color: #eee; */
background-color: #fff;
margin: 0;
padding: 0;

View File

@ -131,9 +131,8 @@ $( function() {
} );
});
$('#update_haproxy_wi').click(function() {
$("#ajax").html('')
$("#ajax").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
$("#ajax-update").html('')
$("#ajax-update").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
$.ajax( {
url: "options.py",
data: {
@ -148,39 +147,39 @@ $( function() {
} else if (data.indexOf('Complete!') != '-1'){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">Update was success!</data>');
$("#ajax-update").html('<div class="alert alert-success">Update was success!</data>');
} else if (data.indexOf('Unauthorized') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-danger">It is seems like you Unauthorized in the HAProxy-WI repository. How to get HAProxy-WI auth you can read <a href="https://haproxy-wi.org/installation.py" title="How to get HAProxy-WI auth">hear</a> </data>');
$("#ajax-update").html('<div class="alert alert-danger">It is seems like you Unauthorized in the HAProxy-WI repository. How to get HAProxy-WI auth you can read <a href="https://haproxy-wi.org/installation.py" title="How to get HAProxy-WI auth">hear</a> </data>');
} else if (data.indexOf('but not installed') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-warning">You have settings for HAProxy-WI repository, but installed HAProxy-WI without repository. Please reinstall with yum or use update.sh</data>');
$("#ajax-update").html('<div class="alert alert-warning">You have settings for HAProxy-WI repository, but installed HAProxy-WI without repository. Please reinstall with yum or use update.sh</data>');
} else if (data.indexOf('No Match for argument') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-warning">It is seems like you do not have HAProxy-WI repository settings. Please read docs for<a href="https://haproxy-wi.org/updates.py">detail</a></data>');
$("#ajax-update").html('<div class="alert alert-warning">It is seems like you do not have HAProxy-WI repository settings. Please read docs for<a href="https://haproxy-wi.org/updates.py">detail</a></data>');
} else if (data.indexOf('password for') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-warning">It is seems like you need add Apache user to sudoers. Please read docs for<a href="https://haproxy-wi.org/updates.py">detail</a></data>');
$("#ajax-update").html('<div class="alert alert-warning">It is seems like you need add Apache user to sudoers. Please read docs for<a href="https://haproxy-wi.org/updates.py">detail</a></data>');
} else if (data.indexOf('No packages marked for update') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">It is seems like you have the lastest version HAProxy-WI</data>');
$("#ajax-update").html('<div class="alert alert-info">It is seems like you have the lastest version HAProxy-WI</data>');
} else if (data.indexOf('Connection timed out') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-danger">Cannot connect to HAProxy-WI repository. Connection timed out</data>');
$("#ajax-update").html('<div class="alert alert-danger">Cannot connect to HAProxy-WI repository. Connection timed out</data>');
} else if (data.indexOf('--disable') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-danger">It is seems like you have problem with your repositorys.</data>');
$("#ajax-update").html('<div class="alert alert-danger">It is seems like you have problem with your repositorys.</data>');
} else if (data.indexOf('Unauthorized') != '-1') {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-danger">It is seems like you Unauthorized in the HAProxy-WI repository.</data>');
$("#ajax-update").html('<div class="alert alert-danger">It is seems like you Unauthorized in the HAProxy-WI repository.</data>');
}
}
} );