From 08b21981df601b4d3cd486fd3808d93e844ad848 Mon Sep 17 00:00:00 2001 From: Pavel Loginov Date: Fri, 16 Apr 2021 20:09:51 +0600 Subject: [PATCH] v5.1.1.0 Changelog: https://haproxy-wi.org/changelog.py#5_1_1 --- app/create_db.py | 2 +- app/funct.py | 16 +++++++++++--- app/sections.py | 5 ++++- app/templates/add.html | 23 +++++++++++++++++++ app/templates/ajax/config_show.html | 23 +++++++++---------- app/templates/ajax/load_updatehapwi.html | 11 +++++++++- app/templates/sections.html | 8 +++---- inc/add.js | 28 ++++++++++++++++++++++++ inc/style.css | 3 +++ inc/users.js | 2 +- 10 files changed, 98 insertions(+), 23 deletions(-) diff --git a/app/create_db.py b/app/create_db.py index 44d9bcfd..c5db894f 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -1221,7 +1221,7 @@ def update_db_v_5_1_0_1(**kwargs): def update_ver(): con, cur = get_cur() - sql = """update version set version = '5.1.0.0'; """ + sql = """update version set version = '5.1.1.0'; """ try: cur.execute(sql) con.commit() diff --git a/app/funct.py b/app/funct.py index f6a55c2a..caf6edd9 100644 --- a/app/funct.py +++ b/app/funct.py @@ -340,7 +340,7 @@ def diff_config(oldcfg, cfg): except IOError: print('
Can\'t read write change to log. %s
' % stderr) pass - + def get_sections(config, **kwargs): return_config = list() @@ -437,7 +437,17 @@ def rewrite_section(start_line, end_line, config, section): return_config += line return return_config - + + +def get_userlists(config, **kwargs): + return_config = '' + with open(config, 'r') as f: + for line in f: + if line.startswith('userlist'): + line = line.strip() + return_config += line + ',' + + return return_config def get_backends_from_config(serv, backends='', **kwargs): configs_dir = get_config_var('configs', 'haproxy_save_configs_dir') @@ -1244,4 +1254,4 @@ def get_services_status(): except Exception: services.append([s, status, v, '']) - return services \ No newline at end of file + return services diff --git a/app/sections.py b/app/sections.py index f4b7bbc5..314f1e0c 100644 --- a/app/sections.py +++ b/app/sections.py @@ -55,7 +55,10 @@ if serv is not None and form.getvalue('config') is not None: start_line = form.getvalue('start_line') end_line = form.getvalue('end_line') aftersave = 1 - + + if save == 'delete': + config = '' + config = funct.rewrite_section(start_line, end_line, oldcfg, config) try: diff --git a/app/templates/add.html b/app/templates/add.html index a967c360..76db048c 100644 --- a/app/templates/add.html +++ b/app/templates/add.html @@ -920,6 +920,29 @@ +
+ + + + + + + + + + + +

Existing UserList

