v6.3.17.0

Changelog: https://roxy-wi.org/changelog#6_3_17
pull/364/head
Aidaho 2023-08-03 09:56:25 +03:00
parent e5807d62c2
commit af228c236e
24 changed files with 592 additions and 358 deletions

View File

@ -45,9 +45,9 @@ if all(v is None for v in [
print(str(e))
lib_path = get_config_var.get_config_var('main', 'lib_path')
dir = lib_path + "/" + sql.get_setting('lists_path')
white_dir = lib_path + "/" + sql.get_setting('lists_path') + "/" + user_group + "/white"
black_dir = lib_path + "/" + sql.get_setting('lists_path') + "/" + user_group + "/black"
dir = lib_path + "/lists"
white_dir = lib_path + "/lists/" + user_group + "/white"
black_dir = lib_path + "/lists/" + user_group + "/black"
if not os.path.exists(dir):
os.makedirs(dir)
@ -60,12 +60,13 @@ if all(v is None for v in [
white_lists = roxywi_common.get_files(folder=white_dir, file_format="lst")
black_lists = roxywi_common.get_files(folder=black_dir, file_format="lst")
maps = roxywi_common.get_files(folder=f'{lib_path}/maps/{user_group}', file_format="map")
template = template.render(
h2=1, role=user_params['role'], user=user_params['user'], selects=user_params['servers'], add=form.getvalue('add'),
conf_add=form.getvalue('conf'), group=user_group, options=sql.select_options(), saved_servers=sql.select_saved_servers(),
white_lists=white_lists, black_lists=black_lists, user_services=user_params['user_services'], token=user_params['token'],
lang=user_params['lang']
lang=user_params['lang'], maps=maps
)
print(template)

View File

@ -22,9 +22,6 @@ def default_values():
{'param': 'ssl_local_path', 'value': 'certs', 'section': 'main',
'desc': 'Path to the directory with the saved local SSL certificates. The value of this parameter is '
'specified as a relative path beginning with $HOME_ROXY_WI/app/', 'group': '1'},
{'param': 'lists_path', 'value': 'lists', 'section': 'main',
'desc': 'Path to the black and the wild list. The value of this parameter should be specified as a relative path beginning with $HOME_ROXY-WI',
'group': '1'},
{'param': 'maxmind_key', 'value': '', 'section': 'main', 'desc': 'License key for downloading GeoIP DB. You can create it on maxmind.com', 'group': '1'},
{'param': 'haproxy_path_logs', 'value': '/var/log/haproxy/', 'section': 'haproxy', 'desc': 'The path for HAProxy logs', 'group': '1'},
{'param': 'syslog_server_enable', 'value': '0', 'section': 'logs', 'desc': 'Enable getting logs from a syslog server', 'group': '1'},
@ -633,85 +630,6 @@ def update_db_v_4_3_0():
print("An error occurred:", e)
def update_db_v_6_0():
cursor = conn.cursor()
sql = list()
sql.append("alter table servers add column apache integer default 0")
sql.append("alter table servers add column apache_active integer default 0")
sql.append("alter table servers add column apache_alert integer default 0")
sql.append("alter table servers add column apache_metrics integer default 0")
for i in sql:
try:
cursor.execute(i)
except Exception:
pass
else:
print('Updating... DB has been updated to version 6.0.0.0')
def update_db_v_6_0_1():
query = Groups.update(name='Default').where(Groups.group_id == '1')
try:
query.execute()
except Exception as e:
print("An error occurred:", e)
else:
print("Updating... DB has been updated to version 6.0.0.0-1")
def update_db_v_6_1_0():
for service_id in range(1, 5):
try:
servers_id = Server.select(Server.server_id).where(Server.type_ip == 0).execute()
for server_id in servers_id:
CheckerSetting.insert(
server_id=server_id, service_id=service_id
).on_conflict_ignore().execute()
except Exception as e:
if e.args[0] == 'duplicate column name: haproxy' or str(e) == '(1060, "Duplicate column name \'haproxy\'")':
print('Updating... go to version 6.1.0')
else:
print("An error occurred:", e)
def update_db_v_6_1_3():
if mysql_enable == '1':
cursor = conn.cursor()
sql = list()
sql.append("ALTER TABLE `waf_rules` ADD COLUMN service VARCHAR ( 64 ) DEFAULT 'haproxy'")
sql.append("ALTER TABLE `waf_rules` drop CONSTRAINT serv")
sql.append("ALTER TABLE `waf_rules` ADD CONSTRAINT UNIQUE (serv, rule_name, service)")
for i in sql:
try:
cursor.execute(i)
except Exception:
pass
else:
print('Updating... DB has been updated to version 6.1.3.0')
else:
pass
def update_db_v_6_1_4():
servers = Server.select()
services = Services.select()
for server in servers:
for service in services:
settings = ('restart', 'dockerized', 'haproxy_enterprise')
for setting in settings:
if service.slug == 'keepalived':
continue
if service.slug != 'haproxy' and setting == 'haproxy_enterprise':
continue
set_value = 0
try:
ServiceSetting.insert(
server_id=server.server_id, service=service.slug, setting=setting, value=set_value
).on_conflict_ignore().execute()
except Exception:
pass
def update_db_v_6_2_1():
try:
Setting.update(section='main').where(Setting.param == 'maxmind_key').execute()
@ -914,9 +832,18 @@ def update_db_v_6_3_13_5():
print("An error occurred:", e)
def update_db_v_6_3_17():
try:
Setting.delete().where(Setting.param == 'lists_path').execute()
except Exception as e:
print("An error occurred:", e)
else:
print("Updating... DB has been updated to version 6.3.17")
def update_ver():
try:
Version.update(version='6.3.16.0').execute()
Version.update(version='6.3.17.0').execute()
except Exception:
print('Cannot update version')
@ -934,11 +861,6 @@ def update_all():
if check_ver() is None:
update_db_v_3_4_5_22()
update_db_v_4_3_0()
update_db_v_6_0()
update_db_v_6_0_1()
update_db_v_6_1_0()
update_db_v_6_1_3()
update_db_v_6_1_4()
update_db_v_6_2_1()
update_db_v_6_3_4()
update_db_v_6_3_5()
@ -953,6 +875,7 @@ def update_all():
update_db_v_6_3_13_3()
update_db_v_6_3_13_4()
update_db_v_6_3_13_5()
update_db_v_6_3_17()
update_ver()

View File

@ -52,7 +52,7 @@ def show_userlist(server_ip: str) -> None:
def get_bwlist(color: str, group: str, list_name: str) -> None:
lib_path = get_config.get_config_var('main', 'lib_path')
list_path = f"{lib_path}/{sql.get_setting('lists_path')}/{group}/{color}/{list_name}"
list_path = f"{lib_path}/lists/{group}/{color}/{list_name}"
try:
with open(list_path, 'r') as f:
@ -63,7 +63,7 @@ def get_bwlist(color: str, group: str, list_name: str) -> None:
def get_bwlists_for_autocomplete(color: str, group: str) -> None:
lib_path = get_config.get_config_var('main', 'lib_path')
list_path = f"{lib_path}/{sql.get_setting('lists_path')}/{group}/{color}"
list_path = f"{lib_path}/lists/{group}/{color}"
lists = roxywi_common.get_files(list_path, "lst")
for line in lists:
@ -73,7 +73,7 @@ def get_bwlists_for_autocomplete(color: str, group: str) -> None:
def create_bwlist(server_ip: str, list_name: str, color: str, group: str) -> None:
lib_path = get_config.get_config_var('main', 'lib_path')
list_name = f"{list_name.split('.')[0]}.lst"
list_path = f"{lib_path}/{sql.get_setting('lists_path')}/{group}/{color}/{list_name}"
list_path = f"{lib_path}/lists/{group}/{color}/{list_name}"
try:
open(list_path, 'a').close()
print('success: ')
@ -87,7 +87,7 @@ def create_bwlist(server_ip: str, list_name: str, color: str, group: str) -> Non
def save_bwlist(list_name: str, list_con: str, color: str, group: str, server_ip: str, action: str) -> None:
lib_path = get_config.get_config_var('main', 'lib_path')
list_path = f"{lib_path}/{sql.get_setting('lists_path')}/{group}/{color}/{list_name}"
list_path = f"{lib_path}/lists/{group}/{color}/{list_name}"
try:
with open(list_path, "w") as file:
file.write(list_con)
@ -139,7 +139,7 @@ def save_bwlist(list_name: str, list_con: str, color: str, group: str, server_ip
def delete_bwlist(list_name: str, color: str, group: str, server_ip: str) -> None:
servers = []
lib_path = get_config.get_config_var('main', 'lib_path')
list_path = f"{lib_path}/{sql.get_setting('lists_path')}/{group}/{color}/{list_name}"
list_path = f"{lib_path}/lists/{group}/{color}/{list_name}"
path = f"{sql.get_setting('haproxy_dir')}/{color}"
try:
@ -172,6 +172,125 @@ def delete_bwlist(list_name: str, color: str, group: str, server_ip: str) -> Non
pass
def edit_map(map_name: str, group: str) -> None:
lib_path = get_config.get_config_var('main', 'lib_path')
list_path = f"{lib_path}/maps/{group}/{map_name}"
try:
with open(list_path, 'r') as f:
print(f.read())
except IOError as e:
print(f"error: Cannot read {map_name} list: {e}")
def create_map(server_ip: str, map_name: str, group: str) -> None:
lib_path = get_config.get_config_var('main', 'lib_path')
map_name = f"{map_name.split('.')[0]}.map"
map_path = f'{lib_path}/maps/{group}/'
full_path = f'{map_path}/{map_name}'
try:
server_mod.subprocess_execute(f'mkdir -p {map_path}')
except Exception as e:
assert Exception(f'error: cannot create a local folder for maps: {e}')
try:
open(full_path, 'a').close()
print('success: ')
try:
roxywi_common.logging(server_ip, f'A new map {map_name} has been created', roxywi=1, login=1)
except Exception:
pass
except IOError as e:
assert Exception(f'error: Cannot create a new {map_name} map. {e}, ')
def save_map(map_name: str, list_con: str, group: str, server_ip: str, action: str) -> None:
lib_path = get_config.get_config_var('main', 'lib_path')
map_path = f"{lib_path}/maps/{group}/{map_name}"
try:
with open(map_path, "w") as file:
file.write(list_con)
except IOError as e:
print(f'error: Cannot save {map_name} list. {e}')
path = sql.get_setting('haproxy_dir') + "/maps"
servers = []
if server_ip != 'all':
servers.append(server_ip)
masters = sql.is_master(server_ip)
for master in masters:
if master[0] is not None:
servers.append(master[0])
else:
server = roxywi_common.get_dick_permit()
for s in server:
servers.append(s[2])
for serv in servers:
server_mod.ssh_command(serv, [f"sudo mkdir {path}"])
server_mod.ssh_command(serv, [f"sudo chown $(whoami) {path}"])
error = config_mod.upload(serv, f'{path}/{map_name}', map_path, dir='fullpath')
if error:
print(f'error: Upload fail: {error} , ')
else:
print(f'success: Edited {map_name} map was uploaded to {serv} , ')
try:
roxywi_common.logging(serv, f'Has been edited the map {map_name}', roxywi=1, login=1)
except Exception:
pass
server_id = sql.select_server_id_by_ip(server_ip=serv)
haproxy_enterprise = sql.select_service_setting(server_id, 'haproxy', 'haproxy_enterprise')
if haproxy_enterprise == '1':
haproxy_service_name = "hapee-2.0-lb"
else:
haproxy_service_name = "haproxy"
if action == 'restart':
server_mod.ssh_command(serv, [f"sudo systemctl restart {haproxy_service_name}"])
elif action == 'reload':
server_mod.ssh_command(serv, [f"sudo systemctl reload {haproxy_service_name}"])
def delete_map(map_name: str, group: str, server_ip: str) -> None:
servers = []
lib_path = get_config.get_config_var('main', 'lib_path')
list_path = f"{lib_path}/maps/{group}/{map_name}"
path = f"{sql.get_setting('haproxy_dir')}/maps"
try:
os.remove(list_path)
except IOError as e:
print(f'error: Cannot delete {map_name} map from Roxy-WI server. {e} , ')
if server_ip != 'all':
servers.append(server_ip)
masters = sql.is_master(server_ip)
for master in masters:
if master[0] is not None:
servers.append(master[0])
else:
server = roxywi_common.get_dick_permit()
for s in server:
servers.append(s[2])
for serv in servers:
error = server_mod.ssh_command(serv, [f"sudo rm {path}/{map_name}"], return_err=1)
if error:
print(f'error: Deleting fail: {error} , ')
else:
print(f'success: the {map_name} map has been deleted on {serv} , ')
try:
roxywi_common.logging(serv, f'has been deleted the {map_name} map', roxywi=1, login=1)
except Exception:
pass
def create_saved_option(option: str, group: int) -> None:
if sql.insert_new_option(option, group):
from jinja2 import Environment, FileSystemLoader

View File

@ -349,15 +349,14 @@ def show_lists() -> None:
def delete_ip_from_list() -> None:
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
lists_path = sql.get_setting('lists_path')
lib_path = get_config_var.get_config_var('main', 'lib_path')
ip_id = common.checkAjaxInput(form.getvalue('list_ip_id_for_delete'))
ip = common.is_ip_or_dns(form.getvalue('list_ip_for_delete'))
list_id = common.checkAjaxInput(form.getvalue('list_id_for_delete'))
list_name = common.checkAjaxInput(form.getvalue('list_name'))
user_group = roxywi_common.get_user_group(id=1)
cmd = f"sed -i 's!{ip}$!!' {lib_path}/{lists_path}/{user_group}/{list_name}"
cmd1 = f"sed -i '/^$/d' {lib_path}/{lists_path}/{user_group}/{list_name}"
cmd = f"sed -i 's!{ip}$!!' {lib_path}/lists/{user_group}/{list_name}"
cmd1 = f"sed -i '/^$/d' {lib_path}/lists/{user_group}/{list_name}"
output, stderr = server_mod.subprocess_execute(cmd)
output1, stderr1 = server_mod.subprocess_execute(cmd1)
if output:
@ -381,7 +380,6 @@ def delete_ip_from_list() -> None:
def add_ip_to_list() -> None:
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
lists_path = sql.get_setting('lists_path')
lib_path = get_config_var.get_config_var('main', 'lib_path')
ip = form.getvalue('list_ip_for_add')
ip = ip.strip()
@ -397,7 +395,7 @@ def add_ip_to_list() -> None:
print(f'error: {stderr[0]}')
if 'is not a valid IPv4 or IPv6 address' not in output[0]:
cmd = f'echo "{ip}" >> {lib_path}/{lists_path}/{user_group}/{list_name}'
cmd = f'echo "{ip}" >> {lib_path}/lists/{user_group}/{list_name}'
output, stderr = server_mod.subprocess_execute(cmd)
if output:
print(f'error: {output}')

View File

@ -26,7 +26,7 @@ def get_setting(param, **kwargs):
except Exception:
pass
if user_group == '' or param in ('lists_path', 'ssl_local_path', 'proxy'):
if user_group == '' or param in ('ssl_local_path', 'proxy'):
user_group = 1
if kwargs.get('all'):

View File

@ -55,12 +55,12 @@ def show_log(stdout, **kwargs):
def show_roxy_log(
serv, rows='10', waf='0', grep=None, hour='00',
minut='00', hour1='24', minut1='00', service='haproxy', **kwargs
minute='00', hour1='24', minute1='00', service='haproxy', **kwargs
) -> str:
exgrep = form.getvalue('exgrep')
log_file = form.getvalue('file')
date = checkAjaxInput(hour) + ':' + checkAjaxInput(minut)
date1 = checkAjaxInput(hour1) + ':' + checkAjaxInput(minut1)
date = checkAjaxInput(hour) + ':' + checkAjaxInput(minute)
date1 = checkAjaxInput(hour1) + ':' + checkAjaxInput(minute1)
rows = checkAjaxInput(rows)
waf = checkAjaxInput(waf)
cmd = ''

View File

@ -21,6 +21,17 @@ def is_docker() -> bool:
def update_roxy_wi(service):
restart_service = ''
services = ['roxy-wi-checker',
'roxy-wi',
'roxy-wi-keep_alive',
'roxy-wi-smon',
'roxy-wi-metrics',
'roxy-wi-portscanner',
'roxy-wi-socket',
'roxy-wi-prometheus-exporter']
if service not in services:
raise Exception(f'error: {service} is not part of Roxy-WI')
if distro.id() == 'ubuntu':
try:

View File

@ -49,6 +49,9 @@ def install_haproxy(server_ip: str, api=0, **kwargs):
haproxy_ver = kwargs.get('hapver')
server_for_installing = kwargs.get('server')
docker = kwargs.get('docker')
m_or_s = kwargs.get('m_or_s')
master = kwargs.get('master')
slave = kwargs.get('slave')
proxy_serv = ''
ssh_settings = return_ssh_keys_path(server_ip)
full_path = '/var/www/haproxy-wi/app'
@ -68,7 +71,7 @@ def install_haproxy(server_ip: str, api=0, **kwargs):
f"STAT_FILE={server_state_file} DOCKER={docker} SSH_PORT={ssh_settings['port']} STATS_USER={stats_user} "
f"CONT_NAME={container_name} HAP_DIR={haproxy_dir} STATS_PASS='{stats_password}' HAPVER={haproxy_ver} "
f"SYN_FLOOD={syn_flood_protect} HOST={server_ip} USER={ssh_settings['user']} PASS='{ssh_settings['password']}' "
f"KEY={ssh_settings['key']}"
f"M_OR_S={m_or_s} MASTER={master} SLAVE={slave} KEY={ssh_settings['key']}"
]
if server_for_installing:

View File

@ -0,0 +1,60 @@
from jinja2 import Environment, FileSystemLoader
import modules.db.sql as sql
import modules.roxywi.common as roxywi_common
import modules.roxywi.roxy as roxywi_mod
def load_checker(page: str) -> None:
groups = sql.select_groups()
services = roxywi_mod.get_services_status()
lang = roxywi_common.get_user_lang()
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
template = env.get_template('ajax/load_telegram.html')
keepalived_settings = ''
haproxy_settings = ''
apache_settings = ''
nginx_settings = ''
keepalived_servers = ''
haproxy_servers = ''
apache_servers = ''
nginx_servers = ''
telegrams = ''
slacks = ''
pds = ''
try:
user_subscription = roxywi_common.return_user_status()
except Exception as e:
user_subscription = roxywi_common.return_unsubscribed_user_status()
roxywi_common.logging('Roxy-WI server', f'Cannot get a user plan: {e}', roxywi=1)
if user_subscription['user_status']:
haproxy_settings = sql.select_checker_settings(1)
nginx_settings = sql.select_checker_settings(2)
keepalived_settings = sql.select_checker_settings(3)
apache_settings = sql.select_checker_settings(4)
if page == 'servers.py':
user_group = roxywi_common.get_user_group(id=1)
telegrams = sql.get_user_telegram_by_group(user_group)
slacks = sql.get_user_slack_by_group(user_group)
pds = sql.get_user_pd_by_group(user_group)
haproxy_servers = roxywi_common.get_dick_permit(haproxy=1, only_group=1)
nginx_servers = roxywi_common.get_dick_permit(nginx=1, only_group=1)
apache_servers = roxywi_common.get_dick_permit(apache=1, only_group=1)
keepalived_servers = roxywi_common.get_dick_permit(keepalived=1, only_group=1)
else:
telegrams = sql.select_telegram()
slacks = sql.select_slack()
pds = sql.select_pd()
haproxy_servers = roxywi_common.get_dick_permit(haproxy=1)
nginx_servers = roxywi_common.get_dick_permit(nginx=1)
apache_servers = roxywi_common.get_dick_permit(apache=1)
keepalived_servers = roxywi_common.get_dick_permit(keepalived=1)
template = template.render(services=services, telegrams=telegrams, pds=pds, groups=groups, slacks=slacks,
user_status=user_subscription['user_status'], user_plan=user_subscription['user_plan'],
haproxy_servers=haproxy_servers, nginx_servers=nginx_servers, apache_servers=apache_servers,
keepalived_servers=keepalived_servers, haproxy_settings=haproxy_settings, nginx_settings=nginx_settings,
keepalived_settings=keepalived_settings, apache_settings=apache_settings, page=page, lang=lang)
print(template)

View File

@ -276,46 +276,32 @@ if form.getvalue('action'):
if serv is not None and act == "stats":
service_common.get_stat_page(serv, service)
if serv is not None and form.getvalue('show_log') is not None:
if serv is not None and any((form.getvalue('show_log'), form.getvalue('rows1'), form.getvalue('viewlogs'))):
import modules.roxywi.logs as roxywi_logs
waf = 0
rows = form.getvalue('show_log')
waf = form.getvalue('waf')
service = service
if form.getvalue('rows1'):
rows = form.getvalue('rows1')
service = 'apache_internal'
elif form.getvalue('show_log'):
waf = form.getvalue('waf')
elif form.getvalue('viewlogs'):
serv = form.getvalue('viewlogs')
rows = form.getvalue('rows')
service = 'internal'
grep = form.getvalue('grep')
hour = form.getvalue('hour')
minut = form.getvalue('minut')
minute = form.getvalue('minut')
hour1 = form.getvalue('hour1')
minut1 = form.getvalue('minut1')
out = roxywi_logs.show_roxy_log(serv, rows=rows, waf=waf, grep=grep, hour=hour, minut=minut, hour1=hour1,
minut1=minut1, service=service)
print(out)
minute1 = form.getvalue('minut1')
if serv is not None and form.getvalue('rows1') is not None:
import modules.roxywi.logs as roxywi_logs
rows = form.getvalue('rows1')
grep = form.getvalue('grep')
hour = form.getvalue('hour')
minut = form.getvalue('minut')
hour1 = form.getvalue('hour1')
minut1 = form.getvalue('minut1')
out = roxywi_logs.show_roxy_log(serv, rows=rows, waf='0', grep=grep, hour=hour, minut=minut, hour1=hour1,
minut1=minut1, service='apache_internal')
print(out)
if form.getvalue('viewlogs') is not None:
import modules.roxywi.logs as roxywi_logs
viewlog = form.getvalue('viewlogs')
rows = form.getvalue('rows')
grep = form.getvalue('grep')
hour = form.getvalue('hour')
minut = form.getvalue('minut')
hour1 = form.getvalue('hour1')
minut1 = form.getvalue('minut1')
if roxywi_common.check_user_group():
out = roxywi_logs.show_roxy_log(serv=viewlog, rows=rows, waf='0', grep=grep, hour=hour, minut=minut, hour1=hour1,
minut1=minut1, service='internal')
out = roxywi_logs.show_roxy_log(serv=serv, rows=rows, waf=waf, grep=grep, hour=hour, minute=minute, hour1=hour1,
minute1=minute1, service=service)
print(out)
if serv is not None and act == "showMap":
@ -407,12 +393,12 @@ if form.getvalue('master_slave_hap'):
if server == 'master':
try:
service_mod.install_haproxy(master, server=server, docker=docker)
service_mod.install_haproxy(master, server=server, docker=docker, m_or_s='master', master=master, slave=slave)
except Exception as e:
print(f'{e}')
elif server == 'slave':
try:
service_mod.install_haproxy(slave, server=server, docker=docker)
service_mod.install_haproxy(slave, server=server, docker=docker, m_or_s='slave', master=master, slave=slave)
except Exception as e:
print(f'{e}')
@ -586,18 +572,12 @@ if form.getvalue('geoip_install'):
if form.getvalue('update_roxy_wi'):
import modules.roxywi.roxy as roxy
services = ['roxy-wi-checker',
'roxy-wi',
'roxy-wi-keep_alive',
'roxy-wi-smon',
'roxy-wi-metrics',
'roxy-wi-portscanner',
'roxy-wi-socket',
'roxy-wi-prometheus-exporter']
if service not in services:
print(f'error: {service} is not part of Roxy-WI')
sys.exit()
roxy.update_roxy_wi(service)
service = form.getvalue('service')
try:
roxy.update_roxy_wi(service)
except Exception as e:
print(e)
if form.getvalue('metrics_waf'):
metrics_waf = common.checkAjaxInput(form.getvalue('metrics_waf'))
@ -717,6 +697,36 @@ if form.getvalue('get_lists'):
color = common.checkAjaxInput(form.getvalue('color'))
add_mod.get_bwlists_for_autocomplete(color, group)
if form.getvalue('edit_map'):
group = common.checkAjaxInput(form.getvalue('group'))
map_name = common.checkAjaxInput(form.getvalue('edit_map'))
add_mod.edit_map(map_name, group)
if form.getvalue('map_create'):
map_name = common.checkAjaxInput(form.getvalue('map_create'))
group = common.checkAjaxInput(form.getvalue('group'))
try:
add_mod.create_map(serv, map_name, group)
except Exception as e:
print(e)
if form.getvalue('map_save'):
group = common.checkAjaxInput(form.getvalue('group'))
map_save = common.checkAjaxInput(form.getvalue('map_save'))
content = form.getvalue('content')
action = common.checkAjaxInput(form.getvalue('map_restart'))
add_mod.save_map(map_save, content, group, serv, action)
if form.getvalue('map_delete'):
map_name = common.checkAjaxInput(form.getvalue('map_delete'))
group = common.checkAjaxInput( form.getvalue('group'))
server_id = common.checkAjaxInput( form.getvalue('serv'))
add_mod.delete_map(map_name, group, server_id)
if form.getvalue('get_ldap_email'):
import modules.roxywi.user as roxywi_user
@ -1347,54 +1357,9 @@ if form.getvalue('loadservices'):
print(template)
if form.getvalue('loadchecker'):
from modules.roxywi.roxy import get_services_status
import modules.tools.checker as checker_mod
lang = roxywi_common.get_user_lang()
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
template = env.get_template('ajax/load_telegram.html')
services = get_services_status()
groups = sql.select_groups()
page = form.getvalue('page')
try:
user_subscription = roxywi_common.return_user_status()
except Exception as e:
user_subscription = roxywi_common.return_unsubscribed_user_status()
roxywi_common.logging('Roxy-WI server', f'Cannot get a user plan: {e}', roxywi=1)
if user_subscription['user_status']:
haproxy_settings = sql.select_checker_settings(1)
nginx_settings = sql.select_checker_settings(2)
keepalived_settings = sql.select_checker_settings(3)
apache_settings = sql.select_checker_settings(4)
if page == 'servers.py':
user_group = roxywi_common.get_user_group(id=1)
telegrams = sql.get_user_telegram_by_group(user_group)
slacks = sql.get_user_slack_by_group(user_group)
pds = sql.get_user_pd_by_group(user_group)
haproxy_servers = roxywi_common.get_dick_permit(haproxy=1, only_group=1)
nginx_servers = roxywi_common.get_dick_permit(nginx=1, only_group=1)
apache_servers = roxywi_common.get_dick_permit(apache=1, only_group=1)
keepalived_servers = roxywi_common.get_dick_permit(keepalived=1, only_group=1)
else:
telegrams = sql.select_telegram()
slacks = sql.select_slack()
pds = sql.select_pd()
haproxy_servers = roxywi_common.get_dick_permit(haproxy=1)
nginx_servers = roxywi_common.get_dick_permit(nginx=1)
apache_servers = roxywi_common.get_dick_permit(apache=1)
keepalived_servers = roxywi_common.get_dick_permit(keepalived=1)
else:
telegrams = ''
slacks = ''
pds = ''
template = template.render(services=services, telegrams=telegrams, pds=pds, groups=groups, slacks=slacks,
user_status=user_subscription['user_status'], user_plan=user_subscription['user_plan'],
haproxy_servers=haproxy_servers, nginx_servers=nginx_servers, apache_servers=apache_servers,
keepalived_servers=keepalived_servers, haproxy_settings=haproxy_settings, nginx_settings=nginx_settings,
keepalived_settings=keepalived_settings, apache_settings=apache_settings, page=page, lang=lang)
print(template)
checker_mod.load_checker()
if form.getvalue('load_update_hapwi'):
import modules.roxywi.roxy as roxy
@ -1541,13 +1506,13 @@ if form.getvalue('serverSettingsSave') is not None:
server_id = common.checkAjaxInput(form.getvalue('serverSettingsSave'))
service = common.checkAjaxInput(form.getvalue('serverSettingsService'))
haproxy_enterprise = common.checkAjaxInput(form.getvalue('serverSettingsEnterprise'))
haproxy_dockerized = common.checkAjaxInput(form.getvalue('serverSettingshaproxy_dockerized'))
nginx_dockerized = common.checkAjaxInput(form.getvalue('serverSettingsnginx_dockerized'))
apache_dockerized = common.checkAjaxInput(form.getvalue('serverSettingsapache_dockerized'))
haproxy_restart = common.checkAjaxInput(form.getvalue('serverSettingsHaproxyrestart'))
nginx_restart = common.checkAjaxInput(form.getvalue('serverSettingsNginxrestart'))
apache_restart = common.checkAjaxInput(form.getvalue('serverSettingsApache_restart'))
service_dockerized = common.checkAjaxInput(form.getvalue('serverSettingsDockerized'))
service_restart = common.checkAjaxInput(form.getvalue('serverSettingsRestart'))
server_ip = sql.select_server_ip_by_id(server_id)
service_docker = f'Service {service.title()} has been flagged as a dockerized'
service_systemd = f'Service {service.title()} has been flagged as a system service'
disable_restart = f'Restart option is disabled for {service.title()} service'
enable_restart = f'Restart option is disabled for {service.title()} service'
if service == 'haproxy':
if sql.insert_or_update_service_setting(server_id, service, 'haproxy_enterprise', haproxy_enterprise):
@ -1558,58 +1523,20 @@ if form.getvalue('serverSettingsSave') is not None:
else:
roxywi_common.logging(server_ip, 'Service has been flagged as a community version', roxywi=1, login=1,
keep_history=1, service=service)
if sql.insert_or_update_service_setting(server_id, service, 'dockerized', haproxy_dockerized):
print('Ok')
if haproxy_dockerized == '1':
roxywi_common.logging(server_ip, 'Service has been flagged as a dockerized', roxywi=1, login=1,
keep_history=1, service=service)
else:
roxywi_common.logging(server_ip, 'Service has been flagged as a system service', roxywi=1, login=1,
keep_history=1, service=service)
if sql.insert_or_update_service_setting(server_id, service, 'restart', haproxy_restart):
print('Ok')
if haproxy_restart == '1':
roxywi_common.logging(server_ip, 'Restart option is disabled for this service', roxywi=1, login=1,
keep_history=1, service=service)
else:
roxywi_common.logging(server_ip, 'Restart option is disabled for this service', roxywi=1, login=1,
keep_history=1, service=service)
if service == 'nginx':
if sql.insert_or_update_service_setting(server_id, service, 'dockerized', nginx_dockerized):
print('Ok')
if nginx_dockerized:
roxywi_common.logging(server_ip, 'Service has been flagged as a dockerized', roxywi=1, login=1,
keep_history=1, service=service)
else:
roxywi_common.logging(server_ip, 'Service has been flagged as a system service', roxywi=1, login=1,
keep_history=1, service=service)
if sql.insert_or_update_service_setting(server_id, service, 'restart', nginx_restart):
print('Ok')
if nginx_restart == '1':
roxywi_common.logging(server_ip, 'Restart option is disabled for this service', roxywi=1, login=1,
keep_history=1, service=service)
else:
roxywi_common.logging(server_ip, 'Restart option is disabled for this service', roxywi=1, login=1,
keep_history=1, service=service)
if sql.insert_or_update_service_setting(server_id, service, 'dockerized', service_dockerized):
print('Ok')
if service_dockerized == '1':
roxywi_common.logging(server_ip, service_docker, roxywi=1, login=1, keep_history=1, service=service)
else:
roxywi_common.logging(server_ip, service_systemd, roxywi=1, login=1, keep_history=1, service=service)
if service == 'apache':
if sql.insert_or_update_service_setting(server_id, service, 'dockerized', apache_dockerized):
print('Ok')
if apache_dockerized:
roxywi_common.logging(server_ip, 'Service has been flagged as a dockerized', roxywi=1, login=1,
keep_history=1, service=service)
else:
roxywi_common.logging(server_ip, 'Service has been flagged as a system service', roxywi=1, login=1,
keep_history=1, service=service)
if sql.insert_or_update_service_setting(server_id, service, 'restart', apache_restart):
print('Ok')
if apache_restart == '1':
roxywi_common.logging(server_ip, 'Restart option is disabled for this service', roxywi=1, login=1,
keep_history=1, service=service)
else:
roxywi_common.logging(server_ip, 'Restart option is disabled for this service', roxywi=1, login=1,
keep_history=1, service=service)
if sql.insert_or_update_service_setting(server_id, service, 'restart', service_restart):
print('Ok')
if service_restart == '1':
roxywi_common.logging(server_ip, disable_restart, roxywi=1, login=1, keep_history=1, service=service)
else:
roxywi_common.logging(server_ip, enable_restart, roxywi=1, login=1, keep_history=1, service=service)
if act == 'showListOfVersion':
config_mod.list_of_versions(serv, service)
@ -1655,46 +1582,19 @@ if form.getvalue('show_sub_ovw'):
roxywi_overview.show_sub_ovw()
if form.getvalue('updateHaproxyCheckerSettings'):
setting_id = form.getvalue('updateHaproxyCheckerSettings')
email = form.getvalue('email')
service_alert = form.getvalue('server')
backend_alert = form.getvalue('backend')
maxconn_alert = form.getvalue('maxconn')
telegram_id = form.getvalue('telegram_id')
slack_id = form.getvalue('slack_id')
pd_id = form.getvalue('pd_id')
import modules.tools.checker as checker_mod
if sql.update_haproxy_checker_settings(email, telegram_id, slack_id, pd_id, service_alert, backend_alert, maxconn_alert, setting_id):
print('ok')
else:
print('error: Cannot update Checker settings')
checker_mod.update_haproxy_settings()
if form.getvalue('updateKeepalivedCheckerSettings'):
setting_id = form.getvalue('updateKeepalivedCheckerSettings')
email = form.getvalue('email')
service_alert = form.getvalue('server')
backend_alert = form.getvalue('backend')
telegram_id = form.getvalue('telegram_id')
slack_id = form.getvalue('slack_id')
pd_id = form.getvalue('pd_id')
import modules.tools.checker as checker_mod
if sql.update_keepalived_checker_settings(email, telegram_id, slack_id, pd_id, service_alert, backend_alert, setting_id):
print('ok')
else:
print('error: Cannot update Checker settings')
checker_mod.update_keepalived_settings()
if form.getvalue('updateServiceCheckerSettings'):
setting_id = form.getvalue('updateServiceCheckerSettings')
email = form.getvalue('email')
service_alert = form.getvalue('server')
telegram_id = form.getvalue('telegram_id')
slack_id = form.getvalue('slack_id')
pd_id = form.getvalue('pd_id')
import modules.tools.checker as checker_mod
if sql.update_service_checker_settings(email, telegram_id, slack_id, pd_id, service_alert, setting_id):
print('ok')
else:
print('error: Cannot update Checker settings')
checker_mod.update_service_settings()
if act == 'show_server_services':
server_mod.show_server_services()

View File

@ -46,7 +46,7 @@
- '"firewalld" in ansible_facts.packages'
- ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS'
- ansible_facts.services["firewalld.service"]['state'] == "running"
with_items: [ "{{ STAT_PORT }}", "{{ SOCK_PORT }}" ]
with_items: [ "{{ STAT_PORT }}", "{{ SOCK_PORT }}", "10000" ]
- name: Open stat port for iptables
@ -56,7 +56,7 @@
jump: ACCEPT
protocol: tcp
ignore_errors: yes
with_items: [ "{{ STAT_PORT }}", "{{ SOCK_PORT }}" ]
with_items: [ "{{ STAT_PORT }}", "{{ SOCK_PORT }}", "10000" ]
- name: Create the haproxy group
group:

View File

@ -61,7 +61,7 @@
- socat
- rsyslog
state: latest
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ("'FAILED' in install_result1.stderr")
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and (install_result.rc != 0 and install_result1.rc != 0)
register: install_result
retries: 5
until: install_result.rc == 0

View File

@ -38,9 +38,21 @@ listen stats
stats realm HAProxy-04\ Statistics
stats auth {{STATS_USER}}:{{STATS_PASS}}
stats admin if TRUE
{% if M_OR_S != 'None' %}
peers default_peers
{% if M_OR_S == 'master' %}
peer {{ ansible_hostname }} {{MASTER}}:10000
peer slave_lb {{SLAVE}}:10000
{% else %}
peer master_lb {{MASTER}}:10000
peer {{ ansible_hostname }} {{SLAVE}}:10000
{% endif %}
{% endif %}
backend per_ip_and_url_rates
stick-table type binary len 8 size 1m expire 24h store http_req_rate(24h)
stick-table type binary len 8 size 1m expire 24h store http_req_rate(24h) {% if M_OR_S != 'None' %} peers default_peers {% endif %}
backend per_ip_rates
stick-table type ip size 1m expire 24h store gpc0,gpc0_rate(30s)
stick-table type ip size 1m expire 24h store gpc0,gpc0_rate(30s) {% if M_OR_S != 'None' %} peers default_peers {% endif %}

View File

@ -5,22 +5,25 @@ do
VALUE=$(echo $ARGUMENT | cut -f2 -d=)
case "$KEY" in
PROXY) PROXY=${VALUE} ;;
PROXY) PROXY=${VALUE} ;;
SOCK_PORT) SOCK_PORT=${VALUE} ;;
STAT_PORT) STAT_PORT=${VALUE} ;;
STAT_FILE) STAT_FILE=${VALUE} ;;
STATS_USER) STATS_USER=${VALUE} ;;
STATS_PASS) STATS_PASS=${VALUE} ;;
HAPVER) HAPVER=${VALUE} ;;
HOST) HOST=${VALUE} ;;
USER) USER=${VALUE} ;;
PASS) PASS=${VALUE} ;;
KEY) KEY=${VALUE} ;;
STATS_USER) STATS_USER=${VALUE} ;;
STATS_PASS) STATS_PASS=${VALUE} ;;
HAPVER) HAPVER=${VALUE} ;;
HOST) HOST=${VALUE} ;;
USER) USER=${VALUE} ;;
PASS) PASS=${VALUE} ;;
KEY) KEY=${VALUE} ;;
SYN_FLOOD) SYN_FLOOD=${VALUE} ;;
SSH_PORT) SSH_PORT=${VALUE} ;;
DOCKER) DOCKER=${VALUE} ;;
HAP_DIR) HAP_DIR=${VALUE} ;;
SSH_PORT) SSH_PORT=${VALUE} ;;
DOCKER) DOCKER=${VALUE} ;;
HAP_DIR) HAP_DIR=${VALUE} ;;
CONT_NAME) CONT_NAME=${VALUE} ;;
M_OR_S) M_OR_S=${VALUE} ;;
MASTER) MASTER=${VALUE} ;;
SLAVE) SLAVE=${VALUE} ;;
*)
esac
done
@ -41,9 +44,9 @@ else
fi
if [[ $KEY == "" ]]; then
ansible-playbook $PWD/roles/haproxy.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST PROXY=$PROXY HAPVER=$HAPVER HAP_DIR=$HAP_DIR CONT_NAME=$CONT_NAME SOCK_PORT=$SOCK_PORT STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS='$STATS_PASS' STAT_FILE=$STAT_FILE SSH_PORT=$SSH_PORT SYN_FLOOD=$SYN_FLOOD" -i $PWD/$HOST -t $tags
ansible-playbook $PWD/roles/haproxy.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST PROXY=$PROXY HAPVER=$HAPVER HAP_DIR=$HAP_DIR CONT_NAME=$CONT_NAME SOCK_PORT=$SOCK_PORT STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS='$STATS_PASS' STAT_FILE=$STAT_FILE SSH_PORT=$SSH_PORT SYN_FLOOD=$SYN_FLOOD M_OR_S=$M_OR_S MASTER=$MASTER SLAVE=$SLAVE" -i $PWD/$HOST -t $tags
else
ansible-playbook $PWD/roles/haproxy.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY HAPVER=$HAPVER HAP_DIR=$HAP_DIR CONT_NAME=$CONT_NAME SOCK_PORT=$SOCK_PORT STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS='$STATS_PASS' STAT_FILE=$STAT_FILE SSH_PORT=$SSH_PORT SYN_FLOOD=$SYN_FLOOD" -i $PWD/$HOST -t $tags
ansible-playbook $PWD/roles/haproxy.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY HAPVER=$HAPVER HAP_DIR=$HAP_DIR CONT_NAME=$CONT_NAME SOCK_PORT=$SOCK_PORT STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS='$STATS_PASS' STAT_FILE=$STAT_FILE SSH_PORT=$SSH_PORT SYN_FLOOD=$SYN_FLOOD M_OR_S=$M_OR_S MASTER=$MASTER SLAVE=$SLAVE" -i $PWD/$HOST -t $tags
fi
if [ $? -gt 0 ]

