mirror of https://github.com/Aidaho12/haproxy-wi
parent
a852d63129
commit
7e9781aa12
|
@ -707,10 +707,9 @@ def update_db_v_4_5_4(**kwargs):
|
|||
con.close()
|
||||
|
||||
|
||||
|
||||
def update_ver(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """update version set version = '4.5.6.0'; """
|
||||
sql = """update version set version = '4.5.7.0'; """
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
|
|
@ -354,8 +354,9 @@ def get_sections(config, **kwargs):
|
|||
line.startswith('#HideBlockStart') or
|
||||
line.startswith('peers') or
|
||||
line.startswith('resolvers') or
|
||||
line.startswith('userlist')
|
||||
):
|
||||
line.startswith('userlist') or
|
||||
line.startswith('http-errors')
|
||||
):
|
||||
line = line.strip()
|
||||
return_config.append(line)
|
||||
|
||||
|
@ -387,7 +388,8 @@ def get_section_from_config(config, section):
|
|||
line.startswith('#HideBlockStart') or
|
||||
line.startswith('peers') or
|
||||
line.startswith('resolvers') or
|
||||
line.startswith('userlist')
|
||||
line.startswith('userlist') or
|
||||
line.startswith('http-errors')
|
||||
):
|
||||
record = False
|
||||
end_line = index
|
||||
|
|
|
@ -45,11 +45,20 @@ if form.getvalue('checkSshConnect') is not None and serv is not None:
|
|||
if form.getvalue('getcert') is not None and serv is not None:
|
||||
cert_id = form.getvalue('getcert')
|
||||
cert_path = sql.get_setting('cert_path')
|
||||
commands = ["cat " + cert_path + "/" + cert_id]
|
||||
commands = ["openssl x509 -in " + cert_path + "/" + cert_id + " -text"]
|
||||
try:
|
||||
funct.ssh_command(serv, commands, ip="1")
|
||||
except Exception as e:
|
||||
print('error: Can not connect to the server ' + e.args[0])
|
||||
print('error: Cannot connect to the server ' + e.args[0])
|
||||
|
||||
if form.getvalue('delcert') is not None and serv is not None:
|
||||
cert_id = form.getvalue('delcert')
|
||||
cert_path = sql.get_setting('cert_path')
|
||||
commands = ["sudo rm -f " + cert_path + "/" + cert_id]
|
||||
try:
|
||||
funct.ssh_command(serv, commands, ip="1")
|
||||
except Exception as e:
|
||||
print('error: Cannot delete the certificate ' + e.args[0])
|
||||
|
||||
if serv and form.getvalue('ssl_cert'):
|
||||
cert_local_dir = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('ssl_local_path')
|
||||
|
@ -1534,7 +1543,7 @@ if form.getvalue('newuser') is not None:
|
|||
|
||||
if funct.check_user_group():
|
||||
if funct.is_admin(level=role_id):
|
||||
if sql.add_user(new_user, email, password, role, activeuser):
|
||||
if sql.add_user(new_user, email, password, role, activeuser, group):
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||
|
@ -1886,6 +1895,15 @@ if form.getvalue('changeUserGroupId') is not None:
|
|||
|
||||
funct.logging('localhost', ' has upgraded groups for user: ' + user, haproxywi=1, login=1)
|
||||
|
||||
if form.getvalue('changeUserCurrentGroupId') is not None:
|
||||
group_id = form.getvalue('changeUserCurrentGroupId')
|
||||
user_uuid = form.getvalue('changeUserGroupsUser')
|
||||
|
||||
if sql.update_user_current_groups(group_id, user_uuid):
|
||||
print('Ok')
|
||||
else:
|
||||
print('error: Cannot change group')
|
||||
|
||||
if form.getvalue('getcurrentusergroup') is not None:
|
||||
import http.cookies
|
||||
|
||||
|
|
30
app/sql.py
30
app/sql.py
|
@ -31,14 +31,14 @@ def get_cur():
|
|||
return con, cur
|
||||
|
||||
|
||||
def add_user(user, email, password, role, activeuser):
|
||||
def add_user(user, email, password, role, activeuser, group):
|
||||
con, cur = get_cur()
|
||||
if password != 'aduser':
|
||||
sql = """INSERT INTO user (username, email, password, role, activeuser)
|
||||
VALUES ('%s', '%s', '%s', '%s', '%s')""" % (user, email, funct.get_hash(password), role, activeuser)
|
||||
sql = """INSERT INTO user (username, email, password, role, activeuser, 'groups')
|
||||
VALUES ('%s', '%s', '%s', '%s', '%s', '%s')""" % (user, email, funct.get_hash(password), role, activeuser, group)
|
||||
else:
|
||||
sql = """INSERT INTO user (username, email, role, ldap_user, activeuser)
|
||||
VALUES ('%s', '%s', '%s', '1', '%s')""" % (user, email, role, activeuser)
|
||||
sql = """INSERT INTO user (username, email, role, ldap_user, activeuser, 'groups')
|
||||
VALUES ('%s', '%s', '%s', '1', '%s')""" % (user, email, role, activeuser, group)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
@ -113,6 +113,25 @@ def delete_user_groups(id):
|
|||
return True
|
||||
|
||||
|
||||
def update_user_current_groups(groups, user_uuid):
|
||||
con, cur = get_cur()
|
||||
user_id = get_user_id_by_uuid(user_uuid)
|
||||
sql = """update user set groups = '%s' where id = '%s'""" % (groups, user_id)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
except sqltool.Error as e:
|
||||
funct.out_error(e)
|
||||
con.rollback()
|
||||
cur.close()
|
||||
con.close()
|
||||
return False
|
||||
else:
|
||||
cur.close()
|
||||
con.close()
|
||||
return True
|
||||
|
||||
|
||||
def update_user_password(password, id):
|
||||
con, cur = get_cur()
|
||||
sql = """update user set password = '%s'
|
||||
|
@ -801,7 +820,6 @@ def get_dick_permit(**kwargs):
|
|||
print('Atata!')
|
||||
|
||||
|
||||
|
||||
def is_master(ip, **kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """ select slave.ip, slave.hostname from servers as master left join servers as slave on master.id = slave.master where master.ip = '%s' """ % ip
|
||||
|
|
|
@ -171,6 +171,16 @@
|
|||
</span><div>
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
{% if line.startswith('http-errors') %}
|
||||
</div><span class="param">{{ line }}
|
||||
{% if role %}
|
||||
<span class="accordion-link">
|
||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
||||
</span>
|
||||
{% endif %}
|
||||
</span><div>
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
{% if "acl" in line or "option" in line or "server" in line %}
|
||||
{% if "timeout" not in line and "default-server" not in line and "#use_backend" not in line and "#" not in line%}
|
||||
<span class="numRow">
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
padding-bottom: 8px;
|
||||
margin-bottom: -20px !important;
|
||||
}
|
||||
.ui-checkboxradio-label {
|
||||
padding-bottom: 5px !important;
|
||||
padding-top: 5px !important;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var ip = []
|
||||
|
@ -82,7 +86,11 @@
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
showOverviewServer('{{s.1}}', '{{s.2}}', '{{s.0}}', '{{service}}');
|
||||
showBytes('{{ s.2 }}')
|
||||
{% if service == 'nginx' %}
|
||||
showNginxConnections('{{ s.2 }}')
|
||||
{% else %}
|
||||
showBytes('{{ s.2 }}')
|
||||
{% endif %}
|
||||
}
|
||||
showMetrics();
|
||||
$( function() {
|
||||
|
@ -227,17 +235,15 @@
|
|||
{% if service != 'nginx' %}
|
||||
<a href="/app/config.py?serv={{s.2}}&showMap" class="ui-button ui-widget ui-corner-all" title="Show map">Map</a>
|
||||
{% endif %}
|
||||
<a href="/app/viewsttats.py?service={{service}}&serv={{s.2}}" class="ui-button ui-widget ui-corner-all" title="View stat">Stat</a>
|
||||
<a href="/app/logs.py?service={{service}}&serv={{s.2}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" class="ui-button ui-widget ui-corner-all" title="View log">Log</a>
|
||||
{% if role <= 2 %}
|
||||
<a href="/app/versions.py?service={{service}}&serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all">Versions</a>
|
||||
{% endif %}
|
||||
<a href="/app/viewsttats.py?service={{service}}&serv={{s.2}}" class="ui-button ui-widget ui-corner-all" title="View stat">Stats</a>
|
||||
<a href="/app/logs.py?service={{service}}&serv={{s.2}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" class="ui-button ui-widget ui-corner-all" title="View log">Log</a>
|
||||
{% if role <= 2 %}
|
||||
<a href="/app/versions.py?service={{service}}&serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all">Versions</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% if serv %}
|
||||
{% if service == 'haproxy' %}
|
||||
<div id="bin_bout"></div>
|
||||
{% endif %}
|
||||
<div id="bin_bout"></div>
|
||||
<div id="ajax-server-{{s.0}}" class="ajax-server"></div>
|
||||
<div class="div-server div-backends">
|
||||
<div class="server-name backends">
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create Listen" class="redirectListen span-link">Create Listen</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
A "listen" section defines a complete proxy with its frontend and backend parts combined in one section. It is generally useful for TCP-only traffic.
|
||||
</div>
|
||||
</div>
|
||||
|
@ -39,7 +39,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create SSL Listen" class="redirectListen span-link" id="create-ssl-listen">Create SSL Listen</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create HTTPS Proxy with the SSL termination on HAProxy and SSL offload.
|
||||
HAProxy will send to backends HTTP traffic. You need have <span title="Upload SSL" class="redirectSsl span-link" style="color: #5d9ceb">uploaded a PEM certificat</span>
|
||||
</div>
|
||||
|
@ -50,7 +50,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create SSL Listen" class="redirectListen span-link" id="create-https-listen">Create HTTPS Listen</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create HTTPS Proxy without the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTPS traffic
|
||||
</div>
|
||||
</div>
|
||||
|
@ -60,7 +60,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create presaved options" class="span-link" id="add4">Create presaved options</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create, edit and delete options with given parameters. And after use them as autocomplete in the "Add" sections
|
||||
</div>
|
||||
</div>
|
||||
|
@ -72,7 +72,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create Frontend" class="redirectFrontend span-link">Create Frontend</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
A "frontend" section describes a set of listening sockets accepting client connections.
|
||||
And forwards them to backend
|
||||
<br />
|
||||
|
@ -92,7 +92,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create SSL Frontend" class="redirectListen span-link" id="create-ssl-frontend">Create SSL Frontend</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create HTTPS Frontend with the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTP traffic. You need have <span title="Upload SSL" class="redirectSsl span-link" style="color: #5d9ceb">uploaded a PEM certificat</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -102,7 +102,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create HTTPS Frontend" class="redirectListen span-link" id="create-https-frontend">Create HTTPS Frontend</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create HTTPS Frontend without the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTPS traffic
|
||||
</div>
|
||||
</div>
|
||||
|
@ -112,7 +112,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create presaved servers" class="span-link" id="add5">Create presaved servers</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create, edit and delete servers. And after use them as autocomplete in the "Add" sections
|
||||
</div>
|
||||
</div>
|
||||
|
@ -124,7 +124,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create Backend" class="redirectBackend span-link">Create Backend</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
A "backend" section describes a set of servers to which the proxy will connect to forward incoming connections.
|
||||
<br />
|
||||
<br />
|
||||
|
@ -135,7 +135,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create SSL Backend" class="redirectListen span-link" id="create-http-backend">Create HTTP Backend</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create HTTP Backend
|
||||
</div>
|
||||
</div>
|
||||
|
@ -144,7 +144,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create HTTPS Backend" class="redirectListen span-link" id="create-ssl-backend">Create SSL Backend</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create HTTPS Backend with the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTP traffic. You need have <span title="Upload SSL" class="redirectSsl span-link" style="color: #5d9ceb">uploaded a PEM certificat</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -154,7 +154,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create SSL Backend" class="redirectListen span-link" id="create-https-backend">Create HTTPS Backend</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create HTTPS Backend without the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTPS traffic
|
||||
</div>
|
||||
</div>
|
||||
|
@ -164,7 +164,7 @@
|
|||
<div class="server-name">
|
||||
<span title="Create userlists" class="span-link" id="add6">Create userlists</span>
|
||||
</div>
|
||||
<div class="server-desc">
|
||||
<div class="server-desc add_proxy">
|
||||
Create userlists. And use it in the "Add" sections
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1112,7 +1112,24 @@ listHistroy()
|
|||
function changeCurrentGroupF(){
|
||||
Cookies.remove('group');
|
||||
Cookies.set('group', $('#newCurrentGroup').val(), { expires: 365, path: '/app', samesite: 'strict', secure: 'true' });
|
||||
location.reload();
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
changeUserCurrentGroupId: $('#newCurrentGroup').val(),
|
||||
changeUserGroupsUser: Cookies.get('uuid'),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
if (data.indexOf('error: ') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
toastr.clear();
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
}
|
||||
function sort_by_status() {
|
||||
$('<div id="err_services" style="clear: both;"></div>').appendTo('.main');
|
||||
|
|
|
@ -805,6 +805,9 @@ label {
|
|||
height: 80px;
|
||||
width: 390px;
|
||||
}
|
||||
.add_proxy {
|
||||
width: 380px;
|
||||
}
|
||||
.server-act-links {
|
||||
margin-left: -2px;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue