Pavel Loginov 2021-03-03 19:47:42 +06:00
parent 797a13fa83
commit c433e2ed0a
10 changed files with 165 additions and 155 deletions

View File

@ -194,6 +194,8 @@ elif form.getvalue('mode') is not None:
acl_if_word = 'path_beg -i ' acl_if_word = 'path_beg -i '
elif a == '4': elif a == '4':
acl_if_word = 'path_end -i ' acl_if_word = 'path_end -i '
elif a == '6':
acl_if_word = 'src ip '
else: else:
acl_if_word = '' acl_if_word = ''
@ -207,6 +209,10 @@ elif form.getvalue('mode') is not None:
elif acl_then[i] == '4': elif acl_then[i] == '4':
acl += ' http-request deny' acl += ' http-request deny'
acl_then_value = '' acl_then_value = ''
elif acl_then[i] == '6':
acl += ' return '
elif acl_then[i] == '7':
acl += ' set-header '
acl += acl_then_value + ' if { ' + acl_if_word + acl_value[i] + ' } \n' acl += acl_then_value + ' if { ' + acl_if_word + acl_value[i] + ' } \n'
except Exception: except Exception:

View File

@ -1053,7 +1053,7 @@ def update_db_v_51(**kwargs):
def update_ver(): def update_ver():
con, cur = get_cur() con, cur = get_cur()
sql = """update version set version = '5.0.0.0'; """ sql = """update version set version = '5.0.1.0'; """
try: try:
cur.execute(sql) cur.execute(sql)
con.commit() con.commit()

View File

@ -494,7 +494,7 @@ def show_installation_output(error, output, service):
print('error: '+error) print('error: '+error)
else: else:
for l in output: for l in output:
if "msg" in l or "FAILED" in l: if "FAILED" in l:
try: try:
l = l.split(':')[1] l = l.split(':')[1]
l = l.split('"')[1] l = l.split('"')[1]

View File

