diff --git a/app/create_db.py b/app/create_db.py index c9e30331..a3b702ff 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -73,9 +73,9 @@ def create_table(**kwargs): `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`) ); - INSERT INTO user (username, email, password, role, groups) VALUES ('admin','admin@localhost','admin','admin','1'), - ('editor','editor@localhost','editor','editor','1'), - ('guest','guest@localhost','guest','guest','1'); + INSERT INTO user (username, email, password, role, groups) VALUES ('admin','admin@localhost','21232f297a57a5a743894a0e4a801fc3','admin','1'), + ('editor','editor@localhost','5aee9dbd2a188839105073571bee1b1f','editor','1'), + ('guest','guest@localhost','084e0343a0486ff05530df6c705c8bb4','guest','1'); CREATE TABLE IF NOT EXISTS `servers` ( `id` INTEGER NOT NULL, `hostname` VARCHAR ( 64 ) UNIQUE, @@ -465,34 +465,6 @@ def update_ver(**kwargs): print('Cannot update version') cur.close() con.close() - - -def update_to_hash(): - cur_ver = funct.check_ver() - cur_ver = cur_ver.replace('.','') - i = 1 - ver = '' - for l in cur_ver: - ver += l - i += 1 - if len(ver) < 4: - ver += '00' - if cur_ver <= '3.4.9': - con, cur = get_cur() - sql = """select id, password from user """ - try: - cur.execute(sql) - except sqltool.Error as e: - out_error(e) - else: - for u in cur.fetchall(): - sql = """ update user set password = '%s' where id = '%s' """ % (funct.get_hash(u[1]), u[0]) - try: - cur.execute(sql) - con.commit() - except sqltool.Error as e: - if kwargs.get('silent') != 1: - print("An error occurred:", e) def update_all(): @@ -511,7 +483,6 @@ def update_all(): update_db_v_3_4_9_5() update_db_v_3_5_3() update_db_v_3_8_1() - update_to_hash() update_ver() @@ -531,7 +502,6 @@ def update_all_silent(): update_db_v_3_4_9_5(silent=1) update_db_v_3_5_3(silent=1) update_db_v_3_8_1(silent=1) - update_to_hash() update_ver() diff --git a/app/funct.py b/app/funct.py index cd46d5ac..556e9d7f 100644 --- a/app/funct.py +++ b/app/funct.py @@ -270,6 +270,7 @@ def get_sections(config): line.startswith('#HideBlockEnd') or line.startswith('#HideBlockStart') or line.startswith('peers') or + line.startswith('resolvers') or line.startswith('userlist') ): line = line.strip() @@ -302,6 +303,7 @@ def get_section_from_config(config, section): line.startswith('#HideBlockEnd') or line.startswith('#HideBlockStart') or line.startswith('peers') or + line.startswith('resolvers') or line.startswith('userlist') ): record = False diff --git a/app/options.py b/app/options.py index 2827a828..3802e128 100644 --- a/app/options.py +++ b/app/options.py @@ -234,7 +234,7 @@ if act == "overviewwaf": return server_status - async def get_runner_overviewWaf(url): + async def get_runner_overviewWaf(): import http.cookies from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do']) @@ -243,16 +243,16 @@ if act == "overviewwaf": 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()] + futures = [async_get_overviewWaf(server[1], server[2]) for server in sql.select_servers(server=serv)] 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) + template = template.render(service_status=servers_sorted, role=sql.get_user_role_by_uuid(user_id.value)) print(template) ioloop = asyncio.get_event_loop() - ioloop.run_until_complete(get_runner_overviewWaf(form.getvalue('page'))) + ioloop.run_until_complete(get_runner_overviewWaf()) ioloop.close() diff --git a/app/scripts/ansible/roles/haproxy/tasks/main.yml b/app/scripts/ansible/roles/haproxy/tasks/main.yml index 5c85ccc0..13a84364 100644 --- a/app/scripts/ansible/roles/haproxy/tasks/main.yml +++ b/app/scripts/ansible/roles/haproxy/tasks/main.yml @@ -19,35 +19,23 @@ https_proxy: "{{PROXY}}" -- name: install HAProxy {{HAPVER}} on EL6 +- name: install HAProxy {{HAPVER}} on EL{{ansible_facts['distribution_major_version']}} yum: name: - - http://repo.haproxy-wi.org/haproxy-{{HAPVER}}.el6.x86_64.rpm + - http://repo.haproxy-wi.org/haproxy-{{HAPVER}}.el{{ansible_facts['distribution_major_version']}}.x86_64.rpm - socat state: present - when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts['distribution_major_version']|int == 6 and HAPVER|length > 0 + when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and HAPVER|length > 0 register: install_result environment: http_proxy: "{{PROXY}}" https_proxy: "{{PROXY}}" -- name: install HAProxy {{HAPVER}} on EL7 - yum: - name: - - http://repo.haproxy-wi.org/haproxy-{{HAPVER}}.el7.x86_64.rpm - - socat - state: present - when: ((ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts['distribution_major_version']|int == 7) and HAPVER|length > 0 - environment: - http_proxy: "{{PROXY}}" - https_proxy: "{{PROXY}}" - - - name: set_fact from wi` set_fact: haproxy_from_wi: "yes" - when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts['distribution_major_version']|int == 7 and HAPVER|length > 0 + when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and HAPVER|length > 0 - name: install the latest version of HAProxy @@ -56,7 +44,7 @@ - haproxy - socat state: latest - when: ((ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts['distribution_major_version']|int != 7) or ("'FAILED' in install_result.stderr") + when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ("'FAILED' in install_result.stderr") environment: http_proxy: "{{PROXY}}" https_proxy: "{{PROXY}}" diff --git a/app/templates/ajax/config_show.html b/app/templates/ajax/config_show.html index b83e0236..4f50ba1a 100644 --- a/app/templates/ajax/config_show.html +++ b/app/templates/ajax/config_show.html @@ -112,6 +112,16 @@
| @@ -15,16 +32,19 @@ Metrics |
-
+
|
')
- },
- type: "POST",
- success: function( data ) {
- $("#ajaxwafstatus").empty();
- $("#ajaxwafstatus").html(data);
- $.getScript('/inc/overview.js');
- if (cur_url[0] == "waf.py") {
- $.getScript('/inc/waf.js');
- $( "input[type=submit], button" ).button();
- $( "input[type=checkbox]" ).checkboxradio();
- } else {
- $('.first-collumn-wi').css('padding', '10px');
- }
- }
- } );
-}
function showStats() {
$.ajax( {
url: "options.py",
diff --git a/inc/waf.js b/inc/waf.js
index ed03e76f..64463317 100644
--- a/inc/waf.js
+++ b/inc/waf.js
@@ -4,6 +4,37 @@ $( function() {
metrics_waf(id);
});
} );
+function showOverviewWaf(serv, hostnamea) {
+ $.getScript('/inc/chart.min.js');
+ showWafMetrics();
+ console.log(serv)
+ var i;
+ for (i = 0; i < serv.length; i++) {
+ showOverviewWafCallBack(serv[i], hostnamea[i])
+ }
+ $.getScript('/inc/overview.js');
+ $.getScript('/inc/waf.js');
+}
+function showOverviewWafCallBack(serv, hostnamea) {
+ $.ajax( {
+ url: "options.py",
+ data: {
+ act: "overviewwaf",
+ serv: serv,
+ token: $('#token').val()
+ },
+ beforeSend: function() {
+ $("#"+hostnamea).html('
');
+ },
+ type: "POST",
+ success: function( data ) {
+ $("#"+hostnamea).empty();
+ $("#"+hostnamea).html(data)
+ $( "input[type=submit], button" ).button();
+ $( "input[type=checkbox]" ).checkboxradio();
+ }
+ } );
+}
function metrics_waf(name) {
var enable = 0;
if ($('#'+name).is(':checked')) {