diff --git a/README.md b/README.md index 5f014483..38d8d412 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,19 @@ For Apache do virtualhost with cgi-bin. Like this: Order Deny,Allow Deny from all + + + Header set X-XSS-Protection: 1; + Header set X-Frame-Options: deny + Header set X-Content-Type-Options: nosniff + Header set Strict-Transport-Security: max-age=3600; + Header set Cache-Control no-cache + Header set Expires: 0 + + + Header set Cache-Control "max-age=86400, public" + + ``` diff --git a/app/config.py b/app/config.py index a0835812..e9a5979c 100644 --- a/app/config.py +++ b/app/config.py @@ -67,20 +67,10 @@ if serv is not None and form.getvalue('config') is not None: conf.write(config) except IOError: error = "Can't read import config file" - - MASTERS = sql.is_master(serv) - for master in MASTERS: - if master[0] != None: - funct.upload_and_restart(master[0], cfg, just_save=save) - stderr = funct.upload_and_restart(serv, cfg, just_save=save) + stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save) funct.diff_config(oldcfg, cfg) - - #if save: - # c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) - # c["restart"] = form.getvalue('serv') - # print(c) os.system("/bin/rm -f " + hap_configs_dir + "*.old") diff --git a/app/create_db.py b/app/create_db.py index ba3e2751..20c3752a 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -366,12 +366,15 @@ def update_db_v_3_4_5_2(**kwargs): def update_db_v_3_4_5_22(**kwargs): con, cur = get_cur() - sql = """insert into version ('version') values ('3.4.5.2'); """ + if mysql_enable == '0': + sql = """insert into version ('version') values ('3.4.5.2'); """ + else: + sql = """INSERT INTO version VALUES ('3.4.5.2'); """ try: cur.execute(sql) con.commit() except sqltool.Error as e: - print('Cannot insert version') + print('Cannot insert version %s' % e) cur.close() con.close() @@ -435,7 +438,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.1'; """ + sql = """update version set version = '3.5.8'; """ try: cur.execute(sql) con.commit() diff --git a/app/funct.py b/app/funct.py index e9c4734b..37d3fc8d 100644 --- a/app/funct.py +++ b/app/funct.py @@ -442,6 +442,7 @@ def upload(serv, path, file, **kwargs): return error + def upload_and_restart(serv, cfg, **kwargs): import sql tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg" @@ -480,6 +481,17 @@ def upload_and_restart(serv, cfg, **kwargs): logging('localhost', error, haproxywi=1) return error + +def master_slave_upload_and_restart(serv, cfg, just_save): + import sql + MASTERS = sql.is_master(serv) + for master in MASTERS: + if master[0] != None: + upload_and_restart(master[0], cfg, just_save=just_save) + + return upload_and_restart(serv, cfg, just_save=just_save) + + def open_port_firewalld(cfg): try: conf = open(cfg, "r") @@ -499,6 +511,7 @@ def open_port_firewalld(cfg): firewalld_commands.append('sudo firewall-cmd --reload') return firewalld_commands + def check_haproxy_config(serv): import sql commands = [ "haproxy -q -c -f %s" % sql.get_setting('haproxy_config_path') ] @@ -511,6 +524,7 @@ def check_haproxy_config(serv): return False ssh.close() + def show_log(stdout): i = 0 for line in stdout: @@ -518,10 +532,12 @@ def show_log(stdout): line_class = "line3" if i % 2 == 0 else "line" print('
' + escape_html(line) + '
') + def show_ip(stdout): for line in stdout: print(line) + def server_status(stdout): proc_count = "" @@ -533,6 +549,7 @@ def server_status(stdout): proc_count = 0 return proc_count + def ssh_command(serv, commands, **kwargs): ssh = ssh_connect(serv) @@ -565,9 +582,11 @@ def ssh_command(serv, commands, **kwargs): print("
"+str(ssh)+"X
") pass + def escape_html(text): return cgi.escape(text, quote=True) + def subprocess_execute(cmd): import subprocess p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True) @@ -576,6 +595,7 @@ def subprocess_execute(cmd): return output, stderr + def show_backends(serv, **kwargs): import json import sql @@ -600,6 +620,7 @@ def show_backends(serv, **kwargs): if kwargs.get('ret'): return ret + def get_files(dir = get_config_var('configs', 'haproxy_save_configs_dir'), format = 'cfg', **kwargs): import glob if format == 'log': @@ -624,6 +645,7 @@ def get_files(dir = get_config_var('configs', 'haproxy_save_configs_dir'), forma else: return files + def get_key(item): return item[0] diff --git a/app/haproxy-wi.db.sql b/app/haproxy-wi.db.sql index ce3c9f53..3014aed4 100644 --- a/app/haproxy-wi.db.sql +++ b/app/haproxy-wi.db.sql @@ -9,12 +9,12 @@ INSERT INTO `role` (name, description) VALUES ('editor','Can edit configs'); INSERT INTO `role` (name, description) VALUES ('guest','Read only access'); CREATE TABLE IF NOT EXISTS `groups` (`id` INTEGER NOT NULL AUTO_INCREMENT,`name` VARCHAR ( 80 ) UNIQUE,`description` VARCHAR ( 255 ),PRIMARY KEY(`id`)); INSERT INTO `groups` (name, description) VALUES ('All','All servers enter in this group'); -CREATE TABLE IF NOT EXISTS `uuid` (`user_id` INTEGER NOT NULL, `uuid` varchar ( 64 ),`exp` DATETIME default '0000-00-00 00:00:00'); -CREATE TABLE IF NOT EXISTS `token` (`user_id` INTEGER, `token` varchar(64), `exp` timestamp default '0000-00-00 00:00:00'); +CREATE TABLE IF NOT EXISTS `uuid` (`user_id` INTEGER NOT NULL, `uuid` varchar ( 64 ),`exp` DATETIME default CURRENT_TIMESTAMP); +CREATE TABLE IF NOT EXISTS `token` (`user_id` INTEGER, `token` varchar(64), `exp` timestamp default CURRENT_TIMESTAMP); CREATE TABLE IF NOT EXISTS `cred` (`id` integer primary key AUTO_INCREMENT, `name` VARCHAR ( 64 ) UNIQUE, `enable` INTEGER NOT NULL DEFAULT 1, `username` VARCHAR ( 64 ) NOT NULL, `password` VARCHAR ( 64 ) NOT NULL, groups INTEGER NOT NULL DEFAULT 1 ); CREATE TABLE IF NOT EXISTS `telegram` (`id` integer primary key auto_increment, `token` VARCHAR ( 64 ), `chanel_name` INTEGER NOT NULL DEFAULT 1, `groups` INTEGER NOT NULL DEFAULT 1); CREATE TABLE IF NOT EXISTS `metrics` (`serv` varchar(64), curr_con INTEGER, cur_ssl_con INTEGER, sess_rate INTEGER, max_sess_rate INTEGER,`date` DATETIME default '0000-00-00 00:00:00'); CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64) UNIQUE, value varchar(64), section varchar(64), `desc` varchar(100)); -CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64), `hash` INTEGER NOT NULL DEFAULT 1,); +CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64)); CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`)); CREATE TABLE IF NOT EXISTS `saved_servers` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `description` VARCHAR ( 120 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`)); diff --git a/app/hapservers.py b/app/hapservers.py index 5bc0d6d1..73a2f250 100644 --- a/app/hapservers.py +++ b/app/hapservers.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import funct, sql import os, http.cookies +import cgi from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('templates/')) template = env.get_template('hapservers.html') @@ -15,12 +16,21 @@ try: users = sql.select_users() groups = sql.select_groups() token = sql.get_token(user_id.value) - servers = sql.get_dick_permit() cmd = "ps ax |grep -e 'keep_alive.py' |grep -v grep |wc -l" keep_alive, stderr = funct.subprocess_execute(cmd) except: pass + +form = cgi.FieldStorage() +serv = form.getvalue('serv') +if serv: + servers = sql.select_servers(server=serv) + autorefresh = 1 +else: + servers = sql.get_dick_permit() + autorefresh = 0 + haproxy_sock_port = sql.get_setting('haproxy_sock_port') haproxy_config_path = sql.get_setting('haproxy_config_path') commands = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ] @@ -47,10 +57,10 @@ for s in servers: servers_with_status.append('Cannot get last date') servers_with_status1.append(servers_with_status) - + template = template.render(h2 = 1, - autorefresh = 0, + autorefresh = autorefresh, title = "HAProxy servers overview", role = sql.get_user_role_by_uuid(user_id.value), user = user, @@ -59,5 +69,6 @@ template = template.render(h2 = 1, servers = servers_with_status1, versions = funct.versions(), keep_alive = ''.join(keep_alive), + serv = serv, token = token) print(template) diff --git a/app/options.py b/app/options.py index adc04ee7..b8f42c78 100644 --- a/app/options.py +++ b/app/options.py @@ -209,7 +209,7 @@ if act == "overviewwaf": 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" ] + commands = [ "top -u haproxy -b -n 1" ] 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 = "" diff --git a/app/sections.py b/app/sections.py index 08b3ffb7..6e670081 100644 --- a/app/sections.py +++ b/app/sections.py @@ -72,12 +72,7 @@ if serv is not None and form.getvalue('config') is not None: except IOError: error = "Can't read import config file" - MASTERS = sql.is_master(serv) - for master in MASTERS: - if master[0] != None: - funct.upload_and_restart(master[0], cfg, just_save=save) - - stderr = funct.upload_and_restart(serv, cfg, just_save=save) + stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save) funct.diff_config(oldcfg, cfg) diff --git a/app/sql.py b/app/sql.py index e0feb09e..d97683e4 100644 --- a/app/sql.py +++ b/app/sql.py @@ -275,7 +275,7 @@ def select_servers(**kwargs): if kwargs.get("server") is not None: sql = """select * from servers where ip='%s' """ % kwargs.get("server") if kwargs.get("full") is not None: - sql = """select * from servers ORDER BY groups """ + sql = """select * from servers ORDER BY hostname """ if kwargs.get("get_master_servers") is not None: sql = """select id,hostname from servers where master = 0 and type_ip = 0 and enable = 1 ORDER BY groups """ if kwargs.get("get_master_servers") is not None and kwargs.get('uuid') is not None: @@ -846,6 +846,20 @@ def select_waf_servers(serv): cur.close() con.close() + +def select_all_waf_servers(): + con, cur = create_db.get_cur() + sql = """ select serv.ip from waf left join servers as serv on waf.server_id = serv.id """ + try: + cur.execute(sql) + except sqltool.Error as e: + out_error(e) + else: + return cur.fetchall() + cur.close() + con.close() + + def select_waf_servers_metrics(uuid, **kwargs): con, cur = create_db.get_cur() sql = """ select * from user where username = '%s' """ % get_user_name_by_uuid(uuid) @@ -1299,8 +1313,8 @@ def show_update_telegram(token, page): def show_update_user(user,page): from jinja2 import Environment, FileSystemLoader - env = Environment(loader=FileSystemLoader('templates/ajax')) - template = env.get_template('/new_user.html') + env = Environment(loader=FileSystemLoader('templates/')) + template = env.get_template('ajax/new_user.html') print('Content-type: text/html\n') template = template.render(users = select_users(user=user), @@ -1311,8 +1325,8 @@ def show_update_user(user,page): def show_update_server(server, page): from jinja2 import Environment, FileSystemLoader - env = Environment(loader=FileSystemLoader('templates/ajax/')) - template = env.get_template('/new_server.html') + env = Environment(loader=FileSystemLoader('templates/')) + template = env.get_template('ajax/new_server.html') print('Content-type: text/html\n') output_from_parsed_template = template.render(groups = select_groups(), diff --git a/app/templates/add.html b/app/templates/add.html index 7ddc794f..9b9b20e5 100644 --- a/app/templates/add.html +++ b/app/templates/add.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% block content %} +{% from 'include/input_macros.html' import input, checkbox, select %} - +{% include 'include/del_confirm.html' %}
@@ -64,34 +59,7 @@ {% for user in users %} - - - - + {% include 'include/admin_users.html' %} - - - + {% for server in servers %} - - - - - - - - - - + {% include 'include/admin_servers.html' %} {% endfor %}
- {% if user.6 == 1%} - - {% else %} - - {% endif %} - - {% if user.6 != 1%} - - Edit - - {% endif %} - - {% if user.7 == 1 %} - - {% else %} - - {% endif %} - - {% if user.6 == 1%} - - {% else %} - - {% endif %} - + {% if group.2 != "None" %} {% else %} @@ -169,10 +137,10 @@
- + {{ input('new-group-add') }} - + {{ input('new-desc', size="60") }} @@ -200,8 +168,7 @@ Description
@@ -225,81 +192,7 @@ {% endfor %} - {% if server.5 == 1 %} - - {% else %} - - {% endif %} - - {% if server.4 == 1 %} - - {% else %} - - {% endif %} - - {% if server.8 == 1 %} - - {% else %} - - {% endif %} - - {% if server.9 == 1 %} - - {% else %} - - {% endif %} - - {% if server.12 == 1 %} - - {% else %} - - {% endif %} - - - -
- - -
-
- {% if server.11 != "None" %} - - {% else %} - - {% endif %} - - - - -
@@ -378,7 +271,7 @@ - + {{ input('new-ssh-add') }} @@ -392,9 +285,9 @@

- + {{ input('ssh_user', value=ssh_user) }}

- + {{ input('ssh_pass', type='password', value=ssh_pass, style="display: none;") }}
@@ -486,10 +379,10 @@ - + {{ input('telegram-token-add') }} - + {{ input('telegram-chanel-add') }} - {% if ldap_enable == '1' %} - Search user in AD - {% endif %} - - - - - Password - * - - - - - - - Active - - - - - - - Email - - - - - + {% include 'include/admin_add_user.html' %} Role @@ -670,96 +521,12 @@
- + + + + Group + * + + + + + + + +
+{% include 'include/change_pass_form.html' %} +{% endif %}
{% for s in servers %} + {% if serv %} + + + + + {% endif %}
@@ -10,9 +34,11 @@ {% else %} {% endif %} - + {% if not serv %} + {{s.1}} + {% else %} {{s.1}} - + {% endif %} {% if s.6|int() >= 1 %} = 1 %} @@ -24,14 +50,14 @@ {% endif %} {% if role <= 1 %} - - start + + start - - stop + + stop - - restart + + restart {% endif %} @@ -68,9 +94,21 @@
{% endfor %}
+{% if serv %} +
+ Refresh +
+ {% for s in servers %} +
+ +
+
+ +
+ {% endfor %} +{% endif %} - {% endblock %} \ No newline at end of file diff --git a/app/templates/include/add_proxy.html b/app/templates/include/add_proxy.html new file mode 100644 index 00000000..84f54a36 --- /dev/null +++ b/app/templates/include/add_proxy.html @@ -0,0 +1,135 @@ +
+
+
+
+
+ Create Listen +
+
+ A "listen" section defines a complete proxy with its frontend and backend parts combined in one section. It is generally useful for TCP-only traffic. +
+
+
+
+
+
+ Create HTTP Listen +
+
+ Create HTTP proxy +
+
+
+
+
+
+ Create SSL Listen +
+
+ Create HTTPS Proxy with the SSL termination on HAProxy and SSL offload. + HAProxy will send to backends HTTP traffic. You need have uploaded a PEM certificat +
+
+
+
+
+
+ Create HTTPS Listen +
+
+ Create HTTPS Proxy without the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTPS traffic +
+
+
+
+
+
+
+
+ Create Frontend +
+
+ A "frontend" section describes a set of listening sockets accepting client connections. + And forwards them to backend +
+
+
+
+
+
+ Create HTTP Frontend +
+
+ Create HTTP Frontend +
+
+
+
+
+ Create SSL Frontend +
+
+ Create HTTPS Frontend with the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTP traffic. You need have uploaded a PEM certificat +
+
+
+
+
+
+ Create HTTPS Frontend +
+
+ Create HTTPS Frontend without the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTPS traffic +
+
+
+
+
+
+
+
+ Create Backend +
+
+ A "backend" section describes a set of servers to which the proxy will connect to forward incoming connections. +
+
+
+
+
+
+
+ Create HTTP Backend +
+
+ Create HTTP Backend +
+
+
+
+
+ Create SSL Backend +
+
+ Create HTTPS Backend with the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTP traffic. You need have uploaded a PEM certificat +
+
+
+
+
+
+ Create HTTPS Backend +
+
+ Create HTTPS Backend without the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTPS traffic +
+
+
+
+ {% if add %} +
+

{{ add }} was success added

+ {{ conf_add }} +
+ {% endif %} +
\ No newline at end of file diff --git a/app/templates/include/add_servers.html b/app/templates/include/add_servers.html new file mode 100644 index 00000000..29b10bcb --- /dev/null +++ b/app/templates/include/add_servers.html @@ -0,0 +1,13 @@ + + : + +
+ : + +
+ : + +
+ + + \ No newline at end of file diff --git a/app/templates/include/admin_add_server.html b/app/templates/include/admin_add_server.html new file mode 100644 index 00000000..68105d90 --- /dev/null +++ b/app/templates/include/admin_add_server.html @@ -0,0 +1,62 @@ +{% from 'include/input_macros.html' import input, checkbox %} + + +

+ Form fields tag "*" are required. +

+ + + + + New hostname + * + + {{ input('new-server-add') }} + + + IP + * + + {{ input('new-ip', size='14') }} + + + Port + * + + {{ input('new-port', value='22', size='1') }} + + + Enable + {{ checkbox('enable', checked='checked') }} + + + Virt + {{ checkbox('typeip') }} + + + Alert + {{ checkbox('alert') }} + + + Metrics + {{ checkbox('metrics') }} + + + Start + {{ checkbox('active') }} + + + Slave for + + + + + + Description + {{ input('desc', size='30') }} + \ No newline at end of file diff --git a/app/templates/include/admin_add_user.html b/app/templates/include/admin_add_user.html new file mode 100644 index 00000000..53a11bbc --- /dev/null +++ b/app/templates/include/admin_add_user.html @@ -0,0 +1,38 @@ +{% from 'include/input_macros.html' import input, checkbox %} + + +

+ Form fields tag "*" are required. +

+ + + + + New user + * + + + {{ input('new-username') }} + {% if ldap_enable == '1' %} + Search user in AD + {% endif %} + + + + + Password + * + + {{ input('new-password', type='password') }} + + + Active + {{ checkbox('activeuser', checked='checked') }} + + + + Email + * + + {{ input('new-email') }} + \ No newline at end of file diff --git a/app/templates/include/admin_servers.html b/app/templates/include/admin_servers.html new file mode 100644 index 00000000..f374ba96 --- /dev/null +++ b/app/templates/include/admin_servers.html @@ -0,0 +1,82 @@ +{% from 'include/input_macros.html' import input, checkbox %} + + {% set id = 'enable-' + server.0|string() %} + {% if server.5 == 1 %} + {{ checkbox(id, checked='checked') }} + {% else %} + {{ checkbox(id) }} + {% endif %} + + + {% set id = 'typeip-' + server.0|string() %} + {% if server.4 == 1 %} + {{ checkbox(id, checked='checked') }} + {% else %} + {{ checkbox(id) }} + {% endif %} + + + {% set id = 'alert-' + server.0|string() %} + {% if server.8 == 1 %} + {{ checkbox(id, checked='checked') }} + {% else %} + {{ checkbox(id) }} + {% endif %} + + + {% set id = 'metrics-' + server.0|string() %} + {% if server.9 == 1 %} + {{ checkbox(id, checked='checked') }} + {% else %} + {{ checkbox(id) }} + {% endif %} + + + {% set id = 'active-' + server.0|string() %} + {% if server.12 == 1 %} + {{ checkbox(id, checked='checked') }} + {% else %} + {{ checkbox(id) }} + {% endif %} + + + + + +
+ + +
+ + + {% set id = 'desc-' + server.0|string() %} + {% if server.11 != "None" %} + {{ input(id, value=server.11, size='20') }} + {% else %} + {{ input(id, size='20') }} + {% endif %} + + + + + + + \ No newline at end of file diff --git a/app/templates/include/admin_user.html b/app/templates/include/admin_user.html new file mode 100644 index 00000000..4d99c4a1 --- /dev/null +++ b/app/templates/include/admin_user.html @@ -0,0 +1,28 @@ + + {% if user.6 == 1%} + + {% else %} + + {% endif %} + + + {% if user.6 != 1%} + + Edit + + {% endif %} + + + {% if user.7 == 1 %} + + {% else %} + + {% endif %} + + + {% if user.6 == 1%} + + {% else %} + + {% endif %} + \ No newline at end of file diff --git a/app/templates/include/admin_users.html b/app/templates/include/admin_users.html new file mode 100644 index 00000000..4fd0a115 --- /dev/null +++ b/app/templates/include/admin_users.html @@ -0,0 +1,32 @@ +{% from 'include/input_macros.html' import input, checkbox %} + + {% set login_id = 'login-' + user.0|string() %} + {% if user.6 == 1%} + {{ input(login_id, value=user.1, readonly='readonly') }} + {% else %} + {{ input(login_id, value=user.1) }} + {% endif %} + + + {% if user.6 != 1%} + + Edit + + {% endif %} + + + {% set activeuser_id = 'activeuser-' + user.0|string() %} + {% if user.7 == 1 %} + {{ checkbox(activeuser_id, checked='checked') }} + {% else %} + {{ checkbox(activeuser_id) }} + {% endif %} + + + {% set email_id = 'email-' + user.0|string() %} + {% if user.6 == 1%} + {{ input(email_id, value=user.2, readonly='readonly') }} + {% else %} + {{ input(email_id, value=user.2) }} + {% endif %} + \ No newline at end of file diff --git a/app/templates/include/change_pass_form.html b/app/templates/include/change_pass_form.html new file mode 100644 index 00000000..b4e07852 --- /dev/null +++ b/app/templates/include/change_pass_form.html @@ -0,0 +1,23 @@ +{% from 'include/input_macros.html' import input %} + \ No newline at end of file diff --git a/app/templates/include/del_confirm.html b/app/templates/include/del_confirm.html new file mode 100644 index 00000000..7d0941db --- /dev/null +++ b/app/templates/include/del_confirm.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/app/templates/include/errors.html b/app/templates/include/errors.html new file mode 100644 index 00000000..f4e3d47d --- /dev/null +++ b/app/templates/include/errors.html @@ -0,0 +1,6 @@ +
+ Some errors: +

+ {{stderr}} + {{error}} +
\ No newline at end of file diff --git a/app/templates/include/input_macros.html b/app/templates/include/input_macros.html new file mode 100644 index 00000000..e6a172ae --- /dev/null +++ b/app/templates/include/input_macros.html @@ -0,0 +1,31 @@ +{% macro input(id, name='', value='', type='text', size='', readonly='', required='', placeholder='', title='', class='form-control', style='') -%} + {% if name == '' %} + {% set name = id %} + {% endif %} + +{%- endmacro %} + +{%- macro checkbox(id, name='', checked='', title='', value='', desc='') -%} + {% if name == '' %} + {% set name = id %} + {% endif %} + +{%- endmacro %} + +{%- macro select(id, values, name='', required='', first='', class='', selected='') -%} + {% if name == '' %} + {% set name = id %} + {% endif %} + +{%- endmacro %} \ No newline at end of file diff --git a/app/templates/include/login.html b/app/templates/include/login.html new file mode 100644 index 00000000..7bc347ee --- /dev/null +++ b/app/templates/include/login.html @@ -0,0 +1,5 @@ +{% if user %} + +{% else %} + +{% endif %} \ No newline at end of file diff --git a/app/templates/include/select.html b/app/templates/include/select.html new file mode 100644 index 00000000..f11c06a1 --- /dev/null +++ b/app/templates/include/select.html @@ -0,0 +1,11 @@ + + \ No newline at end of file diff --git a/app/templates/lists.html b/app/templates/lists.html index 56730016..76fe2d2e 100644 --- a/app/templates/lists.html +++ b/app/templates/lists.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% block content %} +{% from 'include/input_macros.html' import input %} - + {{ input('group', value=group, type='hidden') }}
New black list @@ -9,7 +10,7 @@
- Name: + Name: {{ input('new_blacklist_name') }} @@ -18,7 +19,7 @@ {% endfor %} - Name: + Name: {{ input('new_whitelist_name') }} @@ -27,7 +28,7 @@ {% endfor %}
In this section you can create and edit black and white lists. And after use them in the HAProxy configs or in the "Add proxy" pages @@ -35,6 +36,6 @@
{% endblock %} \ No newline at end of file diff --git a/app/templates/login.html b/app/templates/login.html index ff25dcdb..37c2d571 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% block content %} +{% from 'include/input_macros.html' import input %} - +{% include 'include/del_confirm.html' %} @@ -19,11 +18,7 @@
  • SSH credentials
  • Checker
  • Install HAProxy
  • - {% if user %} - - {% else %} - - {% endif %} + {% include 'include/login.html' %}
    @@ -40,35 +35,7 @@ {% for user in users %} {% if user.5 == group %} - - - - + {% include 'include/admin_users.html' %} - - - - - - - - - - + {% include 'include/admin_servers.html' %} {% endfor %}
    - {% if user.6 == 1%} - - {% else %} - - {% endif %} - - - {% if user.6 != 1%} - - Edit - - {% endif %} - - {% if user.7 == 1 %} - - {% else %} - - {% endif %} - - {% if user.6 == 1%} - - {% else %} - - {% endif %} - - {% if server.5 == 1 %} - - {% else %} - - {% endif %} - - {% if server.4 == 1 %} - - {% else %} - - {% endif %} - - {% if server.8 == 1 %} - - {% else %} - - {% endif %} - - {% if server.9 == 1 %} - - {% else %} - - {% endif %} - - {% if server.12 == 1 %} - - {% else %} - - {% endif %} - - - -
    - - -
    -
    - {% if server.11 != "None" %} - - {% else %} - - {% endif %} - - - - -
    @@ -270,16 +163,16 @@ - + {{ input('new-ssh-add') }}

    - + {{ input('ssh_user', value=ssh_user) }}

    - + {{ input('ssh_pass', type='password', value=ssh_pass, style="display: none;") }}
    @@ -359,13 +252,13 @@ - + {{ input('telegram-token-add') }} {% for group in ssh_group %} - + {{ input('new-telegram-group-add', value=group.0) }} {% endfor %} - + {{ input('telegram-chanel-add') }} @@ -387,12 +280,9 @@ - + {% set values = dict() %} + {% set values = {'2.0.4-1':'2.0.4-1','2.0.6-1':'2.0.6-1', '2.0.7-1':'2.0.7-1'} %} + {{ select('hapver', values=values, selected='2.0.7-1', required='required') }} -