diff --git a/app/options.py b/app/options.py index 5a5ce31..64822d5 100644 --- a/app/options.py +++ b/app/options.py @@ -570,7 +570,7 @@ if act == "overviewServers": async def async_get_overviewServers(serv1, serv2, service): 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')) + cmd = 'echo "show info" |nc %s %s -w 1|grep -e "node\|Nbproc\|Maxco\|MB\|Peers\|Nbthread"' % (serv2, sql.get_setting('haproxy_sock_port')) out = funct.subprocess_execute(cmd) out1 = "" @@ -2099,6 +2099,7 @@ if form.getvalue('lets_domain'): lets_email = form.getvalue('lets_email') proxy = sql.get_setting('proxy') ssl_path = sql.get_setting('cert_path') + haproxy_dir = sql.get_setting('haproxy_dir') script = "letsencrypt.sh" ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = funct.return_ssh_keys_path(serv) @@ -2116,7 +2117,7 @@ if form.getvalue('lets_domain'): else: proxy_serv = '' - commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + + commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " haproxy_dir=" + haproxy_dir + " DOMAIN=" + lets_domain + " EMAIL=" + lets_email + " SSH_PORT=" + ssh_port + " SSL_PATH=" + ssl_path + " HOST=" + serv + " USER=" + ssh_user_name + " PASS=" + ssh_user_password + " KEY=" + ssh_key_name] @@ -2207,7 +2208,7 @@ if form.getvalue('scan_ports') is not None: 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 + cmd1 = "sudo nmap -sS %s |head -5|tail -2" % ip stdout, stderr = funct.subprocess_execute(cmd) stdout1, stderr1 = funct.subprocess_execute(cmd1) diff --git a/app/scripts/ansible/roles/geoip.sh.j2 b/app/scripts/ansible/roles/geoip.sh.j2 index 2430407..4343b49 100644 --- a/app/scripts/ansible/roles/geoip.sh.j2 +++ b/app/scripts/ansible/roles/geoip.sh.j2 @@ -6,6 +6,13 @@ country_location="GeoLite2-Country-CSV_*/GeoLite2-Country-Locations-en.csv" country_ip="GeoLite2-Country-CSV_*/GeoLite2-Country-Blocks-IPv4.csv" haproxy_dir="{{haproxy_dir}}" MAXMIND_LICENSE="{{maxmind_key}}" +PROXY="{{PROXY}}" + +if [[ $PROXY != "" ]] +then + export http_proxy="$PROXY" + export https_proxy="$PROXY" +fi cd /tmp @@ -40,4 +47,6 @@ if [[ ! -d "$haproxy_dir"/geoip ]]; then mkdir "$haproxy_dir"/geoip fi -cp subnets/* "$haproxy_dir"/geoip \ No newline at end of file +cp subnets/* "$haproxy_dir"/geoip + +systemctl reload haproxy \ No newline at end of file diff --git a/app/scripts/ansible/roles/letsencrypt.yml b/app/scripts/ansible/roles/letsencrypt.yml index a8ed92f..79b2a4a 100644 --- a/app/scripts/ansible/roles/letsencrypt.yml +++ b/app/scripts/ansible/roles/letsencrypt.yml @@ -35,10 +35,15 @@ - name: Combine into pem file shell: cat /etc/letsencrypt/live/{{DOMAIN}}/fullchain.pem /etc/letsencrypt/live/{{DOMAIN}}/privkey.pem > "{{SSL_PATH}}"/"{{DOMAIN}}".pem + - name: Creates directory + file: + path: "{{haproxy_dir}}/scripts" + state: directory + - name: Copy renew script template: src: /var/www/haproxy-wi/app/scripts/ansible/roles/renew_letsencrypt.j2 - dest: /etc/haproxy/renew_letsencrypt.sh + dest: "{{haproxy_dir}}/scripts/renew_letsencrypt.sh" mode: '0755' ignore_errors: yes failed_when: false @@ -48,4 +53,4 @@ cron: name: "Let's encrypt renew script" special_time: "monthly" - job: '/etc/haproxy/renew_letsencrypt.sh' + job: '{{haproxy_dir}}/scripts/renew_letsencrypt.sh' \ No newline at end of file diff --git a/app/scripts/ansible/roles/renew_letsencrypt.j2 b/app/scripts/ansible/roles/renew_letsencrypt.j2 index 5c6d9f9..ee7e3de 100644 --- a/app/scripts/ansible/roles/renew_letsencrypt.j2 +++ b/app/scripts/ansible/roles/renew_letsencrypt.j2 @@ -20,4 +20,4 @@ for i in $(ls -d */ |awk -F"/" '{print $1}'); do done # Reload HAProxy -sudo systemctl reload haproxy +sudo systemctl reload haproxy \ No newline at end of file diff --git a/app/scripts/letsencrypt.sh b/app/scripts/letsencrypt.sh index e1d3f7b..139b7d8 100644 --- a/app/scripts/letsencrypt.sh +++ b/app/scripts/letsencrypt.sh @@ -14,6 +14,7 @@ do DOMAIN) DOMAIN=${VALUE} ;; EMAIL) EMAIL=${VALUE} ;; SSL_PATH) SSL_PATH=${VALUE} ;; + haproxy_dir) haproxy_dir=${VALUE} ;; *) esac done @@ -29,9 +30,9 @@ PWD=$PWD/scripts/ansible/ echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST if [[ $KEY == "" ]]; then - ansible-playbook $PWD/roles/letsencrypt.yml -e "ansible_user=$USER ansible_ssh_pass=$PASS ansible_port=$SSH_PORT variable_host=$HOST PROXY=$PROXY DOMAIN=$DOMAIN EMAIL=$EMAIL SSL_PATH=$SSL_PATH" -i $PWD/$HOST + ansible-playbook $PWD/roles/letsencrypt.yml -e "ansible_user=$USER ansible_ssh_pass=$PASS ansible_port=$SSH_PORT variable_host=$HOST PROXY=$PROXY DOMAIN=$DOMAIN EMAIL=$EMAIL haproxy_dir=$haproxy_dir SSL_PATH=$SSL_PATH" -i $PWD/$HOST else - ansible-playbook $PWD/roles/letsencrypt.yml --key-file $KEY -e "ansible_user=$USER ansible_port=$SSH_PORT variable_host=$HOST PROXY=$PROXY DOMAIN=$DOMAIN EMAIL=$EMAIL SSL_PATH=$SSL_PATH" -i $PWD/$HOST + ansible-playbook $PWD/roles/letsencrypt.yml --key-file $KEY -e "ansible_user=$USER ansible_port=$SSH_PORT variable_host=$HOST PROXY=$PROXY DOMAIN=$DOMAIN EMAIL=$EMAIL haproxy_dir=$haproxy_dir SSL_PATH=$SSL_PATH" -i $PWD/$HOST fi if [ $? -gt 0 ] diff --git a/app/templates/ajax/firewall_rules.html b/app/templates/ajax/firewall_rules.html new file mode 100644 index 0000000..c77649e --- /dev/null +++ b/app/templates/ajax/firewall_rules.html @@ -0,0 +1,118 @@ +{% set thead = ' + + Number + Target + Protocol + Source + Destination + Port + +' %} +
+ +
+ + {{thead}} + + {% for p in input %} + + + + + + + + + {% endfor %} + +
+ {{p.split(' ')[0]}} + + {{p.split(' ')[1]}} + + {{p.split(' ')[2]}} + + {{p.split(' ')[4]}} + + {{p.split(' ')[5]}} + + {{p.split(' ')[7]}} +
+
+
+ + {{thead}} + + {% for p in IN_public_allow %} + + + + + + + + + {% endfor %} + +
+ {{p.split(' ')[0]}} + + {{p.split(' ')[1]}} + + {{p.split(' ')[2]}} + + {{p.split(' ')[4]}} + + {{p.split(' ')[5]}} + + {{p.split(' ')[7]}} +
+
+
+ + {{thead}} + + {% for p in output %} + + + + + + + + + {% endfor %} + +
+ {{p.split(' ')[0]}} + + {{p.split(' ')[1]}} + + {{p.split(' ')[2]}} + + {{p.split(' ')[4]}} + + {{p.split(' ')[5]}} + + {{p.split(' ')[7]}} +
+
+
+
+ There are rules only from INPUT, IN_public_allow and OUTPUT chains +
+ + \ No newline at end of file diff --git a/app/templates/ajax/list.html b/app/templates/ajax/list.html index c3e3a06..1015d9a 100644 --- a/app/templates/ajax/list.html +++ b/app/templates/ajax/list.html @@ -10,10 +10,10 @@ "searchable": false, "orderable": false, "targets": 2 - } - ], - "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]] - } ); + } + ], + "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]] + } ); } ); @@ -29,14 +29,9 @@
- - - + + + diff --git a/app/templates/ajax/scan_ports.html b/app/templates/ajax/scan_ports.html new file mode 100644 index 0000000..16517bf --- /dev/null +++ b/app/templates/ajax/scan_ports.html @@ -0,0 +1,30 @@ +
- Id - - Ip - - IdIp
+ + + + + + + + + {% for p in ports %} + + + + + + {% endfor %} + +
PortStateService
+ {{p.split(' ')[0]}} + + {{p.split(' ')[1]}} + + {{p.split(' ')[2]}} +
+
+
+{% for i in info %} + {{i}}
+{% endfor %} +
\ No newline at end of file diff --git a/app/templates/configver.html b/app/templates/configver.html index 11c45e5..4ab8d0e 100644 --- a/app/templates/configver.html +++ b/app/templates/configver.html @@ -42,7 +42,6 @@
Config is ok
Go to view stats {% endif %} - {% endif %} {% if aftersave != 1 %} diff --git a/app/templates/delver.html b/app/templates/delver.html index 77a3ab6..0e7277d 100644 --- a/app/templates/delver.html +++ b/app/templates/delver.html @@ -16,7 +16,7 @@ {% if not aftersave and not open %}
- Here you can work with previous versions of {%if service == 'keepalived' %}Keepalived{%else%}HAProxy{%endif%} configs. Roll back to them, view or delete + Here you can work with previous versions of {%if service == 'keepalived' %}Keepalived{%elif service == 'nginx' %}Nginx{%else%}HAProxy{%endif%} configs. Roll back to them, view or delete
{% endif %}