View File

@ -33,6 +33,7 @@
<li><a href="#userlist" title="{{lang.words.add|title()}} {{lang.words.proxy}}: {{lang.words.create|title()}} {{lang.words.userlists|title()}} - Roxy-WI">{{lang.words.userlists|title()}}</a></li>
<li><a href="#peers" title="{{lang.words.add|title()}} {{lang.words.proxy}}: {{lang.words.create|title()}} peers - Roxy-WI">Peers</a></li>
<li><a href="#lists" title="{{lang.words.add|title()}} {{lang.words.proxy}}: {{lang.words.create|title()}} {{lang.words.and}} {{lang.words.upload}} {{lang.words.whitelists}} {{lang.words.or}} {{lang.words.blacklists}} - Roxy-WI">{{lang.words.lists|title()}}</a></li>
<li><a href="#maps" title="{{lang.words.add|title()}} {{lang.words.proxy}}: {{lang.words.create|title()}} {{lang.words.and}} {{lang.words.upload}} {{lang.words.maps}} - Roxy-WI">{{lang.words.maps|title()}}</a></li>
</ul>
<ul id='browse_histroy'></ul>
{% include 'include/add_proxy.html' %}
@ -1084,7 +1085,7 @@
<td style="width: 30%; padding: 10px 0 10px 0;">
{% for list in black_lists %}
<span class="list_of_lists">
<a onclick="editList('{{ list }}', 'black')" title="{{lang.words.edit|title()}} {{lang.words.the}} {{ list }} list">{{ list }}</a>
<a onclick="editList('{{ list }}', 'black')" title="{{lang.words.edit|title()}} {{lang.words.the}} {{ list }} {{lang.words.list}}">{{ list }}</a>
</span>
{% endfor %}
</td>
@ -1126,11 +1127,53 @@
{{lang.add_page.desc.lists_howto}}
<a href="https://roxy-wi.org/howto/blacklist" title="How to create and manage blacklist" target="_blank">{{lang.words.article}}</a>
</div>
<div id="dialog-confirm-cert-edit" title="View certificate " style="display: none;">
<div id="dialog-confirm-cert-edit" title="{{lang.words.view|title()}} {{lang.words.cert}} " style="display: none;">
<span><b>{{lang.words.note|title()}}:</b> {{lang.add_page.desc.lists_new_line}}</span>
<textarea id="edit_lists" style="width: 100%" rows=20></textarea>
</div>
</div>
<div id="maps">
<table class="overview">
<tr class="overviewHead">
<th class="padding10 first-collumn">{{lang.words.new|title()}} {{lang.words.map}}</th>
<th>{{lang.words.server|title()}} {{lang.words.for}} {{lang.words.uploading}}</th>
<th>{{lang.words.existing|title()}} {{lang.words.maps}}</th>
</tr>
<tr>
<td class="padding10 first-collumn" style="width: 25%;">
{{lang.words.name|title()}}: {{ input('new_map_name') }}
<button onclick="createMap()">{{lang.words.create|title()}}</button>
</td>
<td class="first-collumn">
<select required name="serv-map" id="serv-map">
<option disabled selected>------</option>
<option value="all">{{lang.words.all|title()}}</option>
{% for select in selects %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endfor %}
</select>
</td>
<td style="width: 30%; padding: 10px 0 10px 0;">
{% for map in maps %}
<span class="list_of_lists">
<a onclick="editMap('{{ map }}')" title="{{lang.words.edit|title()}} {{lang.words.the}} {{ map }} {{lang.words.map}}">{{ map }}</a>
</span>
{% endfor %}
</td>
</tr>
{{ input('group', value=group, type='hidden') }}
</table>
<div id="ajax-maps"></div>
<div class="add-note alert addName alert-info" style="width: inherit; margin-right: 15px;">
{{lang.add_page.desc.lists_howto}}
<a href="https://www.haproxy.com/blog/introduction-to-haproxy-maps" title="Introduction to HAProxy Maps" target="_blank">{{lang.words.article}}</a>
</div>
<div id="dialog-confirm-map-edit" title="{{lang.words.view|title()}} {{lang.words.map}} " style="display: none;">
<span><b>{{lang.words.note|title()}}:</b> {{lang.add_page.desc.lists_new_line}}</span>
<textarea id="edit_map" style="width: 100%" rows=20></textarea>
</div>
</div>
{% include 'include/del_confirm.html' %}
<div id="dialog-confirm-cert" title="View certificate " style="display: none;">
<pre id="dialog-confirm-body"></pre>

View File

@ -171,7 +171,6 @@
"tmp_config_path": "Path to the temporary directory. A valid path should be specified as the value of this parameter. The directory must be owned by the user specified in SSH settings",
"cert_path": "Path to SSL dir. Folder owner must be a user which set in the SSH settings. Path must exist",
"ssl_local_path": "Path to the directory with the saved local SSL certificates. The value of this parameter is specified as a relative path beginning with $HOME_ROXY_WI/app/",
"lists_path": "Path to the black and the white list. The value of this paramer should be specified as a relative path beginning with $HOME_ROXY-WI",
"maxmind_key": "License key for downloading to GeoLite2 DB. You can create it on maxmind.com",
},
"mail": {
@ -464,6 +463,7 @@
"UNKNOWN": "UNKNOWN",
"PORT_DOWN": "PORT DOWN",
"DISABLED": "DISABLED",
"packet_size": "Packet size",
}
}
%}
@ -647,7 +647,7 @@
"set": "set",
"type": "type",
"typing": "typing",
"site": "size",
"size": "size",
"is": "is",
"w_empty": "empty",
"used": "used",
@ -875,5 +875,7 @@
"average2": "average",
"cert_expire": "Cert Expire",
"Hostname": "Hostname",
"maps": "maps",
"map": "map",
}
%}

View File

@ -171,7 +171,6 @@
"tmp_config_path": "Chemin pour le dossier temporaire. Un chemin valide doit être spécifier pour ce paramètre. Le répèrtoire doit appartenir au même utilisateur celui spécifié dans les paramètres SSH",
"cert_path": "Chemin pour le dossier SSL. Le répèrtoire doit appartenir au même utilisateur celui spécifié dans les paramètres SSH. Le chemin doit éxister",
"ssl_local_path": "Chemin pour le dossier local contenant les certificats SSL sauvegardés. La valeur spécifiée est relative au chemin commençant par $HOME_ROXY_WI/app/",
"lists_path": "Chemin pour les listes non authorisées ou authorisées. La valeur de ce paramètre est relative au chemin commeçant par $HOME_ROXY-WI",
"maxmind_key": "Clé de licence à télécharger sur GeoLite2 DB. Vous pouvez la créer sur maxmind.com",
},
"mail": {
@ -876,5 +875,7 @@
"average2": "moyenne",
"cert_expire": "Expiration du certificat",
"Hostname": "Nome de anfitrião",
"maps": "cartes",
"map": "carte",
}
%}

View File

@ -171,7 +171,6 @@
"tmp_config_path": "Caminho para o diretório temporário.. Indica um caminho válidos. O dono do directorio deve ser o usuario indicado na configuração de SSH. O camihno deve existir",
"cert_path": "Caminho para o diretório SSL. O dono do directorio deve ser o usuario indicado na configuração de SSH. O camihno deve existir",
"ssl_local_path": "aminho para o diretório com certificados SSL locais. O valor desse parâmetro debe ser o caminho relativo que começa com $HOME_ROXY_WI/app/",
"lists_path": "Caminho para a lista branca e lista negra. O valor desse parâmetro debe ser o caminho relativo que começa com $HOME_ROXY_WI/app/",
"maxmind_key": "A chave de licença para carregar GeoliteDB. Você pode cria-lo no maxmind.com",
},
"mail": {
@ -464,6 +463,7 @@
"UNKNOWN": "UNKNOWN",
"PORT_DOWN": "PORT DOWN",
"DISABLED": "DESABIL.",
"packet_size": "Tamanho do pacote",
}
}
%}
@ -647,7 +647,7 @@
"set": "definir",
"type": "tipo",
"typing": "typing",
"site": "site",
"size": "size",
"is": "dinamicamente",
"w_empty": "vazio",
"used": "usado",
@ -875,5 +875,7 @@
"average2": "médio",
"cert_expire": "Expiração do certificado",
"Hostname": "Nom d'hôte",
"maps": "mapas",
"map": "mapa",
}
%}

View File

@ -171,7 +171,6 @@
"tmp_config_path": "Путь до временной директории. Путь должен существовать. Директория должна принадлежать пользователю, от имени которого подключается SSH",
"cert_path": "Путь до SSL-директории. Путь должен существовать. Директория должна принадлежать пользователю, от имени которого подключается SSH",
"ssl_local_path": "Локальный путь для хранения SSL-сертификатов. Укажите относительный путь от $HOME_ROXY_WI/app/",
"lists_path": "Локальный путь для хранения черных и белых списков. Укажите относительный путь от $HOME_ROXY-WI",
"maxmind_key": "Лицензионный ключ для загрузки GeoLite2 DB. Создается на сайте maxmind.com",
},
"mail": {
@ -876,5 +875,7 @@
"average2": "средний",
"cert_expire": "Срок действия сертификата",
"Hostname": "Имя хоста",
"maps": "карты",
"map": "карта",
}
%}

View File

@ -10,6 +10,7 @@
<input type="hidden" id="new-sshgroup" name="new-sshgroup" value="{{ group }}" >
{{ input('new-telegram-group-add', type='hidden', value=group) }}
{{ input('new-slack-group-add', type='hidden', value=group) }}
{{ input('new-pd-group-add', type='hidden', value=group) }}
<div id="tabs">
<ul>
<li><a href="#users" title="{{lang.words.servers|title()}}: {{lang.words.manage|title()}} {{lang.words.users}} - Roxy-WI">{{lang.words.users|title()}}</a></li>

