Pavel Loginov 2021-01-02 22:36:43 +06:00
parent a852d63129
commit 7e9781aa12
9 changed files with 110 additions and 37 deletions

View File

@ -707,10 +707,9 @@ def update_db_v_4_5_4(**kwargs):
con.close() con.close()
def update_ver(**kwargs): def update_ver(**kwargs):
con, cur = get_cur() con, cur = get_cur()
sql = """update version set version = '4.5.6.0'; """ sql = """update version set version = '4.5.7.0'; """
try: try:
cur.execute(sql) cur.execute(sql)
con.commit() con.commit()

View File

@ -354,7 +354,8 @@ def get_sections(config, **kwargs):
line.startswith('#HideBlockStart') or line.startswith('#HideBlockStart') or
line.startswith('peers') or line.startswith('peers') or
line.startswith('resolvers') or line.startswith('resolvers') or
line.startswith('userlist') line.startswith('userlist') or
line.startswith('http-errors')
): ):
line = line.strip() line = line.strip()
return_config.append(line) return_config.append(line)
@ -387,7 +388,8 @@ def get_section_from_config(config, section):
line.startswith('#HideBlockStart') or line.startswith('#HideBlockStart') or
line.startswith('peers') or line.startswith('peers') or
line.startswith('resolvers') or line.startswith('resolvers') or
line.startswith('userlist') line.startswith('userlist') or
line.startswith('http-errors')
): ):
record = False record = False
end_line = index end_line = index

View File

@ -45,12 +45,21 @@ if form.getvalue('checkSshConnect') is not None and serv is not None:
if form.getvalue('getcert') 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_id = form.getvalue('getcert')
cert_path = sql.get_setting('cert_path') cert_path = sql.get_setting('cert_path')
commands = ["cat " + cert_path + "/" + cert_id] commands = ["openssl x509 -in " + cert_path + "/" + cert_id + " -text"]
try: try:
funct.ssh_command(serv, commands, ip="1") funct.ssh_command(serv, commands, ip="1")
except Exception as e: except Exception as e:
print('error: Cannot 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'): if serv and form.getvalue('ssl_cert'):
cert_local_dir = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('ssl_local_path') cert_local_dir = os.path.dirname(os.getcwd()) + "/" + sql.get_setting('ssl_local_path')
cert_path = sql.get_setting('cert_path') cert_path = sql.get_setting('cert_path')
@ -1534,7 +1543,7 @@ if form.getvalue('newuser') is not None:
if funct.check_user_group(): if funct.check_user_group():
if funct.is_admin(level=role_id): 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 from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True) 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) 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: if form.getvalue('getcurrentusergroup') is not None:
import http.cookies import http.cookies

View File

@ -31,14 +31,14 @@ def get_cur():
return con, 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() con, cur = get_cur()
if password != 'aduser': if password != 'aduser':
sql = """INSERT INTO user (username, email, password, role, activeuser) sql = """INSERT INTO user (username, email, password, role, activeuser, 'groups')
VALUES ('%s', '%s', '%s', '%s', '%s')""" % (user, email, funct.get_hash(password), role, activeuser) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')""" % (user, email, funct.get_hash(password), role, activeuser, group)
else: else:
sql = """INSERT INTO user (username, email, role, ldap_user, activeuser) sql = """INSERT INTO user (username, email, role, ldap_user, activeuser, 'groups')
VALUES ('%s', '%s', '%s', '1', '%s')""" % (user, email, role, activeuser) VALUES ('%s', '%s', '%s', '1', '%s')""" % (user, email, role, activeuser, group)
try: try:
cur.execute(sql) cur.execute(sql)
con.commit() con.commit()
@ -113,6 +113,25 @@ def delete_user_groups(id):
return True 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): def update_user_password(password, id):
con, cur = get_cur() con, cur = get_cur()
sql = """update user set password = '%s' sql = """update user set password = '%s'
@ -801,7 +820,6 @@ def get_dick_permit(**kwargs):
print('Atata!') print('Atata!')
def is_master(ip, **kwargs): def is_master(ip, **kwargs):
con, cur = get_cur() 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 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