@ -13,7 +13,7 @@
'option smtpchk':'Check a SMTP service'} %} 'option smtpchk':'Check a SMTP service'} %}
{% set if_values = dict() %} {% set if_values = dict() %}
{% set if_values = {'1':'Host name starts with','2':'Host name ends with','3':'Path starts with','4':'Path ends with'} %} {% set if_values = {'1':'Host name starts with','2':'Host name ends with','3':'Path starts with','4':'Path ends with', '6': 'Src ip'} %}
<script src="/inc/add.js"></script> <script src="/inc/add.js"></script>
<div id="tabs"> <div id="tabs">
@ -121,20 +121,19 @@
<td class="addOption"> <td class="addOption">
<span title="Add ACL" id="add_listener_acl" class="link add-server"></span> <span title="Add ACL" id="add_listener_acl" class="link add-server"></span>
<div id="listener_acl" style="display: none;"> <div id="listener_acl" style="display: none;">
<span id="listener_acl_for_cloning"> <p style="border-bottom: 1px solid #ddd; padding-bottom: 10px;" id="listener_acl_rule">
<b class="padding10">if</b> <b class="padding10">if</b>
{{ select('listener_acl_if', name='acl_if', values=if_values, first='Choose if', class='force_close', disabled=false) }} {{ select('listener_acl_if', name='acl_if', values=if_values, first='Choose if', class='force_close', disabled=false) }}
<b class="padding10">value</b> <b class="padding10">value</b>
{{ input('listener_acl_value', name="acl_value") }} {{ input('listener_acl_value', name="acl_value") }}
<p style="border-bottom: 1px solid #ddd; padding-bottom: 10px;"> <b class="padding10">then</b>
<b class="padding10">then</b> {% set values = dict() %}
{% set values = dict() %} {% set values = {'2':'Redirect to','3':'Allow','4':'Deny', '6': 'Return', '7': 'Set-header'} %}
{% set values = {'2':'Redirect to','3':'Allow','4':'Deny'} %} {{ select('listener_acl_then', name='acl_then', values=values, first='Choose action', class='force_close', disabled=false) }}
{{ select('listener_acl_then', name='acl_then', values=values, first='Choose action', class='force_close', disabled=false) }} <b class="padding10">value</b>
<b class="padding10">value</b> {{ input('listener_acl_then_value', name='acl_then_value', title="Required if \'then\' is \'Use backend\' or \'Redirect\', \'Return\', or \'Set-header\'") }}
{{ input('listener_acl_then_value', name='acl_then_value', title="Required if \'then\' is \'Use backend\' or \'Redirect\'") }} <span class="minus minus-style" onclick="delete_acl_rule('listener_acl_rule')" title="Delete this rule"></span>
</p> </p>
</span>
</div> </div>
<span> <span>
<a class="link add-server" id="listener_add_acl" title="Add ACL" style="cursor: pointer; display: none;"></a> <a class="link add-server" id="listener_add_acl" title="Add ACL" style="cursor: pointer; display: none;"></a>
@ -335,20 +334,19 @@
<td class="addOption"> <td class="addOption">
<span title="Add ACL" id="add_frontend_acl" class="link add-server"></span> <span title="Add ACL" id="add_frontend_acl" class="link add-server"></span>
<div id="frontend_acl" style="display: none;"> <div id="frontend_acl" style="display: none;">
<span id="frontend_acl_for_cloning"> <p id="frontend_acl_rule" style="border-bottom: 1px solid #ddd; padding-bottom: 10px;">
<b class="padding10">if</b> <b class="padding10">if</b>
{{ select('frontend_acl_if', name='acl_if', values=if_values, first='Choose if', class='force_close', disabled=false) }} {{ select('frontend_acl_if', name='acl_if', values=if_values, first='Choose if', class='force_close', disabled=false) }}
<b class="padding10">value</b> <b class="padding10">value</b>
{{ input('frontend_acl_value', name='acl_value') }} {{ input('frontend_acl_value', name='acl_value') }}
<p style="border-bottom: 1px solid #ddd; padding-bottom: 10px;"> <b class="padding10">then</b>
<b class="padding10">then</b> {% set values = dict() %}
{% set values = dict() %} {% set values = {'5':'Use backend','2':'Redirect to','3':'Allow','4':'Deny', '6': 'Return', '7': 'Set-header'} %}
{% set values = {'5':'Use backend','2':'Redirect to','3':'Allow','4':'Deny'} %} {{ select('frontend_acl_then', name='acl_then', values=values, first='Choose action', class='force_close', disabled=false) }}
{{ select('frontend_acl_then', name='acl_then', values=values, first='Choose action', class='force_close', disabled=false) }} <b class="padding10">value</b>
<b class="padding10">value</b> {{ input('frontend_acl_then_value', name='acl_then_value', title="Required if \'then\' is \'Use backend\' or \'Redirect\', \'Return\', or \'Set-header\'") }}
{{ input('frontend_acl_then_value', name='acl_then_value', title="Required if \'then\' is \'Use backend\' or \'Redirect\'") }} <span class="minus minus-style" onclick="delete_acl_rule('frontend_acl_rule')" title="Delete this rule"></span>
</p> </p>
</span>
</div> </div>
<span> <span>
<a class="link add-server" id="frontend_add_acl" title="Add ACL" style="cursor: pointer; display: none;"></a> <a class="link add-server" id="frontend_add_acl" title="Add ACL" style="cursor: pointer; display: none;"></a>
@ -505,20 +503,19 @@
<td class="addOption"> <td class="addOption">
<span title="Add ACL" id="add_backend_acl" class="link add-server"></span> <span title="Add ACL" id="add_backend_acl" class="link add-server"></span>
<div id="backend_acl" style="display: none;"> <div id="backend_acl" style="display: none;">
<span id="backend_acl_for_cloning"> <p id="backend_acl_rule" style="border-bottom: 1px solid #ddd; padding-bottom: 10px;">
<b class="padding10">if</b> <b class="padding10">if</b>
{{ select('backend_acl_if', name='acl_if', values=if_values, first='Choose if', class='force_close', disabled=false) }} {{ select('backend_acl_if', name='acl_if', values=if_values, first='Choose if', class='force_close', disabled=false) }}
<b class="padding10">value</b> <b class="padding10">value</b>
{{ input('backend_acl_value', name="acl_value") }} {{ input('backend_acl_value', name="acl_value") }}
<p style="border-bottom: 1px solid #ddd; padding-bottom: 10px;"> <b class="padding10">then</b>
<b class="padding10">then</b> {% set values = dict() %}
{% set values = dict() %} {% set values = {'2':'Redirect to','3':'Allow','4':'Deny', '6': 'Return', '7': 'Set-header'} %}
{% set values = {'2':'Redirect to','3':'Allow','4':'Deny'} %} {{ select('backend_acl_then', name='acl_then', values=values, first='Choose action', class='force_close', disabled=false) }}
{{ select('backend_acl_then', name='acl_then', values=values, first='Choose action', class='force_close', disabled=false) }} <b class="padding10">value</b>
<b class="padding10">value</b> {{ input('backend_acl_then_value', name='acl_then_value', title="Required if \'then\' is \'Use backend\', \'Redirect\', \'Return\', or \'Set-header\'") }}
{{ input('backend_acl_then_value', name='acl_then_value', title="Required if \'then\' is \'Use backend\' or \'Redirect\'") }} <span class="minus minus-style" onclick="delete_acl_rule('backend_acl_rule')" title="Delete this rule"></span>
</p> </p>
</span>
</div> </div>
<span> <span>
<a class="link add-server" id="backend_add_acl" title="Add ACL" style="cursor: pointer; display: none;"></a> <a class="link add-server" id="backend_add_acl" title="Add ACL" style="cursor: pointer; display: none;"></a>
@ -762,8 +759,8 @@
<div id="ajax-option"></div> <div id="ajax-option"></div>
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;"> <div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
In this section you can create, edit and delete options with given parameters. And after use them as autocomplete in the "Add" sections In this section you can create, edit and delete options with given parameters. And after use them as autocomplete in the "Add" sections
<br /> </div>
<br /> <div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
How to use pre saved option you can see in How to use pre saved option you can see in
<a href="https://haproxy-wi.org/description.py?description=saved" title="How to use pre saved options" target="_blank"> <a href="https://haproxy-wi.org/description.py?description=saved" title="How to use pre saved options" target="_blank">
<b>this video</b> <b>this video</b>
@ -817,8 +814,8 @@
<div id="ajax-servers"></div> <div id="ajax-servers"></div>
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;"> <div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
In this section you can create, edit and delete servers. And after use them as autocomplete in the "Add" sections In this section you can create, edit and delete servers. And after use them as autocomplete in the "Add" sections
<br /> </div>
<br /> <div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
How to use pre saved servers you can see in How to use pre saved servers you can see in
<a href="https://haproxy-wi.org/description.py?description=saved" title="How to use pre saved servers" target="_blank"> <a href="https://haproxy-wi.org/description.py?description=saved" title="How to use pre saved servers" target="_blank">
<b>this video</b> <b>this video</b>
@ -890,8 +887,8 @@
</form> </form>
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;"> <div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
In this section you can create userlists. And after use them in the "Add" sections In this section you can create userlists. And after use them in the "Add" sections
<br /> </div>
<br /> <div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
How to use userlists you can read How to use userlists you can read
<a href="https://haproxy-wi.org/description.py?description=userlist" title="How to use userlists" target="_blank"> <a href="https://haproxy-wi.org/description.py?description=userlist" title="How to use userlists" target="_blank">
<b>here</b> <b>here</b>
@ -984,17 +981,7 @@ $( function() {
}); });
} }
}); });
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
var serv_ports = $('.send_proxy'); var serv_ports = $('.send_proxy');
console.log(serv_ports)
for (var i = 0; i <= serv_ports.length; i++) { for (var i = 0; i <= serv_ports.length; i++) {
var uniqId = makeid(3); var uniqId = makeid(3);

View File

@ -215,7 +215,7 @@
</div> </div>
<div id="show-updates" style="display: none;"> <div id="show-updates" style="display: none;">
<div> <div>
There is a new version HAProxy-WI. Check the <a href="/app/users.py#updatehapwi">Update page</a> There is a new version HAProxy-WI. Check the <a href="/app/users.py#updatehapwi" class="link">Update page</a>
</div> </div>
</div> </div>
<div class="footer"> <div class="footer">

View File

@ -72,7 +72,7 @@
{% endif %} {% endif %}
</p> </p>
</form> </form>
<div class="alert alert-info"><b>Note:</b> When reconfiguring the master server, the slave will be reconfigured automatically</div> <div class="alert alert-info alert-two-rows"><b>Note:</b> When reconfiguring the master server, the slave will be reconfigured automatically</div>
{% endif %} {% endif %}
{% endif %} {% endif %}
</center> </center>
@ -87,15 +87,17 @@
showConfig(); showConfig();
} }
if (cur_url[1].split('&')[0] == 'service=haproxy' || cur_url[1].split('&')[0] == 'service=None') { if (cur_url[1].split('&')[0] == 'service=haproxy' || cur_url[1].split('&')[0] == 'service=None') {
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"), {mode: "haproxy", lineNumbers: true}); var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"),
{mode: "haproxy", lineNumbers: true, autocapitalize: true, autocorrect: true, spellcheck: true});
} else { } else {
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"), {mode: "nginx", lineNumbers: true}); var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"),
{mode: "nginx", lineNumbers: true, autocapitalize: true, autocorrect: true, spellcheck: true});
} }
</script> </script>
<style> <style>
.CodeMirror { .CodeMirror {
line-height: 1.2em; line-height: 1.2em;
height: 60%; height: 70%;
} }
</style> </style>
<script> <script>

View File

@ -33,7 +33,7 @@
<option disabled selected>Choose log</option> <option disabled selected>Choose log</option>
{% for select in selects %} {% for select in selects %}
{% if page == 'for_editor' %} {% if page == 'for_editor' %}
{% if select.1.startswith('haproxy-wi') or select.1.startswith('config_edit') %} {% if select.1.startswith('haproxy-wi') or select.1.startswith('config_edit') or select.1.startswith('port_sca') %}
{% if select.0|int() == serv|int() %} {% if select.0|int() == serv|int() %}
<option value="{{ select.0 }}" selected>{{ select.1 }}</option> <option value="{{ select.0 }}" selected>{{ select.1 }}</option>
{% else %} {% else %}

View File

@ -23,24 +23,20 @@
<ul id='browse_histroy'></ul> <ul id='browse_histroy'></ul>
<div id="users"> <div id="users">
{% include 'include/admin_users.html' %} {% include 'include/admin_users.html' %}
{% include 'include/servers_group_error.html' %}
</div> </div>
<div id="servers"> <div id="servers">
{% include 'include/admin_servers.html' %} {% include 'include/admin_servers.html' %}
{% include 'include/servers_group_error.html' %}
</div> </div>
<div id="ssh"> <div id="ssh">
{% include 'include/admin_ssh.html' %} {% include 'include/admin_ssh.html' %}
{% include 'include/servers_group_error.html' %}
</div> </div>
<div id="checker"></div> <div id="checker"></div>
<div id="settings"> <div id="settings">
{% include 'include/admin_settings.html' %} {% include 'include/admin_settings.html' %}
{% include 'include/servers_group_error.html' %}
</div> </div>
<div id="installproxy"> <div id="installproxy">
@ -167,39 +163,11 @@
<div id="backup"> <div id="backup">
{% include 'include/admin_backup.html' %} {% include 'include/admin_backup.html' %}
{% include 'include/servers_group_error.html' %}
</div> </div>
</div> </div>
{% include 'include/admins_dialogs.html' %} {% include 'include/admins_dialogs.html' %}
{% include 'include/change_pass_form.html' %} {% include 'include/change_pass_form.html' %}
<script> <script>
if($('#new-server-group-add').val() == 1) {
$('.group_error').css('display', 'block');
$('#add-user-button').css('display', 'none');
$('#add-server-button').css('display', 'none');
$('.passwordChange').css('display', 'none');
$('#add-ssh-button').css('display', 'none');
$('#ssh_key_upload').css('display', 'none');
$('#add-telegram-button').css('display', 'none');
$('input').css('color', 'rgba(0, 0, 0, 0.3)');
setTimeout(function() {
$("input[type=checkbox]").checkboxradio( "disable" );
$("select").selectmenu( "disable" );
$("button").button( "disable" );
$("input").attr( "readonly", "readonly" );
$('.delete').remove()
$('#hapver').selectmenu('enable');
$('#haproxyaddserv').selectmenu('enable');
$('#nginxaddserv').selectmenu('enable');
$('#haproxy_exp_addserv').selectmenu('enable');
$('#nginx_exp_addserv').selectmenu('enable');
$('#geoipserv').selectmenu('enable');
$('#syn_flood').checkboxradio('enable');
$('#nginx_syn_flood').checkboxradio('enable');
$('#updating_geoip').checkboxradio('enable');
}, 500 );
}
$( function() { $( function() {
{% for user in users %} {% for user in users %}
$("#role-{{user.0}}" ).selectmenu({ $("#role-{{user.0}}" ).selectmenu({

View File

@ -1097,45 +1097,15 @@ $( function() {
$( "#backend_add_acl" ).show(); $( "#backend_add_acl" ).show();
$( "#add_backend_acl" ).hide(); $( "#add_backend_acl" ).hide();
} ); } );
var acl_option = '<b class="padding10">if</b>\n' +
'<select name="acl_if">\n' +
'\t<option selected>Choose if</option>\n' +
'\t<option value="1">Host name starts with</option>\n' +
'\t<option value="2">Host name ends with</option>\n' +
'\t<option value="3">Path starts with</option>\n' +
'\t<option value="4">Path ends with</option>\n' +
'</select>' +
'<b class="padding10">value</b>\n' +
'<input type="text" name="acl_value" class="form-control">\n' +
'<p style="border-bottom: 1px solid #ddd; padding-bottom: 10px;">\n' +
'<b class="padding10">then</b>\n' +
'<select name="acl_then">\n' +
'\t<option selected>Choose then</option>\n' +
'\t<option value="5">Use backend</option>\n' +
'\t<option value="2">Redirect to</option>\n' +
'\t<option value="3">Allow</option>\n' +
'\t<option value="4">Deny</option>\n' +
'</select>\n' +
'<b class="padding10">value</b>\n' +
'<input type="text" name="acl_then_value" class="form-control" value="" title="Required if \"then\" is \"Use backend\" or \"Redirect\""></p>'
$("#listener_add_acl").click(function(){ $("#listener_add_acl").click(function(){
$("#listener_acl").append(acl_option); make_actions_for_adding_acl_rule('#listener_acl');
$("#listener_acl").find('option[value=5]').remove(); $("#listener_acl").find('option[value=5]').remove();
$( "select" ).selectmenu();
$('[name=acl_if]').selectmenu({width: 180});
$('[name=acl_then]').selectmenu({width: 180});
}); });
$("#frontend_add_acl").click(function(){ $("#frontend_add_acl").click(function(){
$("#frontend_acl").append(acl_option); make_actions_for_adding_acl_rule('#frontend_acl');
$( "select" ).selectmenu();
$('[name=acl_if]').selectmenu({width: 180});
$('[name=acl_then]').selectmenu({width: 180});
}); });
$("#backend_add_acl").click(function(){ $("#backend_add_acl").click(function(){
$("#backend_acl").append(acl_option); make_actions_for_adding_acl_rule('#backend_acl');
$( "select" ).selectmenu();
$('[name=acl_if]').selectmenu({width: 180});
$('[name=acl_then]').selectmenu({width: 180});
}); });
}); });
function resetProxySettings() { function resetProxySettings() {
@ -1324,6 +1294,10 @@ function view_ssl(id) {
buttons: { buttons: {
Close: function() { Close: function() {
$( this ).dialog( "close" ); $( this ).dialog( "close" );
},
Delete: function () {
$( this ).dialog( "close" );
confirmDeleting("SSL cert", id, $( this ), "");
} }
} }
}); });
@ -1331,6 +1305,26 @@ function view_ssl(id) {
} }
} ); } );
} }
function deleteSsl(id) {
$.ajax( {
url: "options.py",
data: {
serv: $('#serv5').val(),
delcert: id,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
if (data.indexOf('error: ') != '-1') {
toastr.error(data);
} else {
toastr.clear();
toastr.success('SSL cert ' + id + ' has been deleted');
$("#ssl_key_view").trigger( "click" );
}
}
} );
}
function change_select_acceleration(id) { function change_select_acceleration(id) {
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
@ -1608,3 +1602,53 @@ function confirmDeleting(deleting_thing, id, dialog_id, color) {
} }
}); });
} }
function delete_acl_rule(id) {
$('#'+id).remove();
}
var acl_option = '<p id="new_acl_p" style="border-bottom: 1px solid #ddd; padding-bottom: 10px;">\n' +
'<b class="padding10">if</b>\n' +
'<select name="acl_if">\n' +
'\t<option selected>Choose if</option>\n' +
'\t<option value="1">Host name starts with</option>\n' +
'\t<option value="2">Host name ends with</option>\n' +
'\t<option value="3">Path starts with</option>\n' +
'\t<option value="4">Path ends with</option>\n' +
'\t<option value="6">Src ip</option>\n' +
'</select> ' +
'<b class="padding10">value</b>\n' +
'<input type="text" name="acl_value" class="form-control">\n' +
'<b class="padding10">then</b>\n' +
'<select name="acl_then">\n' +
'\t<option selected>Choose then</option>\n' +
'\t<option value="5">Use backend</option>\n' +
'\t<option value="2">Redirect to</option>\n' +
'\t<option value="3">Allow</option>\n' +
'\t<option value="4">Deny</option>\n' +
'\t<option value="6">Return</option>\n' +
'\t<option value="7">Set-header</option>\n' +
'</select>\n' +
'<b class="padding10">value</b>\n' +
'<input type="text" name="acl_then_value" class="form-control" value="" title="Required if \"then\" is \"Use backend\" or \"Redirect\"">\n' +
'<span class="minus minus-style" id="new_acl_rule_minus" title="Delete this ACL"></span>' +
'</p>'
function make_actions_for_adding_acl_rule(section_id) {
var random_id = makeid(3);
$(section_id).append(acl_option);
$('#new_acl_rule_minus').attr('onclick', 'delete_acl_rule(\''+random_id+'\')');
$('#new_acl_rule_minus').attr('id', '');
$('#new_acl_p').attr('id', random_id);
$('#new_acl_rule_minus').attr('id', '');
$.getScript("/inc/fontawesome.min.js");
$( "select" ).selectmenu();
$('[name=acl_if]').selectmenu({width: 180});
$('[name=acl_then]').selectmenu({width: 180});
}
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}

View File

@ -954,6 +954,9 @@ label {
background-color: grey; background-color: grey;
color: #aaa; color: #aaa;
} }
.minus-style {
cursor: pointer;
}
@media (max-width: 1920px) { @media (max-width: 1920px) {
#logo_span { #logo_span {
margin-left: 17%; margin-left: 17%;