View File

@ -931,13 +931,17 @@ $( function() {
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error:') != '-1') {
toastr.error(data);
} else if (data.indexOf('success') != '-1') {
toastr.success(data);
} else {
toastr.error('Something wrong, check and try again');
data = data.split("<br/>");
for (i = 0; i < data.length; i++) {
if (data[i]) {
if (data[i].indexOf('error: ') != '-1' || data[i].indexOf('Errno') != '-1') {
toastr.error(data[i]);
} else {
if (data[i] != '\n') {
toastr.success(data[i]);
}
}
}
}
}
} );
@ -1745,7 +1749,9 @@ function saveList(action, list, color) {
if (data[i].indexOf('error: ') != '-1' || data[i].indexOf('Errno') != '-1') {
toastr.error(data[i]);
} else {
toastr.success(data[i]);
if (data[i] != '\n') {
toastr.success(data[i]);
}
}
}
}
@ -1779,6 +1785,150 @@ function deleteList(list, color) {
}
});
}
function createMap() {
map_name = $('#new_map_name').val()
map_name = escapeHtml(map_name);
$.ajax( {
url: "options.py",
data: {
map_create: map_name,
group: $('#group').val(),
token: $('#token').val()
},
type: "POST",
success: function( data ) {
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1' || data.indexOf('Errno') != '-1') {
toastr.error(data);
} else if (data.indexOf('Info') != '-1' ){
toastr.clear();
toastr.info(data);
} else if (data.indexOf('success') != '-1' ) {
toastr.clear();
toastr.success('A map has been created');
setTimeout(function () {
location.reload();
}, 2500);
}
}
} );
}
function editMap(map) {
$.ajax( {
url: "options.py",
data: {
edit_map: map,
group: $('#group').val(),
token: $('#token').val()
},
type: "POST",
success: function( data ) {
if (data.indexOf('error:') != '-1') {
toastr.error(data);
} else {
var cancel_word = $('#translate').attr('data-cancel');
var save_word = $('#translate').attr('data-just_save');
var delete_word = $('#translate').attr('data-delete');
var upload_and_reload = $('#translate').attr('data-upload_and_reload');
var upload_and_restart = $('#translate').attr('data-upload_and_restart');
var edit_word = $('#translate').attr('data-edit');
$('#edit_map').text(data);
$( "#dialog-confirm-map-edit" ).dialog({
resizable: false,
height: "auto",
width: 650,
modal: true,
title: edit_word + " "+map,
buttons: [{
text: delete_word,
click: function () {
$(this).dialog("close");
confirmDeleting('map', map, $(this));
}
}, {
text: save_word,
click: function () {
$(this).dialog("close");
saveMap('save', map);
}
}, {
text: upload_and_reload,
click: function () {
$(this).dialog("close");
saveMap('reload', map);
}
}, {
text: upload_and_restart,
click: function () {
$(this).dialog("close");
saveMap('restart', map);
}
}, {
text: cancel_word,
click: function () {
$(this).dialog("close");
}
}]
});
}
}
} );
}
function saveMap(action, map) {
var serv = $( "#serv-map option:selected" ).val();
if(!checkIsServerFiled($("#serv-map"))) return false;
$.ajax({
url: "options.py",
data: {
map_save: map,
serv: serv,
content: $('#edit_map').val(),
group: $('#group').val(),
map_restart: action,
token: $('#token').val()
},
type: "POST",
success: function (data) {
data = data.split(" , ");
for (i = 0; i < data.length; i++) {
if (data[i]) {
if (data[i].indexOf('error: ') != '-1' || data[i].indexOf('Errno') != '-1') {
toastr.error(data[i]);
} else {
if (data[i] != '\n') {
toastr.success(data[i]);
}
}
}
}
}
});
}
function deleteMap(map) {
var serv = $( "#serv-map option:selected" ).val();
if(!checkIsServerFiled($("#serv-map"))) return false;
$.ajax({
url: "options.py",
data: {
map_delete: map,
serv: serv,
group: $('#group').val(),
token: $('#token').val()
},
type: "POST",
success: function (data) {
if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1' || data.indexOf('Errno') != '-1') {
toastr.error(data);
} else if (data.indexOf('Info') != '-1' ){
toastr.clear();
toastr.info(data);
} else if (data.indexOf('success') != '-1' ) {
toastr.clear();
toastr.success('The map has been deleted');
setTimeout(function () {location.reload();}, 2500);
}
}
});
}
function generateConfig(form_name) {
var frm = $('#'+form_name);
if (form_name == 'add-listener') {
@ -1951,6 +2101,9 @@ function confirmDeleting(deleting_thing, id, dialog_id, color) {
} else if (deleting_thing == "list") {
deleteList(id, color);
$(dialog_id).dialog("close");
} else if (deleting_thing == "map") {
deleteMap(id);
$(dialog_id).dialog("close");
}
$(this).dialog("close");
}

View File

@ -66,6 +66,7 @@ function showOverview(serv, hostnamea) {
}
showSubOverview();
showServicesOverview();
updatingCpuRamCharts();
}
function showOverviewCallBack(serv, hostnamea) {
$.ajax( {
@ -669,32 +670,28 @@ function serverSettings(id, name) {
}
function serverSettingsSave(id, name, service, dialog_id) {
var haproxy_enterprise = 0;
var haproxy_dockerized = 0;
var nginx_dockerized = 0;
var apache_dockerized = 0;
var haproxy_restart = 0;
var nginx_restart = 0;
var apache_restart = 0;
var service_dockerized = 0;
var service_restart = 0;
if ($('#haproxy_enterprise').is(':checked')) {
haproxy_enterprise = '1';
}
if ($('#haproxy_dockerized').is(':checked')) {
haproxy_dockerized = '1';
service_dockerized = '1';
}
if ($('#nginx_dockerized').is(':checked')) {
nginx_dockerized = '1';
service_dockerized = '1';
}
if ($('#apache_dockerized').is(':checked')) {
apache_dockerized = '1';
service_dockerized = '1';
}
if ($('#haproxy_restart').is(':checked')) {
haproxy_restart = '1';
service_restart = '1';
}
if ($('#nginx_restart').is(':checked')) {
nginx_restart = '1';
service_restart = '1';
}
if ($('#apache_restart').is(':checked')) {
apache_restart = '1';
service_restart = '1';
}
$.ajax({
url: "options.py",
@ -702,12 +699,8 @@ function serverSettingsSave(id, name, service, dialog_id) {
serverSettingsSave: id,
serverSettingsService: service,
serverSettingsEnterprise: haproxy_enterprise,
serverSettingshaproxy_dockerized: haproxy_dockerized,
serverSettingsnginx_dockerized: nginx_dockerized,
serverSettingsapache_dockerized: apache_dockerized,
serverSettingsHaproxyrestart: haproxy_restart,
serverSettingsNginxrestart: nginx_restart,
serverSettingsApache_restart: apache_restart,
serverSettingsDockerized: service_dockerized,
serverSettingsRestart: service_restart,
token: $('#token').val()
},
type: "POST",

View File

@ -707,21 +707,23 @@ function viewLogs() {
}
}
$( function() {
// $('a').click(function(e) {
// try {
// var cur_path = window.location.pathname;
// var attr = $(this).attr('href');
// if (typeof attr !== typeof undefined && attr !== false) {
// $('title').text($(this).attr('title'));
// history.pushState({}, '', $(this).attr('href'));
// if ($(this).attr('href').split('#')[0] && $(this).attr('href').split('#')[0] != cur_path) {
// window.history.go()
// }
// }
// } catch (err) {
// console.log(err);
// }
// });
$('a').click(function(e) {
try {
var cur_path = window.location.pathname;
var attr = $(this).attr('href');
if (cur_path == '/app/add.py' || cur_path == '/app/add_nginx.py' || cur_path == '/app/servers.py' || cur_path == '/app/users.py') {
if (typeof attr !== typeof undefined && attr !== false) {
$('title').text($(this).attr('title'));
history.pushState({}, '', $(this).attr('href'));
if ($(this).attr('href').split('#')[0] && $(this).attr('href').split('#')[0] != cur_path) {
window.history.go()
}
}
}
} catch (err) {
console.log(err);
}
});
toastr.options.closeButton = true;
toastr.options.progressBar = true;
toastr.options.positionClass = 'toast-bottom-full-width';

View File

@ -1975,6 +1975,11 @@ function updateSSH(id) {
} );
}
function updateReceiver(id, receiver_name) {
if (cur_url[0].split('#')[0] == 'servers.py') {
var group = $('#new-group').val();
} else {
var group = $('#'+receiver_name+'group-'+id).val();
}
toastr.clear();
$.ajax( {
url: "options.py",
@ -1982,7 +1987,7 @@ function updateReceiver(id, receiver_name) {
receiver_name: receiver_name,
update_receiver_token: $('#'+receiver_name+'-token-'+id).val(),
update_receiver_channel: $('#'+receiver_name+'-chanel-'+id).val(),
update_receiver_group: $('#'+receiver_name+'group-'+id).val(),
update_receiver_group: group,
id: id,
token: $('#token').val()
},
@ -2366,6 +2371,7 @@ function updateService(service, action='update') {
}
$("#ajax-update").html('');
loadupdatehapwi();
show_version();
}
} );
}