mirror of https://github.com/Aidaho12/haproxy-wi
parent
c106b6ffcc
commit
d92856067a
|
@ -181,7 +181,7 @@ def update_db_v_31(**kwargs):
|
|||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('server_state_file', '/etc/haproxy/haproxy.state', 'haproxy', 'Path to HAProxy state file');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock', '/var/run/haproxy.sock', 'haproxy', 'Path to HAProxy sock file');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock_port', '1999', 'haproxy', 'HAProxy sock port');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('firewall_enable', '0', 'haproxy', 'If enable this option Haproxy-wi will be configure firewalld based on config port');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('firewall_enable', '0', 'main', 'If enable this option Haproxy-wi will be configure firewalld based on config port');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('apache_log_path', '/var/log/httpd/', 'logs', 'Path to Apache logs');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_enable', '0', 'ldap', 'If 1 ldap enabled');")
|
||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_server', '', 'ldap', 'IP address ldap server');")
|
||||
|
|
|
@ -1223,25 +1223,30 @@ if form.getvalue('bwlists_save'):
|
|||
except IOError as e:
|
||||
print('<div class="alert alert-danger" style="margin-left:14px">Cat\'n save '+color+' list. %s </div>' % e)
|
||||
|
||||
servers = sql.get_dick_permit()
|
||||
path = sql.get_setting('haproxy_dir')+"/"+color
|
||||
servers = []
|
||||
servers.append(serv)
|
||||
|
||||
for server in servers:
|
||||
funct.ssh_command(server[2], ["sudo mkdir "+path])
|
||||
funct.ssh_command(server[2], ["sudo chown $(whoami) "+path])
|
||||
error = funct.upload(server[2], path+"/"+bwlists_save, list, dir='fullpath')
|
||||
MASTERS = sql.is_master(serv)
|
||||
for master in MASTERS:
|
||||
if master[0] != None:
|
||||
servers.append(master[0])
|
||||
for serv in servers:
|
||||
funct.ssh_command(serv, ["sudo mkdir "+path])
|
||||
funct.ssh_command(serv, ["sudo chown $(whoami) "+path])
|
||||
error = funct.upload(serv, path+"/"+bwlists_save, list, dir='fullpath')
|
||||
if error:
|
||||
print('<div class="alert alert-danger">Upload fail: %s</div>' % error)
|
||||
else:
|
||||
print('<div class="alert alert-success" style="margin:10px; margin-left:14px">Edited '+color+' list was uploaded to '+server[1]+'</div>')
|
||||
print('<div class="alert alert-success" style="margin:10px; margin-left:14px">Edited '+color+' list was uploaded to '+serv+'</div>')
|
||||
try:
|
||||
funct.logging(server[1], 'has edited '+color+' list '+bwlists_save, haproxywi=1, login=1)
|
||||
funct.logging(serv, 'has edited '+color+' list '+bwlists_save, haproxywi=1, login=1)
|
||||
except:
|
||||
pass
|
||||
if form.getvalue('bwlists_restart') == 'restart':
|
||||
funct.ssh_command(server[2], ["sudo systemctl restart haproxy"])
|
||||
funct.ssh_command(serv, ["sudo systemctl restart haproxy"])
|
||||
elif form.getvalue('bwlists_restart') == 'reload':
|
||||
funct.ssh_command(server[2], ["sudo systemctl reload haproxy"])
|
||||
funct.ssh_command(serv, ["sudo systemctl reload haproxy"])
|
||||
|
||||
|
||||
if form.getvalue('get_lists'):
|
||||
|
|
|
@ -750,13 +750,20 @@ h3 {
|
|||
<div id="lists">
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">New black list</th>
|
||||
<td>Exists black lists</th>
|
||||
<td class="padding10 first-collumn">New white list</th>
|
||||
<td>Exists white lists</th>
|
||||
<th class="padding10 first-collumn">Server for upload</th>
|
||||
<th>New black list</th>
|
||||
<th>Exists black lists</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
<td class="padding10 first-collumn">
|
||||
<select required name="serv-black-list" id="serv-black-list">
|
||||
<option disabled selected>Choose server</option>
|
||||
{% for select in selects %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 25%;">
|
||||
Name: {{ input('new_blacklist_name') }}
|
||||
<button onclick="createList('black')">Create</button>
|
||||
</td>
|
||||
|
@ -765,7 +772,26 @@ h3 {
|
|||
<a onclick="editList('{{ list }}', 'black')" style="cursor: pointer;" title="Edit list {{ list }}">{{ list }}</a>
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td class="padding10 first-collumn" style="width: 25%;">
|
||||
|
||||
</tr>
|
||||
{{ input('group', value=group, type='hidden') }}
|
||||
</table>
|
||||
<table>
|
||||
<tr class="overviewHead">
|
||||
<th class="padding10 first-collumn">Server for upload</th>
|
||||
<th>New white list</th>
|
||||
<th>Exists white lists</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn">
|
||||
<select required name="serv-white-list" id="serv-white-list">
|
||||
<option disabled selected>Choose server</option>
|
||||
{% for select in selects %}
|
||||
<option value="{{ select.2 }}">{{ select.1 }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 25%;">
|
||||
Name: {{ input('new_whitelist_name') }}
|
||||
<button onclick="createList( 'white')">Create</button>
|
||||
</td>
|
||||
|
@ -775,12 +801,11 @@ h3 {
|
|||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
{{ input('group', value=group, type='hidden') }}
|
||||
</table>
|
||||
<div id="ajax"></div>
|
||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||
In this section you can create and edit black and white lists. And after use them in the HAProxy configs or in the "Add proxy" pages
|
||||
</div>
|
||||
<div id="ajax"></div>
|
||||
<div id="dialog-confirm-cert-edit" title="View certificate " style="display: none;">
|
||||
<span><b>Note:</b> Each new address must be specified from a new line</span>
|
||||
<textarea id="edit_lists" style="width: 100%" rows=20></textarea>
|
||||
|
|
|
@ -74,7 +74,7 @@ def main(serv, port):
|
|||
servername = servername.split(",")
|
||||
realserver = servername[0]
|
||||
server = servername[1]
|
||||
alert = "Backend: "+realserver[2:]+", server: "+server+" has changed status and is now "+ currentstat[i] + " at " + serv
|
||||
alert = "Backend: "+realserver[2:]+", server: "+server+" has changed status to "+ currentstat[i] + " at " + serv
|
||||
funct.telegram_send_mess(str(alert), ip=serv)
|
||||
funct.logging("localhost", " "+alert, alerting=1)
|
||||
firstrun = False
|
||||
|
|
|
@ -1212,6 +1212,7 @@ function saveList(action, list, color) {
|
|||
url: "options.py",
|
||||
data: {
|
||||
bwlists_save: list,
|
||||
serv: $( "#serv-"+color+"-list option:selected" ).val(),
|
||||
bwlists_content: $('#edit_lists').val(),
|
||||
color: color,
|
||||
group: $('#group').val(),
|
||||
|
|
Loading…
Reference in New Issue