@@ -41,7 +41,7 @@ {% for file in return_files %} - Upload + View/Upload
{% endfor %} diff --git a/app/templates/include/admin_servers.html b/app/templates/include/admin_servers.html index 80114c5..dd53a5e 100644 --- a/app/templates/include/admin_servers.html +++ b/app/templates/include/admin_servers.html @@ -106,10 +106,12 @@ @@ -154,7 +156,7 @@
+ Add

-
+
You can read the description of all parameters here or read HowTo in this article
diff --git a/app/templates/include/admins_dialogs.html b/app/templates/include/admins_dialogs.html index 5092b99..6863b49 100644 --- a/app/templates/include/admins_dialogs.html +++ b/app/templates/include/admins_dialogs.html @@ -221,4 +221,10 @@
+ + \ No newline at end of file diff --git a/inc/style.css b/inc/style.css index 048b1de..1a8c889 100644 --- a/inc/style.css +++ b/inc/style.css @@ -829,20 +829,19 @@ label { .haproxy-info { display: inline-block; width: 160px; - padding-left: 30px; - padding-top: 15px; - font-size: 12px; + padding-top: 5px; + font-size: 11.5px; float: left; } .top-info { display: inline-block; width: 350px; - margin-top: 10px; + margin-top: 5px; font-size: 10px; } .bin_bout { width: 110px; - margin-left: 10px; + margin-left: 12px; } .bytes { padding-top: 17px;