View File

@ -171,6 +171,16 @@
</span><div> </span><div>
{% continue %} {% continue %}
{% endif %} {% endif %}
{% if line.startswith('http-errors') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if "acl" in line or "option" in line or "server" in line %} {% 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%} {% if "timeout" not in line and "default-server" not in line and "#use_backend" not in line and "#" not in line%}
<span class="numRow"> <span class="numRow">

View File

@ -20,6 +20,10 @@
padding-bottom: 8px; padding-bottom: 8px;
margin-bottom: -20px !important; margin-bottom: -20px !important;
} }
.ui-checkboxradio-label {
padding-bottom: 5px !important;
padding-top: 5px !important;
}
</style> </style>
<script> <script>
var ip = [] var ip = []
@ -82,7 +86,11 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
showOverviewServer('{{s.1}}', '{{s.2}}', '{{s.0}}', '{{service}}'); showOverviewServer('{{s.1}}', '{{s.2}}', '{{s.0}}', '{{service}}');
{% if service == 'nginx' %}
showNginxConnections('{{ s.2 }}')
{% else %}
showBytes('{{ s.2 }}') showBytes('{{ s.2 }}')
{% endif %}
} }
showMetrics(); showMetrics();
$( function() { $( function() {
@ -227,7 +235,7 @@
{% if service != 'nginx' %} {% 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> <a href="/app/config.py?serv={{s.2}}&showMap" class="ui-button ui-widget ui-corner-all" title="Show map">Map</a>
{% endif %} {% 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/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> <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 %} {% 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> <a href="/app/versions.py?service={{service}}&serv={{s.2}}&open=open" class="ui-button ui-widget ui-corner-all">Versions</a>
@ -235,9 +243,7 @@
</div> </div>
</div> </div>
{% if serv %} {% if serv %}
{% if service == 'haproxy' %}
<div id="bin_bout"></div> <div id="bin_bout"></div>
{% endif %}
<div id="ajax-server-{{s.0}}" class="ajax-server"></div> <div id="ajax-server-{{s.0}}" class="ajax-server"></div>
<div class="div-server div-backends"> <div class="div-server div-backends">
<div class="server-name backends"> <div class="server-name backends">

View File

@ -19,7 +19,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create Listen" class="redirectListen span-link">Create Listen</span> <span title="Create Listen" class="redirectListen span-link">Create Listen</span>
</div> </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. 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>
</div> </div>
@ -39,7 +39,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create SSL Listen" class="redirectListen span-link" id="create-ssl-listen">Create SSL Listen</span> <span title="Create SSL Listen" class="redirectListen span-link" id="create-ssl-listen">Create SSL Listen</span>
</div> </div>
<div class="server-desc"> <div class="server-desc add_proxy">
Create HTTPS Proxy with the SSL termination on HAProxy and SSL offload. 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> 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>
@ -50,7 +50,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create SSL Listen" class="redirectListen span-link" id="create-https-listen">Create HTTPS Listen</span> <span title="Create SSL Listen" class="redirectListen span-link" id="create-https-listen">Create HTTPS Listen</span>
</div> </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 Create HTTPS Proxy without the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTPS traffic
</div> </div>
</div> </div>
@ -60,7 +60,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create presaved options" class="span-link" id="add4">Create presaved options</span> <span title="Create presaved options" class="span-link" id="add4">Create presaved options</span>
</div> </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 Create, edit and delete options with given parameters. And after use them as autocomplete in the "Add" sections
</div> </div>
</div> </div>
@ -72,7 +72,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create Frontend" class="redirectFrontend span-link">Create Frontend</span> <span title="Create Frontend" class="redirectFrontend span-link">Create Frontend</span>
</div> </div>
<div class="server-desc"> <div class="server-desc add_proxy">
A "frontend" section describes a set of listening sockets accepting client connections. A "frontend" section describes a set of listening sockets accepting client connections.
And forwards them to backend And forwards them to backend
<br /> <br />
@ -92,7 +92,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create SSL Frontend" class="redirectListen span-link" id="create-ssl-frontend">Create SSL Frontend</span> <span title="Create SSL Frontend" class="redirectListen span-link" id="create-ssl-frontend">Create SSL Frontend</span>
</div> </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> 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>
</div> </div>
@ -102,7 +102,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create HTTPS Frontend" class="redirectListen span-link" id="create-https-frontend">Create HTTPS Frontend</span> <span title="Create HTTPS Frontend" class="redirectListen span-link" id="create-https-frontend">Create HTTPS Frontend</span>
</div> </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 Create HTTPS Frontend without the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTPS traffic
</div> </div>
</div> </div>
@ -112,7 +112,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create presaved servers" class="span-link" id="add5">Create presaved servers</span> <span title="Create presaved servers" class="span-link" id="add5">Create presaved servers</span>
</div> </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 Create, edit and delete servers. And after use them as autocomplete in the "Add" sections
</div> </div>
</div> </div>
@ -124,7 +124,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create Backend" class="redirectBackend span-link">Create Backend</span> <span title="Create Backend" class="redirectBackend span-link">Create Backend</span>
</div> </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. A "backend" section describes a set of servers to which the proxy will connect to forward incoming connections.
<br /> <br />
<br /> <br />
@ -135,7 +135,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create SSL Backend" class="redirectListen span-link" id="create-http-backend">Create HTTP Backend</span> <span title="Create SSL Backend" class="redirectListen span-link" id="create-http-backend">Create HTTP Backend</span>
</div> </div>
<div class="server-desc"> <div class="server-desc add_proxy">
Create HTTP Backend Create HTTP Backend
</div> </div>
</div> </div>
@ -144,7 +144,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create HTTPS Backend" class="redirectListen span-link" id="create-ssl-backend">Create SSL Backend</span> <span title="Create HTTPS Backend" class="redirectListen span-link" id="create-ssl-backend">Create SSL Backend</span>
</div> </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> 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>
</div> </div>
@ -154,7 +154,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create SSL Backend" class="redirectListen span-link" id="create-https-backend">Create HTTPS Backend</span> <span title="Create SSL Backend" class="redirectListen span-link" id="create-https-backend">Create HTTPS Backend</span>
</div> </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 Create HTTPS Backend without the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTPS traffic
</div> </div>
</div> </div>
@ -164,7 +164,7 @@
<div class="server-name"> <div class="server-name">
<span title="Create userlists" class="span-link" id="add6">Create userlists</span> <span title="Create userlists" class="span-link" id="add6">Create userlists</span>
</div> </div>
<div class="server-desc"> <div class="server-desc add_proxy">
Create userlists. And use it in the "Add" sections Create userlists. And use it in the "Add" sections
</div> </div>
</div> </div>

View File

@ -1112,8 +1112,25 @@ listHistroy()
function changeCurrentGroupF(){ function changeCurrentGroupF(){
Cookies.remove('group'); Cookies.remove('group');
Cookies.set('group', $('#newCurrentGroup').val(), { expires: 365, path: '/app', samesite: 'strict', secure: 'true' }); Cookies.set('group', $('#newCurrentGroup').val(), { expires: 365, path: '/app', samesite: 'strict', secure: 'true' });
$.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(); location.reload();
} }
}
} );
}
function sort_by_status() { function sort_by_status() {
$('<div id="err_services" style="clear: both;"></div>').appendTo('.main'); $('<div id="err_services" style="clear: both;"></div>').appendTo('.main');
$('<div id="good_services" style="clear: both;"></div>').appendTo('.main'); $('<div id="good_services" style="clear: both;"></div>').appendTo('.main');

View File

@ -805,6 +805,9 @@ label {
height: 80px; height: 80px;
width: 390px; width: 390px;
} }
.add_proxy {
width: 380px;
}
.server-act-links { .server-act-links {
margin-left: -2px; margin-left: -2px;
} }