Pavel Loginov 3 years ago
parent 4a74ce394d
commit adbec8a967

@ -14,7 +14,12 @@ print('Content-type: text/html\n')
funct.check_login()
funct.page_for_admin(level=3)
if form.getvalue('mode') is None and form.getvalue('new_userlist') is None:
if (
form.getvalue('mode') is None and
form.getvalue('new_userlist') is None and
form.getvalue('peers-name') is None and
form.getvalue('generateconfig') is None
):
try:
user, user_id, role, token, servers = funct.get_users_params()
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
@ -54,7 +59,6 @@ if form.getvalue('mode') is None and form.getvalue('new_userlist') is None:
print(template)
elif form.getvalue('mode') is not None:
cert_path = sql.get_setting('cert_path')
haproxy_dir = sql.get_setting('haproxy_dir')
port = form.getvalue('port')
bind = ""
@ -99,7 +103,10 @@ elif form.getvalue('mode') is not None:
maxconn = " maxconn " + form.getvalue('maxconn') + "\n"
if form.getvalue('ssl') == "https" and form.getvalue('mode') != "tcp":
cert_path = sql.get_setting('cert_path')
if form.getvalue('cert') is not None:
ssl = "ssl crt " + cert_path + form.getvalue('cert')
if form.getvalue('ssl-dis-check') is None:
if form.getvalue('ssl-check') == "ssl-check":
ssl_check = " ssl verify none"
else:
@ -323,6 +330,22 @@ if form.getvalue('new_userlist') is not None:
config_add = "\n" + name + new_userlist_groups + new_users_list
if form.getvalue('peers-name') is not None:
name = "peers " + form.getvalue('peers-name') + "\n"
servers_split = ''
if form.getvalue('servers') is not None:
servers = form.getlist('servers')
server_port = form.getlist('server_port')
servers_name = form.getlist('servers_name')
i = 0
for server in servers:
servers_split += " peer {0} {1}:{2} \n".format(servers_name[i], server, server_port[i])
i += 1
config_add = "\n" + name + servers_split
if form.getvalue('generateconfig') is None:
try:
funct.check_is_server_in_group(serv)

@ -1251,9 +1251,26 @@ def update_db_v_5_1_3(**kwargs):
con.close()
def update_db_v_5_2_0(**kwargs):
con, cur = get_cur()
sql = list()
sql.append("INSERT INTO settings (param, value, section, `desc`) values('portscanner_keep_history_range', '14', 'monitoring', 'How many days to keep the history for the Port scanner service')")
for i in sql:
try:
cur.execute(i)
con.commit()
except sqltool.Error as e:
pass
else:
if kwargs.get('silent') != 1:
print('Updating... DB has been updated to version 5.2.0')
cur.close()
con.close()
def update_ver():
con, cur = get_cur()
sql = """update version set version = '5.1.4.0'; """
sql = """update version set version = '5.2.0.0'; """
try:
cur.execute(sql)
con.commit()
@ -1296,6 +1313,7 @@ def update_all():
update_db_v_5_1_1()
update_db_v_5_1_2()
update_db_v_5_1_3()
update_db_v_5_2_0()
update_ver()
@ -1332,6 +1350,7 @@ def update_all_silent():
update_db_v_5_1_1(silent=1)
update_db_v_5_1_2(silent=1)
update_db_v_5_1_3(silent=1)
update_db_v_5_2_0(silent=1)
update_ver()

@ -83,6 +83,28 @@ $( function() {
$( "#https-hide-backend" ).hide( "fast" );
}
});
$( "#ssl-dis-check-listen" ).click( function(){
if ($('#ssl-dis-check-listen').is(':checked')) {
$( "#ssl-check-listen" ).checkboxradio( "disable" );
$( "#ssl-check-listen" ).prop( "checked", false );
$( "#ssl-check-listen" ).checkboxradio("refresh");
} else {
$( "#ssl-check-listen" ).checkboxradio( "enable" );
$( "#ssl-check-listen" ).prop( "checked", true );
$( "#ssl-check-listen" ).checkboxradio("refresh");
}
});
$( "#ssl-dis-check-backend" ).click( function(){
if ($('#ssl-dis-check-backend').is(':checked')) {
$( "#ssl-check-backend" ).checkboxradio( "disable" );
$( "#ssl-check-backend" ).prop( "checked", false );
$( "#ssl-check-backend" ).checkboxradio("refresh");
} else {
$( "#ssl-check-backend" ).checkboxradio( "enable" );
$( "#ssl-check-backend" ).prop( "checked", true );
$( "#ssl-check-backend" ).checkboxradio("refresh");
}
});
$( "#options-listen-show" ).click( function(){
if ($('#options-listen-show').is(':checked')) {
$( "#options-listen-show-div" ).show( "fast" );
@ -967,7 +989,7 @@ $( function() {
}
});
var add_server_var = '<br /><input name="servers" title="Backend IP" size=14 placeholder="xxx.xxx.xxx.xxx" class="form-control second-server">: ' +
'<input name="server_port" required title="Backend IP" size=3 placeholder="yyy" class="form-control second-server add_server_number" type="number">' +
'<input name="server_port" required title="Backend port" size=3 placeholder="yyy" class="form-control second-server add_server_number" type="number">' +
'<input name="server_maxconn" required title="Maxconn. Default 200" size=5 value="200" class="form-control add_server_number" type="number">'
$('[name=add-server-input]').click(function() {
$("[name=add_servers]").append(add_server_var);
@ -980,6 +1002,12 @@ $( function() {
$('#add-userlist-group').click(function() {
$('#userlist-groups').append(add_userlist_group_var);
});
var add_peer_var = '<br /><input name="servers_name" required title="Peer name" size=14 placeholder="haproxyN" class="form-control">' +
'<input name="servers" title="Backend IP" size=14 placeholder="xxx.xxx.xxx.xxx" class="form-control second-server">: ' +
'<input name="server_port" required title="Backend port" size=3 placeholder="yyy" class="form-control second-server add_server_number" type="number">'
$('[name=add-peer-input]').click(function() {
$("[name=add_peers]").append(add_peer_var);
});
$('.advance-show-button').click(function() {
$('.advance').fadeIn();
$('.advance-show-button').css('display', 'none');
@ -1206,6 +1234,7 @@ function resetProxySettings() {
$('[name=server_port]').val('');
$('input:checkbox').prop( "checked", false );
$('[name=ssl-check]').prop( "checked", true );
$('[name=ssl-dis-check]').prop( "checked", false );
$('[name=check-servers]').prop( "checked", true );
$('input:checkbox').checkboxradio("refresh");
$('.advance-show').fadeIn();
@ -1237,7 +1266,10 @@ function createSsl(TabId, proxy) {
$( "#tabs" ).tabs( "option", "active", TabId );
$( "#https-hide-"+proxy).show("fast");
$('#https-'+proxy).prop( "checked", true );
$('#https-'+proxy).checkboxradio("refresh");
$('#ssl-dis-check-'+proxy).prop( "checked", true );
$('#ssl-check-'+proxy).prop( "checked", false );
$('#ssl-check-'+proxy).checkboxradio('disable');
$('input:checkbox').checkboxradio("refresh");
$("#path-cert-"+proxy ).attr('required',true);
if (TabId == 1) {
TabId = '';

Loading…
Cancel
Save