mirror of https://github.com/Aidaho12/haproxy-wi
parent
bcdd41bcd5
commit
57db17c86b
|
@ -317,12 +317,12 @@ def list_of_lists(serv) -> str:
|
|||
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')
|
||||
cmd = f'echo "show acl #{list_id}"|nc {serv} {haproxy_sock_port}'
|
||||
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:
|
||||
|
@ -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]:
|
||||
cmd = f'echo "{ip}" >> {lib_path}/lists/{user_group}/{list_name}'
|
||||
print(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')
|
||||
if output:
|
||||
return f'error: {output}'
|
||||
if stderr:
|
||||
return f'error: {stderr}'
|
||||
return 'ok'
|
||||
|
||||
|
||||
def select_session(server_ip: str) -> str:
|
||||
|
|
|
@ -222,13 +222,14 @@ def get_lists(server_ip):
|
|||
return f'{e}'
|
||||
|
||||
|
||||
@bp.route('/list/<server_ip>/<int:list_id>/<list_name>')
|
||||
def get_list(server_ip, list_id, list_name):
|
||||
@bp.route('/list/<server_ip>/<int:list_id>/<color>/<list_name>')
|
||||
def get_list(server_ip, list_id, color, list_name):
|
||||
server_ip = common.is_ip_or_dns(server_ip)
|
||||
list_name = common.checkAjaxInput(list_name)
|
||||
color = common.checkAjaxInput(color)
|
||||
|
||||
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:
|
||||
return f'{e}'
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
List name: {{list_name}}
|
||||
</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>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -266,8 +266,11 @@ function getTable() {
|
|||
});
|
||||
}
|
||||
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({
|
||||
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: {
|
||||
// token: $('#token').val()
|
||||
// },
|
||||
|
@ -319,7 +322,7 @@ function addNewIp() {
|
|||
var ip = $('#list_add_ip_new_ip').val();
|
||||
if (valid) {
|
||||
$.ajax({
|
||||
url: "/app/runtimeapi/list/add/",
|
||||
url: "/app/runtimeapi/list/add",
|
||||
data: {
|
||||
serv: $('#list_serv_select').val(),
|
||||
list_ip_for_add: ip,
|
||||
|
|
Loading…
Reference in New Issue