mirror of https://github.com/Aidaho12/haproxy-wi
parent
bcdd41bcd5
commit
57db17c86b
|
@ -317,12 +317,12 @@ def list_of_lists(serv) -> str:
|
||||||
return '------'
|
return '------'
|
||||||
|
|
||||||
|
|
||||||
def show_lists(serv, list_id, list_name) -> None:
|
def show_lists(serv, list_id, color, list_name) -> None:
|
||||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||||
cmd = f'echo "show acl #{list_id}"|nc {serv} {haproxy_sock_port}'
|
cmd = f'echo "show acl #{list_id}"|nc {serv} {haproxy_sock_port}'
|
||||||
output, stderr = server_mod.subprocess_execute(cmd)
|
output, stderr = server_mod.subprocess_execute(cmd)
|
||||||
|
|
||||||
return render_template('ajax/list.html', list=output, list_id=list_id, list_name=list_name)
|
return render_template('ajax/list.html', list=output, list_id=list_id, color=color, list_name=list_name)
|
||||||
|
|
||||||
|
|
||||||
def delete_ip_from_list(serv, ip_id, ip, list_id, list_name) -> str:
|
def delete_ip_from_list(serv, ip_id, ip, list_id, list_name) -> str:
|
||||||
|
@ -377,12 +377,14 @@ def add_ip_to_list(serv, ip, list_id, list_name) -> str:
|
||||||
|
|
||||||
if 'is not a valid IPv4 or IPv6 address' not in output[0]:
|
if 'is not a valid IPv4 or IPv6 address' not in output[0]:
|
||||||
cmd = f'echo "{ip}" >> {lib_path}/lists/{user_group}/{list_name}'
|
cmd = f'echo "{ip}" >> {lib_path}/lists/{user_group}/{list_name}'
|
||||||
|
print(cmd)
|
||||||
output, stderr = server_mod.subprocess_execute(cmd)
|
output, stderr = server_mod.subprocess_execute(cmd)
|
||||||
roxywi_common.logging(serv, f'{ip} has been added to list {list_id}', login=1, keep_history=1, service='haproxy')
|
roxywi_common.logging(serv, f'{ip} has been added to list {list_id}', login=1, keep_history=1, service='haproxy')
|
||||||
if output:
|
if output:
|
||||||
return f'error: {output}'
|
return f'error: {output}'
|
||||||
if stderr:
|
if stderr:
|
||||||
return f'error: {stderr}'
|
return f'error: {stderr}'
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
|
|
||||||
def select_session(server_ip: str) -> str:
|
def select_session(server_ip: str) -> str:
|
||||||
|
|
|
@ -222,13 +222,14 @@ def get_lists(server_ip):
|
||||||
return f'{e}'
|
return f'{e}'
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/list/<server_ip>/<int:list_id>/<list_name>')
|
@bp.route('/list/<server_ip>/<int:list_id>/<color>/<list_name>')
|
||||||
def get_list(server_ip, list_id, list_name):
|
def get_list(server_ip, list_id, color, list_name):
|
||||||
server_ip = common.is_ip_or_dns(server_ip)
|
server_ip = common.is_ip_or_dns(server_ip)
|
||||||
list_name = common.checkAjaxInput(list_name)
|
list_name = common.checkAjaxInput(list_name)
|
||||||
|
color = common.checkAjaxInput(color)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return runtime.show_lists(server_ip, list_id, list_name)
|
return runtime.show_lists(server_ip, list_id, color, list_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f'{e}'
|
return f'{e}'
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
List name: {{list_name}}
|
List name: {{list_name}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button title="Add IP in this list" id="list_add_ip" data-list-id="{{list_id}}" data-list-name="{{list_name}}">Add IP</button>
|
<button title="Add IP in this list" id="list_add_ip" data-list-id="{{list_id}}" data-list-name="{{color}}/{{list_name}}">Add IP</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -266,8 +266,11 @@ function getTable() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getList() {
|
function getList() {
|
||||||
|
let color = $('#list_select option:selected').text().split('/')[0];
|
||||||
|
let list_name = $('#list_select option:selected').text().split('/')[1];
|
||||||
|
console.log(list_name)
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/app/runtimeapi/list/" + $('#list_serv_select').val() + "/" + $('#list_select').val() + "/" + $('#list_select option:selected').text(),
|
url: "/app/runtimeapi/list/" + $('#list_serv_select').val() + "/" + $('#list_select').val() + "/" + color + "/" + list_name,
|
||||||
// data: {
|
// data: {
|
||||||
// token: $('#token').val()
|
// token: $('#token').val()
|
||||||
// },
|
// },
|
||||||
|
@ -319,7 +322,7 @@ function addNewIp() {
|
||||||
var ip = $('#list_add_ip_new_ip').val();
|
var ip = $('#list_add_ip_new_ip').val();
|
||||||
if (valid) {
|
if (valid) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/app/runtimeapi/list/add/",
|
url: "/app/runtimeapi/list/add",
|
||||||
data: {
|
data: {
|
||||||
serv: $('#list_serv_select').val(),
|
serv: $('#list_serv_select').val(),
|
||||||
list_ip_for_add: ip,
|
list_ip_for_add: ip,
|
||||||
|
|
Loading…
Reference in New Issue