Select server: + +
Note: If you reconfigure Master server, Slave will reconfigured automatically
+
+ Show Userlist +
In this section you can create userlists. And after use them in the "Add" sections
diff --git a/app/templates/ajax/config_show.html b/app/templates/ajax/config_show.html index e1e369f9..0508da3a 100644 --- a/app/templates/ajax/config_show.html +++ b/app/templates/ajax/config_show.html @@ -87,12 +87,12 @@ {{- line -}} {% if role %} - Edit + Edit/Delete {% endif %} {%- set backend = line.split(' ') -%} - Stats + Stats {%- set backend = backend|join('_') -%} {%- do section_name.update({i: backend}) -%} @@ -104,7 +104,7 @@ {{ line }} {% if role %} - Edit + Edit/Delete {% endif %} {% set backend = line.split(' ') %} @@ -121,7 +121,7 @@ {{ line }} {% if role %} - Edit + Edit/Delete {% endif %} {% set backend = line.split(' ') %} @@ -135,7 +135,7 @@ {{ line }} {% if role %} - Edit + Edit/Delete {% endif %}
@@ -145,7 +145,7 @@
{{ line }} {% if role %} - Edit + Edit/Delete {% endif %}
@@ -155,7 +155,7 @@
{{ line }} {% if role %} - Edit + Edit/Delete {% endif %}
@@ -165,7 +165,7 @@
{{ line }} {% if role %} - Edit + Edit/Delete {% endif %}
@@ -175,7 +175,7 @@
{{ line }} {% if role %} - Edit + Edit/Delete {% endif %}
@@ -208,10 +208,11 @@
{% endif %} {%- if "bind" in line -%} - {%- set bind = line.split(':') -%} + {%- set bind = line.split(':')[1] -%} + {%- set bind = bind.split(' ') -%} {%- endif -%} {%- endif -%} diff --git a/app/templates/ajax/load_updatehapwi.html b/app/templates/ajax/load_updatehapwi.html index 21ed7390..b5e53842 100644 --- a/app/templates/ajax/load_updatehapwi.html +++ b/app/templates/ajax/load_updatehapwi.html @@ -22,7 +22,7 @@ {% for s in services %} - {% if s.0 == 'smon' or s.0 == 'checker_haproxy' or s.0 == 'keep_alive' or s.0 == 'metrics_haproxy' %} + {% if s.0 == 'smon' or s.0 == 'checker_haproxy' or s.0 == 'keep_alive' or s.0 == 'metrics_haproxy' or s.0 == 'portscanner' %} {% set is_need_update = 0 %} {% if s.0 == 'smon' %} @@ -53,6 +53,13 @@ {% if s.3|float < metrics_ver|float %} {% set is_need_update = 1 %} {% endif %} +{% elif s.0 == 'portscanner' %} + {% set service_name = 'Port scanner' %} + {% set service_link = 'portscanner' %} + {% set desc_link = 'https://haproxy-wi.org/services.py?service={{service_link}}' %} + {% if s.3|float < portscanner_ver|float %} + {% set is_need_update = 1 %} + {% endif %} {% endif %} {{service_name}} @@ -72,6 +79,8 @@ {{keep_ver}} {% elif s.0 == 'metrics_haproxy' %} {{metrics_ver}} + {% elif s.0 == 'portscanner' %} + {{portscanner_ver}} {% endif %} diff --git a/app/templates/sections.html b/app/templates/sections.html index 56e5947c..d9b26a1e 100644 --- a/app/templates/sections.html +++ b/app/templates/sections.html @@ -42,13 +42,11 @@ + {% if section != 'globals' and section != 'defaults' %} + + {% endif %}

-
-

Note:

-

When reconfiguring the master server, the slave will be reconfigured automatically

-

Unable to delete entire section

-
diff --git a/inc/add.js b/inc/add.js index 5f8f58f0..afe72780 100644 --- a/inc/add.js +++ b/inc/add.js @@ -1726,4 +1726,32 @@ function makeid(length) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; +} +function showUserlists() { + var serv = $( "#existing_userlist_serv option:selected" ).val(); + if (serv == 'Choose server') { + toastr.warning('Choose a server before'); + } else { + $.ajax({ + url: "options.py", + data: { + show_userlists: 1, + serv: serv, + token: $('#token').val() + }, + type: "POST", + success: function (data) { + if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1') { + toastr.error(data); + } else { + $('#existing_userlist_tr').show(); + $('#existing_userlist_ajax').text(''); + data = data.split(","); + for (i = 0; i < data.length; i++) { + $('#existing_userlist_ajax').append(''+data[i]+' '); + } + } + } + }); + } } \ No newline at end of file diff --git a/inc/style.css b/inc/style.css index 83bd03d6..2bc5685c 100644 --- a/inc/style.css +++ b/inc/style.css @@ -360,6 +360,7 @@ pre { } .overview-wi .overviewHead { border-bottom: 1px solid #A4C7F5; + height: 25px; } .overview tr{ border-bottom: 1px solid #ddd; @@ -713,6 +714,8 @@ td,th { margin-top: 220px; margin-right: 50px; width: 300px; + text-align: center; + margin-left: 40%; } .validateTips { width: 540px; diff --git a/inc/users.js b/inc/users.js index f536109e..db7a83c7 100644 --- a/inc/users.js +++ b/inc/users.js @@ -1941,7 +1941,7 @@ function ajaxActionServies(action, service) { toastr.error(data); } else { window.history.pushState("services", "services", cur_url[0].split("#")[0] + "#services"); - toastr.success('The ' + service + 'has been ' + action +'ed'); + toastr.success('The ' + service + ' has been ' + action +'ed'); loadServices(); } },