From 2664479d1c45102e34d95c1efb47b325565ce24c Mon Sep 17 00:00:00 2001 From: Aidaho Date: Fri, 22 Jan 2021 10:01:08 +0600 Subject: [PATCH] v4.5.8.0 Changelog: https://haproxy-wi.org/changelog.py#4_5_8 --- app/options.py | 40 ++++++++++++++++-------- app/templates/include/admin_servers.html | 14 ++++----- inc/add.js | 6 ++-- inc/configshow.js | 1 - inc/overview.js | 1 - inc/script.js | 6 ++-- inc/style.css | 6 ---- inc/users.js | 2 +- 8 files changed, 42 insertions(+), 34 deletions(-) diff --git a/app/options.py b/app/options.py index 64822d5c..007f5bd0 100644 --- a/app/options.py +++ b/app/options.py @@ -399,13 +399,10 @@ if form.getvalue('action_hap') is not None and serv is not None: if form.getvalue('action_nginx') is not None and serv is not None: action = form.getvalue('action_nginx') - if funct.check_haproxy_config(serv): - commands = ["sudo systemctl %s nginx" % action] - funct.ssh_command(serv, commands) - funct.logging(serv, 'Nginx was ' + action + 'ed', haproxywi=1, login=1) - print("success: Nginx was %s" % action) - else: - print("error: Bad config, check please") + commands = ["sudo systemctl %s nginx" % action] + funct.ssh_command(serv, commands) + funct.logging(serv, 'Nginx was ' + action + 'ed', haproxywi=1, login=1) + print("success: Nginx was %s" % action) if form.getvalue('action_waf') is not None and serv is not None: serv = form.getvalue('serv') @@ -1626,7 +1623,7 @@ if form.getvalue('newserver') is not None: page=page, adding=1) print(template) - funct.logging('a new server ' + hostname, ' has created ', haproxywi=1, login=1) + funct.logging('a new server ' + hostname, ' has been created ', haproxywi=1, login=1) if form.getvalue('updatehapwiserver') is not None: hapwi_id = form.getvalue('updatehapwiserver') @@ -1636,7 +1633,7 @@ if form.getvalue('updatehapwiserver') is not None: metrics = form.getvalue('metrics') service_name = form.getvalue('service_name') sql.update_hapwi_server(hapwi_id, alert, metrics, active, service_name) - funct.logging('the server ' + name, ' has updated ', haproxywi=1, login=1) + funct.logging('the server ' + name, ' has been updated ', haproxywi=1, login=1) if form.getvalue('updateserver') is not None: name = form.getvalue('updateserver') @@ -1656,7 +1653,7 @@ if form.getvalue('updateserver') is not None: print(error_mess) else: sql.update_server(name, group, typeip, enable, master, serv_id, cred, port, desc, haproxy, nginx, firewall) - funct.logging('the server ' + name, ' has updated ', haproxywi=1, login=1) + funct.logging('the server ' + name, ' has been updated ', haproxywi=1, login=1) if form.getvalue('serverdel') is not None: serverdel = form.getvalue('serverdel') @@ -1670,7 +1667,7 @@ if form.getvalue('serverdel') is not None: if sql.delete_server(serverdel): sql.delete_waf_server(serverdel) print("Ok") - funct.logging(hostname, ' has deleted server with ', haproxywi=1, login=1) + funct.logging(hostname, ' has been deleted server with ', haproxywi=1, login=1) if form.getvalue('newgroup') is not None: newgroup = form.getvalue('groupname') @@ -2231,6 +2228,15 @@ if form.getvalue('viewFirewallRules') is not None: cmd2 = ["sudo iptables -L OUTPUT -n --line-numbers|sed 's/ */ /g'|grep -v -E 'Chain|target'"] input_chain = funct.ssh_command(serv, cmd, raw=1) + + input_chain2 = [] + for each_line in input_chain: + input_chain2.append(each_line.strip('\n')) + + if 'error:' in input_chain: + print(input_chain) + sys.exit() + IN_public_allow = funct.ssh_command(serv, cmd1, raw=1) output_chain = funct.ssh_command(serv, cmd2, raw=1) @@ -2238,7 +2244,7 @@ if form.getvalue('viewFirewallRules') is not None: env = Environment(loader=FileSystemLoader('templates')) template = env.get_template('ajax/firewall_rules.html') - template = template.render(input=input_chain, IN_public_allow=IN_public_allow, output=output_chain) + template = template.render(input=input_chain2, IN_public_allow=IN_public_allow, output=output_chain) print(template) if form.getvalue('geoipserv') is not None: @@ -2273,7 +2279,7 @@ if form.getvalue('geoip_install'): commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port + " UPDATE=" + str(geoip_update) + " maxmind_key=" + maxmind_key + " haproxy_dir=" + haproxy_dir + - " HOST=" + str(serv) +" USER=" + str(ssh_user_name) + " PASS=" + str(ssh_user_password) + + " HOST=" + str(serv) + " USER=" + str(ssh_user_name) + " PASS=" + str(ssh_user_password) + " KEY=" + str(ssh_key_name)] output, error = funct.subprocess_execute(commands[0]) @@ -2281,3 +2287,11 @@ if form.getvalue('geoip_install'): funct.show_installation_output(error, output, 'GeoLite2 Database') os.system("rm -f %s" % script) + +if form.getvalue('show_versions'): + from jinja2 import Environment, FileSystemLoader + + env = Environment(loader=FileSystemLoader('templates')) + template = env.get_template('ajax/check_version.html') + template = template.render(versions=funct.versions()) + print(template) \ No newline at end of file diff --git a/app/templates/include/admin_servers.html b/app/templates/include/admin_servers.html index 12275a74..5e0c2ee2 100644 --- a/app/templates/include/admin_servers.html +++ b/app/templates/include/admin_servers.html @@ -7,18 +7,18 @@ IP Port {% if page != "servers.py" %} - Group + Group {% endif %} Enabled - + Virt HAProxy - Nginx - + Nginx + Firewalld - + Slave for Credentials @@ -83,7 +83,7 @@ {{ checkbox(id) }} {% endif %} - + {% set id = 'nginx-' + server.0|string() %} {% if server.14 == 1 %} {{ checkbox(id, checked='checked') }} @@ -91,7 +91,7 @@ {{ checkbox(id) }} {% endif %} - +
{% set id = 'firewall-' + server.0|string() %} {% if server.18 == 1 %} diff --git a/inc/add.js b/inc/add.js index 716bdb21..44c52103 100644 --- a/inc/add.js +++ b/inc/add.js @@ -651,6 +651,7 @@ $( function() { $( ".second-server" ).hide( "fast" ); $( ".backend_server" ).hide( "fast" ); $( ".send_proxy" ).hide( "fast" ); + $( "input[name=server_maxconn]" ).hide( "fast" ); $( ".prefix" ).attr('required',true); } else { $( ".prefix" ).hide( "fast" ); @@ -658,6 +659,7 @@ $( function() { $( ".second-server" ).show( "fast" ); $( ".backend_server" ).show( "fast" ) $( ".send_proxy" ).show( "fast" ) + $( "input[name=server_maxconn]" ).show( "fast" ); } }); var location = window.location.href; @@ -888,8 +890,8 @@ $( function() { toastr.error('Wrong e-mail format'); } }); - var add_server_var = '
: ' + - '' + + var add_server_var = '
: ' + + '' + '' $('[name=add-server-input]').click(function() { $("[name=add_servers]").append(add_server_var); diff --git a/inc/configshow.js b/inc/configshow.js index 11eab170..98750560 100644 --- a/inc/configshow.js +++ b/inc/configshow.js @@ -72,5 +72,4 @@ $( function() { }); event.preventDefault(); }); - }) \ No newline at end of file diff --git a/inc/overview.js b/inc/overview.js index f4662aba..305d7bfd 100644 --- a/inc/overview.js +++ b/inc/overview.js @@ -318,7 +318,6 @@ function updateHapWIServer(id, service_name) { toastr.error(data); } else { toastr.clear(); - console.log("#server-"+id+"-"+service_name) $("#server-"+id+"-"+service_name).addClass( "update", 1000 ); setTimeout(function() { $( "#server-"+id+"-"+service_name).removeClass( "update" ); diff --git a/inc/script.js b/inc/script.js index 424f2994..820b4508 100644 --- a/inc/script.js +++ b/inc/script.js @@ -959,7 +959,7 @@ $( function() { $(this).children(".settings").css('padding-left', '30px'); $(this).children(".settings").css('border-left', '4px solid #5D9CEB'); }); - $( "#tabs" ).tabs( "option", "active", 5 ); + $( "#tabs" ).tabs( "option", "active", 6 ); } ); $( ".services" ).on( "click", function() { $('.menu li ul li').each(function () { @@ -968,7 +968,7 @@ $( function() { $(this).children(".services").css('padding-left', '30px'); $(this).children(".services").css('border-left', '4px solid #5D9CEB'); }); - $( "#tabs" ).tabs( "option", "active", 6 ); + $( "#tabs" ).tabs( "option", "active", 7 ); } ); $( ".updatehapwi" ).on( "click", function() { $('.menu li ul li').each(function () { @@ -977,7 +977,7 @@ $( function() { $(this).children(".updatehapwi").css('padding-left', '30px'); $(this).children(".updatehapwi").css('border-left', '4px solid #5D9CEB'); }); - $( "#tabs" ).tabs( "option", "active", 7 ); + $( "#tabs" ).tabs( "option", "active", 8 ); } ); } else { $( ".runtime" ).on( "click", function() { diff --git a/inc/style.css b/inc/style.css index ef9816a8..4db5f0a8 100644 --- a/inc/style.css +++ b/inc/style.css @@ -373,12 +373,6 @@ pre { .ip-field { width: 100px; } -.group-field, .slave-field { - //min-width: 5%; -} -.slave-field { - padding-left: 10px; -} .cred-field { min-width: 225px; } diff --git a/inc/users.js b/inc/users.js index 83792b33..e911e9ae 100644 --- a/inc/users.js +++ b/inc/users.js @@ -2173,7 +2173,7 @@ function viewFirewallRules(id) { type: "POST", success: function (data) { data = data.replace(/\s+/g, ' '); - if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') { + if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error: ') != '-1') { toastr.error(data); } else { toastr.clear();