mirror of https://github.com/Aidaho12/haproxy-wi
parent
21c24520fc
commit
9062c3a083
22
app/add.py
22
app/add.py
|
@ -28,6 +28,21 @@ try:
|
||||||
token = sql.get_token(user_id.value)
|
token = sql.get_token(user_id.value)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
dir = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')
|
||||||
|
white_dir = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+user_group+"/white"
|
||||||
|
black_dir = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+user_group+"/black"
|
||||||
|
if not os.path.exists(dir):
|
||||||
|
os.makedirs(dir)
|
||||||
|
if not os.path.exists(dir+"/"+user_group):
|
||||||
|
os.makedirs(dir+"/"+user_group)
|
||||||
|
if not os.path.exists(white_dir):
|
||||||
|
os.makedirs(white_dir)
|
||||||
|
if not os.path.exists(black_dir):
|
||||||
|
os.makedirs(black_dir)
|
||||||
|
|
||||||
|
white_lists = funct.get_files(dir=white_dir, format="lst")
|
||||||
|
black_lists = funct.get_files(dir=black_dir, format="lst")
|
||||||
|
|
||||||
|
|
||||||
template = template.render(title = "Add",
|
template = template.render(title = "Add",
|
||||||
|
@ -40,6 +55,8 @@ template = template.render(title = "Add",
|
||||||
versions = funct.versions(),
|
versions = funct.versions(),
|
||||||
options = sql.select_options(),
|
options = sql.select_options(),
|
||||||
saved_servers = sql.select_saved_servers(),
|
saved_servers = sql.select_saved_servers(),
|
||||||
|
white_lists = white_lists,
|
||||||
|
black_lists = black_lists,
|
||||||
token = token)
|
token = token)
|
||||||
print(template)
|
print(template)
|
||||||
|
|
||||||
|
@ -153,7 +170,10 @@ if form.getvalue('mode') is not None:
|
||||||
server_port = form.getlist('server_port')
|
server_port = form.getlist('server_port')
|
||||||
i = 0
|
i = 0
|
||||||
for server in servers:
|
for server in servers:
|
||||||
servers_split += " server "+server+" " + server +":"+server_port[i]+ check + "\n"
|
if form.getvalue('template') is None:
|
||||||
|
servers_split += " server "+server+" " + server +":"+server_port[i]+ check + "\n"
|
||||||
|
else:
|
||||||
|
servers_split += " server-template "+form.getvalue('prefix')+" "+form.getvalue('template-number')+" "+ server +":"+server_port[i]+ check + "\n"
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
compression = form.getvalue("compression")
|
compression = form.getvalue("compression")
|
||||||
|
|
199
app/create_db.py
199
app/create_db.py
|
@ -72,6 +72,8 @@ def create_table(**kwargs):
|
||||||
`password` VARCHAR ( 128 ),
|
`password` VARCHAR ( 128 ),
|
||||||
`role` VARCHAR ( 128 ),
|
`role` VARCHAR ( 128 ),
|
||||||
`groups` VARCHAR ( 120 ),
|
`groups` VARCHAR ( 120 ),
|
||||||
|
ldap_user INTEGER NOT NULL DEFAULT 0,
|
||||||
|
activeuser INTEGER NOT NULL DEFAULT 1,
|
||||||
PRIMARY KEY(`id`)
|
PRIMARY KEY(`id`)
|
||||||
);
|
);
|
||||||
INSERT INTO user (username, email, password, role, groups) VALUES ('admin','admin@localhost','21232f297a57a5a743894a0e4a801fc3','admin','1'),
|
INSERT INTO user (username, email, password, role, groups) VALUES ('admin','admin@localhost','21232f297a57a5a743894a0e4a801fc3','admin','1'),
|
||||||
|
@ -88,6 +90,9 @@ def create_table(**kwargs):
|
||||||
cred INTEGER NOT NULL DEFAULT 1,
|
cred INTEGER NOT NULL DEFAULT 1,
|
||||||
alert INTEGER NOT NULL DEFAULT 0,
|
alert INTEGER NOT NULL DEFAULT 0,
|
||||||
metrics INTEGER NOT NULL DEFAULT 0,
|
metrics INTEGER NOT NULL DEFAULT 0,
|
||||||
|
port INTEGER NOT NULL DEFAULT 22,
|
||||||
|
`desc` varchar(64),
|
||||||
|
active INTEGER NOT NULL DEFAULT 0,
|
||||||
PRIMARY KEY(`id`)
|
PRIMARY KEY(`id`)
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS `role` (
|
CREATE TABLE IF NOT EXISTS `role` (
|
||||||
|
@ -124,6 +129,8 @@ def create_table(**kwargs):
|
||||||
CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
||||||
CREATE TABLE IF NOT EXISTS `saved_servers` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `description` VARCHAR ( 120 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
CREATE TABLE IF NOT EXISTS `saved_servers` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `description` VARCHAR ( 120 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
||||||
CREATE TABLE IF NOT EXISTS `backups` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `rhost` VARCHAR ( 120 ), `rpath` VARCHAR ( 120 ), `type` VARCHAR ( 120 ), `time` VARCHAR ( 120 ), cred INTEGER, `description` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
CREATE TABLE IF NOT EXISTS `backups` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `rhost` VARCHAR ( 120 ), `rpath` VARCHAR ( 120 ), `type` VARCHAR ( 120 ), `time` VARCHAR ( 120 ), cred INTEGER, `description` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
||||||
|
CREATE TABLE IF NOT EXISTS `waf` (`server_id` INTEGER UNIQUE, metrics INTEGER);
|
||||||
|
CREATE TABLE IF NOT EXISTS `waf_metrics` (`serv` varchar(64), conn INTEGER, `date` DATETIME default '0000-00-00 00:00:00');
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
cur.executescript(sql)
|
cur.executescript(sql)
|
||||||
|
@ -149,7 +156,8 @@ def create_table(**kwargs):
|
||||||
return True
|
return True
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def update_db_v_31(**kwargs):
|
def update_db_v_31(**kwargs):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = list()
|
sql = list()
|
||||||
|
@ -176,7 +184,7 @@ def update_db_v_31(**kwargs):
|
||||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'haproxy', 'Temp store configs, for haproxy check');")
|
sql.append("INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'haproxy', 'Temp store configs, for haproxy check');")
|
||||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'haproxy', 'Path to SSL dir');")
|
sql.append("INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'haproxy', 'Path to SSL dir');")
|
||||||
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', '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('lists_path', 'lists', 'main', 'Path to black/white lists');")
|
sql.append("INSERT INTO settings (param, value, section, `desc`) values('lists_path', 'lists', 'main', 'Path to black/white lists. This is a relative path, begins with $HOME_HAPROXY-WI');")
|
||||||
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('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_enable', '0', 'ldap', 'If 1 ldap enabled');")
|
||||||
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_server', '', 'ldap', 'IP address ldap server');")
|
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_server', '', 'ldap', 'IP address ldap server');")
|
||||||
|
@ -202,150 +210,6 @@ def update_db_v_31(**kwargs):
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
def update_db_v_3_2(**kwargs):
|
|
||||||
con, cur = get_cur()
|
|
||||||
sql = """CREATE TABLE IF NOT EXISTS `waf` (`server_id` INTEGER UNIQUE, metrics INTEGER); """
|
|
||||||
try:
|
|
||||||
cur.execute(sql)
|
|
||||||
con.commit()
|
|
||||||
except sqltool.Error as e:
|
|
||||||
if kwargs.get('silent') != 1:
|
|
||||||
if e.args[0] == 'duplicate column name: server_id' or e == "1060 (42S21): Duplicate column name 'server_id' ":
|
|
||||||
print('Updating... go to version 3.2')
|
|
||||||
else:
|
|
||||||
print("An error occurred:", e.args[0])
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
cur.close()
|
|
||||||
con.close()
|
|
||||||
|
|
||||||
def update_db_v_3_21(**kwargs):
|
|
||||||
con, cur = get_cur()
|
|
||||||
sql = """CREATE TABLE IF NOT EXISTS `waf_metrics` (`serv` varchar(64), conn INTEGER, `date` DATETIME default '0000-00-00 00:00:00'); """
|
|
||||||
try:
|
|
||||||
cur.execute(sql)
|
|
||||||
con.commit()
|
|
||||||
except sqltool.Error as e:
|
|
||||||
if kwargs.get('silent') != 1:
|
|
||||||
if e.args[0] == 'duplicate column name: token' or e == "1060 (42S21): Duplicate column name 'token' ":
|
|
||||||
print('Updating... go to version 2.6')
|
|
||||||
else:
|
|
||||||
print("An error occurred:", e.args[0])
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
cur.close()
|
|
||||||
con.close()
|
|
||||||
|
|
||||||
def update_db_v_3_2_3(**kwargs):
|
|
||||||
con, cur = get_cur()
|
|
||||||
sql = """
|
|
||||||
ALTER TABLE `servers` ADD COLUMN port INTEGER NOT NULL DEFAULT 22;
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
cur.execute(sql)
|
|
||||||
con.commit()
|
|
||||||
except sqltool.Error as e:
|
|
||||||
if kwargs.get('silent') != 1:
|
|
||||||
if e.args[0] == 'duplicate column name: port' or e == " 1060 (42S21): Duplicate column name 'port' ":
|
|
||||||
print('Updating... go to version 3.2.8')
|
|
||||||
else:
|
|
||||||
print("An error occurred:", e)
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
print("DB was update to 3.2.3")
|
|
||||||
return True
|
|
||||||
cur.close()
|
|
||||||
con.close()
|
|
||||||
|
|
||||||
def update_db_v_3_2_8(**kwargs):
|
|
||||||
con, cur = get_cur()
|
|
||||||
sql = """
|
|
||||||
ALTER TABLE `servers` ADD COLUMN `desc` varchar(64);
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
cur.execute(sql)
|
|
||||||
con.commit()
|
|
||||||
except sqltool.Error as e:
|
|
||||||
if kwargs.get('silent') != 1:
|
|
||||||
if e.args[0] == 'duplicate column name: desc' or e == " 1060 (42S21): Duplicate column name 'desc' ":
|
|
||||||
print('Updating... go to version 3.3')
|
|
||||||
else:
|
|
||||||
print("An error occurred:", e)
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
print("DB was update to 3.2.8")
|
|
||||||
return True
|
|
||||||
cur.close()
|
|
||||||
con.close()
|
|
||||||
|
|
||||||
|
|
||||||
def update_db_v_3_31(**kwargs):
|
|
||||||
con, cur = get_cur()
|
|
||||||
sql = """
|
|
||||||
ALTER TABLE `user` ADD COLUMN ldap_user INTEGER NOT NULL DEFAULT 0;
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
cur.execute(sql)
|
|
||||||
con.commit()
|
|
||||||
except sqltool.Error as e:
|
|
||||||
if kwargs.get('silent') != 1:
|
|
||||||
if e.args[0] == 'duplicate column name: ldap_user' or e == " 1060 (42S21): Duplicate column name 'ldap_user' ":
|
|
||||||
print('Updating... go to version 3.4')
|
|
||||||
else:
|
|
||||||
print("An error occurred:", e)
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
print("DB was update to 3.3")
|
|
||||||
return True
|
|
||||||
cur.close()
|
|
||||||
con.close()
|
|
||||||
|
|
||||||
|
|
||||||
def update_db_v_3_4(**kwargs):
|
|
||||||
con, cur = get_cur()
|
|
||||||
sql = """
|
|
||||||
ALTER TABLE `servers` ADD COLUMN active INTEGER NOT NULL DEFAULT 0;
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
cur.execute(sql)
|
|
||||||
con.commit()
|
|
||||||
except sqltool.Error as e:
|
|
||||||
if kwargs.get('silent') != 1:
|
|
||||||
if e.args[0] == 'duplicate column name: active' or e == " 1060 (42S21): Duplicate column name 'active' ":
|
|
||||||
print('Updating... go to version 3.4.1')
|
|
||||||
else:
|
|
||||||
print("An error occurred:", e)
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
print("Updating... go to version 3.4.1")
|
|
||||||
return True
|
|
||||||
cur.close()
|
|
||||||
con.close()
|
|
||||||
|
|
||||||
|
|
||||||
def update_db_v_3_4_1(**kwargs):
|
|
||||||
con, cur = get_cur()
|
|
||||||
sql = """
|
|
||||||
ALTER TABLE `user` ADD COLUMN activeuser INTEGER NOT NULL DEFAULT 1;
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
cur.execute(sql)
|
|
||||||
con.commit()
|
|
||||||
except sqltool.Error as e:
|
|
||||||
if kwargs.get('silent') != 1:
|
|
||||||
if e.args[0] == 'duplicate column name: activeuser' or e == " 1060 (42S21): Duplicate column name 'activeuser' ":
|
|
||||||
print('Updating... go to version 3.4.9.5')
|
|
||||||
else:
|
|
||||||
print("An error occurred:", e)
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
print("Updating... go to version 3.4.5.2")
|
|
||||||
return True
|
|
||||||
cur.close()
|
|
||||||
con.close()
|
|
||||||
|
|
||||||
|
|
||||||
def update_db_v_3_4_5_2(**kwargs):
|
def update_db_v_3_4_5_2(**kwargs):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
|
@ -452,7 +316,7 @@ def update_db_v_3_8_1(**kwargs):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if kwargs.get('silent') != 1:
|
if kwargs.get('silent') != 1:
|
||||||
print('DB was update to 3.8.1')
|
print('Updating... go to version 3.12.0.0')
|
||||||
return True
|
return True
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
@ -467,9 +331,9 @@ def update_db_v_3_12(**kwargs):
|
||||||
except sqltool.Error as e:
|
except sqltool.Error as e:
|
||||||
if kwargs.get('silent') != 1:
|
if kwargs.get('silent') != 1:
|
||||||
if e.args[0] == 'duplicate column name: id' or e == "1060 (42S21): Duplicate column name 'id' ":
|
if e.args[0] == 'duplicate column name: id' or e == "1060 (42S21): Duplicate column name 'id' ":
|
||||||
print('DB was update to 3.12')
|
print('Updating... go to version 3.12.1.0')
|
||||||
else:
|
else:
|
||||||
print("DB was update to 3.12")
|
print("Updating... go to version 3.12.1.0")
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
@ -477,9 +341,28 @@ def update_db_v_3_12(**kwargs):
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
|
def update_db_v_3_12_1(**kwargs):
|
||||||
|
con, cur = get_cur()
|
||||||
|
sql = """INSERT INTO settings (param, value, section, `desc`) values('ssl_local_path', 'certs', 'main', 'Path to dir for local save SSL certs. This is a relative path, begins with $HOME_HAPROXY-WI/app/'); """
|
||||||
|
try:
|
||||||
|
cur.execute(sql)
|
||||||
|
con.commit()
|
||||||
|
except sqltool.Error as e:
|
||||||
|
if kwargs.get('silent') != 1:
|
||||||
|
if e.args[0] == 'duplicate column name: param' or e == "1060 (42S21): Duplicate column name 'param' ":
|
||||||
|
print('DB was update to 3.12.1.0')
|
||||||
|
else:
|
||||||
|
print("DB was update to 3.12.1.0")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
cur.close()
|
||||||
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def update_ver(**kwargs):
|
def update_ver(**kwargs):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
sql = """update version set version = '3.12.0.0'; """
|
sql = """update version set version = '3.12.1.0'; """
|
||||||
try:
|
try:
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
con.commit()
|
con.commit()
|
||||||
|
@ -491,13 +374,6 @@ def update_ver(**kwargs):
|
||||||
|
|
||||||
def update_all():
|
def update_all():
|
||||||
update_db_v_31()
|
update_db_v_31()
|
||||||
update_db_v_3_2()
|
|
||||||
update_db_v_3_21()
|
|
||||||
update_db_v_3_2_3()
|
|
||||||
update_db_v_3_2_8()
|
|
||||||
update_db_v_3_31()
|
|
||||||
update_db_v_3_4()
|
|
||||||
update_db_v_3_4_1()
|
|
||||||
update_db_v_3_4_5_2()
|
update_db_v_3_4_5_2()
|
||||||
if funct.check_ver() is None:
|
if funct.check_ver() is None:
|
||||||
update_db_v_3_4_5_22()
|
update_db_v_3_4_5_22()
|
||||||
|
@ -506,18 +382,12 @@ def update_all():
|
||||||
update_db_v_3_5_3()
|
update_db_v_3_5_3()
|
||||||
update_db_v_3_8_1()
|
update_db_v_3_8_1()
|
||||||
update_db_v_3_12()
|
update_db_v_3_12()
|
||||||
|
update_db_v_3_12_1()
|
||||||
update_ver()
|
update_ver()
|
||||||
|
|
||||||
|
|
||||||
def update_all_silent():
|
def update_all_silent():
|
||||||
update_db_v_31(silent=1)
|
update_db_v_31(silent=1)
|
||||||
update_db_v_3_2(silent=1)
|
|
||||||
update_db_v_3_21(silent=1)
|
|
||||||
update_db_v_3_2_3(silent=1)
|
|
||||||
update_db_v_3_2_8(silent=1)
|
|
||||||
update_db_v_3_31(silent=1)
|
|
||||||
update_db_v_3_4(silent=1)
|
|
||||||
update_db_v_3_4_1(silent=1)
|
|
||||||
update_db_v_3_4_5_2(silent=1)
|
update_db_v_3_4_5_2(silent=1)
|
||||||
if funct.check_ver() is None:
|
if funct.check_ver() is None:
|
||||||
update_db_v_3_4_5_22()
|
update_db_v_3_4_5_22()
|
||||||
|
@ -526,6 +396,7 @@ def update_all_silent():
|
||||||
update_db_v_3_5_3(silent=1)
|
update_db_v_3_5_3(silent=1)
|
||||||
update_db_v_3_8_1(silent=1)
|
update_db_v_3_8_1(silent=1)
|
||||||
update_db_v_3_12(silent=1)
|
update_db_v_3_12(silent=1)
|
||||||
|
update_db_v_3_12_1(silent=1)
|
||||||
update_ver()
|
update_ver()
|
||||||
|
|
||||||
|
|
||||||
|
|
21
app/funct.py
21
app/funct.py
|
@ -162,7 +162,7 @@ def page_for_admin(**kwargs):
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def return_ssh_keys_path(serv):
|
def return_ssh_keys_path(serv, **kwargs):
|
||||||
import sql
|
import sql
|
||||||
fullpath = get_config_var('main', 'fullpath')
|
fullpath = get_config_var('main', 'fullpath')
|
||||||
ssh_enable = ''
|
ssh_enable = ''
|
||||||
|
@ -170,11 +170,18 @@ def return_ssh_keys_path(serv):
|
||||||
ssh_user_name = ''
|
ssh_user_name = ''
|
||||||
ssh_user_password = ''
|
ssh_user_password = ''
|
||||||
|
|
||||||
for sshs in sql.select_ssh(serv=serv):
|
if kwargs.get('id') != '':
|
||||||
ssh_enable = sshs[3]
|
for sshs in sql.select_ssh(id=kwargs.get('id')):
|
||||||
ssh_user_name = sshs[4]
|
ssh_enable = sshs[2]
|
||||||
ssh_user_password = sshs[5]
|
ssh_user_name = sshs[3]
|
||||||
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[2]
|
ssh_user_password = sshs[4]
|
||||||
|
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[1]
|
||||||
|
else:
|
||||||
|
for sshs in sql.select_ssh(serv=serv):
|
||||||
|
ssh_enable = sshs[3]
|
||||||
|
ssh_user_name = sshs[4]
|
||||||
|
ssh_user_password = sshs[5]
|
||||||
|
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[2]
|
||||||
|
|
||||||
return ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name
|
return ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name
|
||||||
|
|
||||||
|
@ -466,7 +473,7 @@ def upload(serv, path, file, **kwargs):
|
||||||
try:
|
try:
|
||||||
file = sftp.put(file, full_path)
|
file = sftp.put(file, full_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging('localhost', ' Cannot upload '+file+' to '+full_path+'. Error: '+str(e.args), haproxywi=1)
|
logging('localhost', ' Cannot upload '+file+' to '+full_path+' to server: '+serv+' Error: '+str(e.args), haproxywi=1)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
[main]
|
[main]
|
||||||
#Path to files destination
|
#Path to files destination
|
||||||
fullpath = /var/www/haproxy-wi
|
fullpath = /var/www/haproxy-wi
|
||||||
cgi_path = ${fullpath}/app/
|
log_path = ${fullpath}/log/
|
||||||
log_path = ${fullpath}/log/
|
|
||||||
cert_local_dir = ${cgi_path}/certs/
|
|
||||||
|
|
||||||
[configs]
|
[configs]
|
||||||
#Dir where configs will be save
|
#Dir where configs will be save
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
CREATE TABLE IF NOT EXISTS `user` (`id` INTEGER NOT NULL AUTO_INCREMENT,`username` VARCHAR ( 64 ) UNIQUE,`email` VARCHAR ( 120 ) UNIQUE, `password` VARCHAR ( 128 ),`role` VARCHAR ( 128 ),`groups` VARCHAR ( 120 ), PRIMARY KEY(`id`) );
|
CREATE TABLE IF NOT EXISTS `user` (`id` INTEGER NOT NULL AUTO_INCREMENT,`username` VARCHAR ( 64 ) UNIQUE,`email` VARCHAR ( 120 ) UNIQUE, `password` VARCHAR ( 128 ),`role` VARCHAR ( 128 ),`groups` VARCHAR ( 120 ), activeuser INTEGER NOT NULL DEFAULT 1, PRIMARY KEY(`id`) );
|
||||||
INSERT INTO `user` (username, email, password, role, groups) VALUES ('admin','admin@localhost','21232f297a57a5a743894a0e4a801fc3','admin','1');
|
INSERT INTO `user` (username, email, password, role, groups) VALUES ('admin','admin@localhost','21232f297a57a5a743894a0e4a801fc3','admin','1');
|
||||||
INSERT INTO `user` (username, email, password, role, groups) VALUES ('editor','editor@localhost','5aee9dbd2a188839105073571bee1b1f','editor','1');
|
INSERT INTO `user` (username, email, password, role, groups) VALUES ('editor','editor@localhost','5aee9dbd2a188839105073571bee1b1f','editor','1');
|
||||||
INSERT INTO `user` (username, email, password, role, groups) VALUES ('guest','guest@localhost','084e0343a0486ff05530df6c705c8bb4','guest','1');
|
INSERT INTO `user` (username, email, password, role, groups) VALUES ('guest','guest@localhost','084e0343a0486ff05530df6c705c8bb4','guest','1');
|
||||||
CREATE TABLE IF NOT EXISTS `servers` (`id` INTEGER NOT NULL AUTO_INCREMENT,`hostname` VARCHAR ( 64 ) UNIQUE,`ip` VARCHAR ( 64 ) UNIQUE,`groups` VARCHAR ( 64 ), type_ip INTEGER NOT NULL DEFAULT 0, enable INTEGER NOT NULL DEFAULT 1, master INTEGER NOT NULL DEFAULT 0, cred INTEGER NOT NULL DEFAULT 1, alert INTEGER NOT NULL DEFAULT 0, metrics INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`) );
|
CREATE TABLE IF NOT EXISTS `servers` (`id` INTEGER NOT NULL AUTO_INCREMENT,`hostname` VARCHAR ( 64 ) UNIQUE,`ip` VARCHAR ( 64 ) UNIQUE,`groups` VARCHAR ( 64 ), type_ip INTEGER NOT NULL DEFAULT 0, enable INTEGER NOT NULL DEFAULT 1, master INTEGER NOT NULL DEFAULT 0, cred INTEGER NOT NULL DEFAULT 1, alert INTEGER NOT NULL DEFAULT 0, metrics INTEGER NOT NULL DEFAULT 0, port INTEGER NOT NULL DEFAULT 22, `desc` varchar(64), active INTEGER NOT NULL DEFAULT 0,PRIMARY KEY(`id`) );
|
||||||
CREATE TABLE IF NOT EXISTS `role` (`id` INTEGER NOT NULL AUTO_INCREMENT,`name` VARCHAR ( 80 ) UNIQUE,`description` VARCHAR ( 255 ),PRIMARY KEY(`id`) );
|
CREATE TABLE IF NOT EXISTS `role` (`id` INTEGER NOT NULL AUTO_INCREMENT,`name` VARCHAR ( 80 ) UNIQUE,`description` VARCHAR ( 255 ),PRIMARY KEY(`id`) );
|
||||||
INSERT INTO `role` (name, description) VALUES ('admin','Can do everything');
|
INSERT INTO `role` (name, description) VALUES ('admin','Can do everything');
|
||||||
INSERT INTO `role` (name, description) VALUES ('editor','Can edit configs');
|
INSERT INTO `role` (name, description) VALUES ('editor','Can edit configs');
|
||||||
|
@ -18,4 +18,6 @@ CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64) UNIQUE, value varchar
|
||||||
CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64));
|
CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64));
|
||||||
CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
||||||
CREATE TABLE IF NOT EXISTS `saved_servers` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `description` VARCHAR ( 120 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
CREATE TABLE IF NOT EXISTS `saved_servers` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `description` VARCHAR ( 120 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
||||||
CREATE TABLE IF NOT EXISTS `backups` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `rhost` VARCHAR ( 120 ), `rpath` VARCHAR ( 120 ), `time` VARCHAR ( 120 ), cred INTEGER, `description` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
CREATE TABLE IF NOT EXISTS `backups` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `rhost` VARCHAR ( 120 ), `rpath` VARCHAR ( 120 ), `time` VARCHAR ( 120 ), cred INTEGER, `description` VARCHAR ( 120 ), PRIMARY KEY(`id`));
|
||||||
|
CREATE TABLE IF NOT EXISTS `waf` (`server_id` INTEGER UNIQUE, metrics INTEGER);
|
||||||
|
CREATE TABLE IF NOT EXISTS `waf_metrics` (`serv` varchar(64), conn INTEGER, `date` DATETIME default '0000-00-00 00:00:00');
|
54
app/lists.py
54
app/lists.py
|
@ -1,54 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
import os
|
|
||||||
import http, cgi
|
|
||||||
import funct
|
|
||||||
import sql
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'))
|
|
||||||
template = env.get_template('lists.html')
|
|
||||||
|
|
||||||
print('Content-type: text/html\n')
|
|
||||||
funct.check_login()
|
|
||||||
form = funct.form
|
|
||||||
funct.page_for_admin(level = 2)
|
|
||||||
|
|
||||||
try:
|
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
|
||||||
user_id = cookie.get('uuid')
|
|
||||||
user = sql.get_user_name_by_uuid(user_id.value)
|
|
||||||
user_group = sql.get_user_group_by_uuid(user_id.value)
|
|
||||||
servers = sql.get_dick_permit(virt=1)
|
|
||||||
token = sql.get_token(user_id.value)
|
|
||||||
servbackend = form.getvalue('servbackend')
|
|
||||||
serv = form.getvalue('serv')
|
|
||||||
if servbackend is None:
|
|
||||||
servbackend = ""
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
dir = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')
|
|
||||||
white_dir = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+user_group+"/white"
|
|
||||||
black_dir = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+user_group+"/black"
|
|
||||||
if not os.path.exists(dir):
|
|
||||||
os.makedirs(dir)
|
|
||||||
if not os.path.exists(dir+"/"+user_group):
|
|
||||||
os.makedirs(dir+"/"+user_group)
|
|
||||||
if not os.path.exists(white_dir):
|
|
||||||
os.makedirs(white_dir)
|
|
||||||
if not os.path.exists(black_dir):
|
|
||||||
os.makedirs(black_dir)
|
|
||||||
|
|
||||||
white_lists = funct.get_files(dir=white_dir, format="lst")
|
|
||||||
black_lists = funct.get_files(dir=black_dir, format="lst")
|
|
||||||
|
|
||||||
template = template.render(h2 = 1,
|
|
||||||
title = "Lists",
|
|
||||||
role = sql.get_user_role_by_uuid(user_id.value),
|
|
||||||
user = user,
|
|
||||||
white_lists = white_lists,
|
|
||||||
black_lists = black_lists,
|
|
||||||
group = user_group,
|
|
||||||
versions = funct.versions(),
|
|
||||||
token = token)
|
|
||||||
print(template)
|
|
|
@ -76,7 +76,8 @@ if form.getvalue('ssh_cert'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if serv and form.getvalue('ssl_cert'):
|
if serv and form.getvalue('ssl_cert'):
|
||||||
cert_local_dir = funct.get_config_var('main', 'cert_local_dir')
|
#cert_local_dir = funct.get_config_var('main', 'cert_local_dir')
|
||||||
|
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')
|
||||||
|
|
||||||
if not os.path.exists(cert_local_dir):
|
if not os.path.exists(cert_local_dir):
|
||||||
|
@ -936,34 +937,40 @@ if form.getvalue('bwlists'):
|
||||||
|
|
||||||
|
|
||||||
if form.getvalue('bwlists_create'):
|
if form.getvalue('bwlists_create'):
|
||||||
|
color = form.getvalue('color')
|
||||||
list_name = form.getvalue('bwlists_create').split('.')[0]
|
list_name = form.getvalue('bwlists_create').split('.')[0]
|
||||||
list_name += '.lst'
|
list_name += '.lst'
|
||||||
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+form.getvalue('color')+"/"+list_name
|
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+color+"/"+list_name
|
||||||
try:
|
try:
|
||||||
open(list, 'a').close()
|
open(list, 'a').close()
|
||||||
print('<div class="alert alert-success" style="margin:0">'+form.getvalue('color')+' list was created</div>')
|
print('<div class="alert alert-success" style="margin:0">'+form.getvalue('color')+' list was created</div>')
|
||||||
|
funct.logging(server[1], 'has created '+color+' list '+list_name, haproxywi=1, login=1)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print('<div class="alert alert-danger" style="margin:0">Cat\'n create new '+form.getvalue('color')+' list. %s </div>' % e)
|
print('<div class="alert alert-danger" style="margin:0">Cat\'n create new '+form.getvalue('color')+' list. %s </div>' % e)
|
||||||
|
|
||||||
|
|
||||||
if form.getvalue('bwlists_save'):
|
if form.getvalue('bwlists_save'):
|
||||||
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+form.getvalue('color')+"/"+form.getvalue('bwlists_save')
|
color = form.getvalue('color')
|
||||||
|
bwlists_save = form.getvalue('bwlists_save')
|
||||||
|
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+color+"/"+bwlists_save
|
||||||
try:
|
try:
|
||||||
with open(list, "w") as file:
|
with open(list, "w") as file:
|
||||||
file.write(form.getvalue('bwlists_content'))
|
file.write(form.getvalue('bwlists_content'))
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print('<div class="alert alert-danger" style="margin:0">Cat\'n save '+form.getvalue('color')+' list. %s </div>' % e)
|
print('<div class="alert alert-danger" style="margin:0">Cat\'n save '+color+' list. %s </div>' % e)
|
||||||
|
|
||||||
servers = sql.get_dick_permit()
|
servers = sql.get_dick_permit()
|
||||||
path = sql.get_setting('haproxy_dir')+"/"+form.getvalue('color')
|
path = sql.get_setting('haproxy_dir')+"/"+color
|
||||||
|
|
||||||
for server in servers:
|
for server in servers:
|
||||||
funct.ssh_command(server[2], ["sudo mkdir "+path])
|
funct.ssh_command(server[2], ["sudo mkdir "+path])
|
||||||
error = funct.upload(server[2], path+"/"+form.getvalue('bwlists_save'), list, dir='fullpath')
|
funct.ssh_command(server[2], ["sudo chown $(whoami) "+path])
|
||||||
|
error = funct.upload(server[2], path+"/"+bwlists_save, list, dir='fullpath')
|
||||||
if error:
|
if error:
|
||||||
print('<div class="alert alert-danger">Upload fail: %s</div>' % error)
|
print('<div class="alert alert-danger">Upload fail: %s</div>' % error)
|
||||||
else:
|
else:
|
||||||
print('<div class="alert alert-success" style="margin:10px">Edited '+form.getvalue('color')+' list was uploaded to '+server[1]+'</div>')
|
print('<div class="alert alert-success" style="margin:10px">Edited '+color+' list was uploaded to '+server[1]+'</div>')
|
||||||
|
funct.logging(server[1], 'has edited '+color+' list '+bwlists_save, haproxywi=1, login=1)
|
||||||
if form.getvalue('bwlists_restart') == 'restart':
|
if form.getvalue('bwlists_restart') == 'restart':
|
||||||
funct.ssh_command(server[2], ["sudo " + sql.get_setting('restart_command')])
|
funct.ssh_command(server[2], ["sudo " + sql.get_setting('restart_command')])
|
||||||
|
|
||||||
|
@ -1016,3 +1023,4 @@ if form.getvalue('change_waf_mode'):
|
||||||
serv = sql.select_server_by_name(server_hostname)
|
serv = sql.select_server_by_name(server_hostname)
|
||||||
commands = [ "sudo sed -i 's/^SecRuleEngine.*/SecRuleEngine %s/' %s/waf/modsecurity.conf " % (waf_mode, haproxy_dir) ]
|
commands = [ "sudo sed -i 's/^SecRuleEngine.*/SecRuleEngine %s/' %s/waf/modsecurity.conf " % (waf_mode, haproxy_dir) ]
|
||||||
funct.ssh_command(serv, commands)
|
funct.ssh_command(serv, commands)
|
||||||
|
funct.logging(serv, 'Was changed WAF mod to '+waf_mode, haproxywi=1, login=1)
|
||||||
|
|
|
@ -37,6 +37,6 @@ output_from_parsed_template = template.render(title = "Servers manage",
|
||||||
telegrams = sql.get_user_telegram_by_uuid(user_id.value),
|
telegrams = sql.get_user_telegram_by_uuid(user_id.value),
|
||||||
token = token,
|
token = token,
|
||||||
versions = funct.versions(),
|
versions = funct.versions(),
|
||||||
backups = sql.select_backups(),
|
backups = sql.select_backups(),
|
||||||
ldap_enable = ldap_enable)
|
ldap_enable = ldap_enable)
|
||||||
print(output_from_parsed_template)
|
print(output_from_parsed_template)
|
||||||
|
|
|
@ -1635,7 +1635,7 @@ if form.getvalue('newserver') is not None:
|
||||||
else:
|
else:
|
||||||
if add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics, port, desc, active):
|
if add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics, port, desc, active):
|
||||||
show_update_server(ip, page)
|
show_update_server(ip, page)
|
||||||
funct.logging('a new server '+hostname, ' created ', haproxywi=1, login=1)
|
#funct.logging('a new server '+hostname, ' created ', haproxywi=1, login=1)
|
||||||
|
|
||||||
|
|
||||||
if form.getvalue('serverdel') is not None:
|
if form.getvalue('serverdel') is not None:
|
||||||
|
|
|
@ -19,9 +19,11 @@ h3 {
|
||||||
<li><a href="#ssl">SSL certificates</a></li>
|
<li><a href="#ssl">SSL certificates</a></li>
|
||||||
<li><a href="#option">Options</a></li>
|
<li><a href="#option">Options</a></li>
|
||||||
<li><a href="#add-servers">Servers</a></li>
|
<li><a href="#add-servers">Servers</a></li>
|
||||||
<li><a href="#userlist">Userlist</a></li>
|
<li><a href="#userlist">Userlists</a></li>
|
||||||
|
<li><a href="#lists">Lists</a></li>
|
||||||
{% include 'include/login.html' %}
|
{% include 'include/login.html' %}
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul id='browse_histroy'></ul>
|
||||||
{% include 'include/add_proxy.html' %}
|
{% include 'include/add_proxy.html' %}
|
||||||
<div id="listen">
|
<div id="listen">
|
||||||
<form name="add-listner" action="/app/add.py" method="post">
|
<form name="add-listner" action="/app/add.py" method="post">
|
||||||
|
@ -172,6 +174,9 @@ h3 {
|
||||||
<td class="addName">Servers:</td>
|
<td class="addName">Servers:</td>
|
||||||
<td class="addOption">
|
<td class="addOption">
|
||||||
{% include 'include/add_servers.html' %}
|
{% include 'include/add_servers.html' %}
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
{{ checkbox('template-listen', name='template', title='Use server-template instead servers list', value='template', desc='Server-template') }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="advance">
|
<tr class="advance">
|
||||||
|
@ -470,6 +475,9 @@ h3 {
|
||||||
<td class="addName">Servers:</td>
|
<td class="addName">Servers:</td>
|
||||||
<td class="addOption">
|
<td class="addOption">
|
||||||
{% include 'include/add_servers.html' %}
|
{% include 'include/add_servers.html' %}
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
{{ checkbox('template-backend', name='template', title='Use server-template instead servers list', value='template', desc='Server-template') }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="advance">
|
<tr class="advance">
|
||||||
|
@ -739,6 +747,45 @@ h3 {
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<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>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="padding10 first-collumn" style="width: 25%;">
|
||||||
|
Name: {{ input('new_blacklist_name') }}
|
||||||
|
<button onclick="createList('black')">Create</button>
|
||||||
|
</td>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
{% for list in black_lists %}
|
||||||
|
<a onclick="editList('{{ list }}', 'black')" style="cursor: pointer;" title="Edit list {{ list }}">{{ list }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</td>
|
||||||
|
<td class="padding10 first-collumn" style="width: 25%;">
|
||||||
|
Name: {{ input('new_whitelist_name') }}
|
||||||
|
<button onclick="createList( 'white')">Create</button>
|
||||||
|
</td>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
{% for list in white_lists %}
|
||||||
|
<a onclick="editList('{{ list }}', 'white')" style="cursor: pointer;" title="Edit list {{ list }}">{{ list }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{ input('group', value=group, type='hidden') }}
|
||||||
|
</table>
|
||||||
|
<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" 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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% include 'include/del_confirm.html' %}
|
{% include 'include/del_confirm.html' %}
|
||||||
<div id="dialog-confirm-cert" title="View certificate " style="display: none;">
|
<div id="dialog-confirm-cert" title="View certificate " style="display: none;">
|
||||||
<center><pre id="dialog-confirm-body"></pre></center>
|
<center><pre id="dialog-confirm-body"></pre></center>
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
<li><a href="#backup">Backup</a></li>
|
<li><a href="#backup">Backup</a></li>
|
||||||
{% include 'include/login.html' %}
|
{% include 'include/login.html' %}
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul id='browse_histroy'></ul>
|
||||||
<div id="users">
|
<div id="users">
|
||||||
<table class="overview" id="ajax-users">
|
<table class="overview" id="ajax-users">
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
|
|
|
@ -71,8 +71,8 @@
|
||||||
<li><a href="/app/add.py#ssl" title="Upload SSL cert" class="cert head-submenu" id="add4">SSL</a></li>
|
<li><a href="/app/add.py#ssl" title="Upload SSL cert" class="cert head-submenu" id="add4">SSL</a></li>
|
||||||
<li><a href="/app/add.py#option" title="Save custom options" class="option head-submenu" id="add5">Options</a></li>
|
<li><a href="/app/add.py#option" title="Save custom options" class="option head-submenu" id="add5">Options</a></li>
|
||||||
<li><a href="/app/add.py#add-servers" title="Save servers" class="runtime head-submenu" id="add6">Servers</a></li>
|
<li><a href="/app/add.py#add-servers" title="Save servers" class="runtime head-submenu" id="add6">Servers</a></li>
|
||||||
<li><a href="/app/add.py#userlist" title="Add userlist" class="add-userlist head-submenu" id="add7">User list</a></li>
|
<li><a href="/app/add.py#userlist" title="Add userlist" class="add-userlist head-submenu" id="add7">User lists</a></li>
|
||||||
<li><a href="/app/lists.py" title="Manage black and white lists" class="lists head-submenu">Lists</a> </li>
|
<li><a href="/app/add.py#lists" title="Manage black and white lists" class="lists head-submenu" id="add8">Lists</a></li>
|
||||||
<li><a href="/app/waf.py" title="Web application firewall" class="waf head-submenu">WAF</a> </li>
|
<li><a href="/app/waf.py" title="Web application firewall" class="waf head-submenu">WAF</a> </li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
<span name="add_servers">
|
<span name="add_servers">
|
||||||
|
<input name="prefix" class="prefix form-control" title="servers prefix" size="3" placeholder="web" style="display: none;">
|
||||||
|
<input name="template-number" class="prefix form-control" title="servers num" value="3" type="number" style="width: 35px; display: none;">
|
||||||
<input name="servers" required title="Backend IP" size=14 placeholder="xxx.xxx.xxx.xxx" class="form-control">:
|
<input name="servers" required title="Backend IP" size=14 placeholder="xxx.xxx.xxx.xxx" class="form-control">:
|
||||||
<input name="server_port" required title="Backend IP" size=1 placeholder="yyy" class="form-control">
|
<input name="server_port" required title="Backend IP" size=1 placeholder="yyy" class="form-control">
|
||||||
<br />
|
<br />
|
||||||
<input name="servers" title="Backend port" size=14 placeholder="xxx.xxx.xxx.xxx" class="form-control">:
|
<input name="servers" title="Backend port" size=14 placeholder="xxx.xxx.xxx.xxx" class="form-control second-server"><span class="second-server">:</span>
|
||||||
<input name="server_port" title="Backend port" size=1 placeholder="yyy" class="form-control">
|
<input name="server_port" title="Backend port" size=1 placeholder="yyy" class="form-control second-server">
|
||||||
<br />
|
<br />
|
||||||
<input name="servers" title="Backend port" size=14 placeholder="xxx.xxx.xxx.xxx" class="form-control">:
|
<input name="servers" title="Backend port" size=14 placeholder="xxx.xxx.xxx.xxx" class="form-control second-server"><span class="second-server">:</span>
|
||||||
<input name="server_port" title="Backend port" size=1 placeholder="yyy" class="form-control">
|
<input name="server_port" title="Backend port" size=1 placeholder="yyy" class="form-control second-server">
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<a class="add-server" name="add-server-input" title="Add backend server" style="cursor: pointer;"></a>
|
<a class="add-server" name="add-server-input" title="Add backend server" style="cursor: pointer;"></a>
|
||||||
</span>
|
</span>
|
||||||
|
<a href="https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4.2-server-template" title="Read about Server-template" target="_blank" class="prefix" style="display: none; font-size: 13px; color: #23527c;">Read about Server-template</a>
|
|
@ -1,41 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
{% block content %}
|
|
||||||
{% from 'include/input_macros.html' import input %}
|
|
||||||
<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>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">
|
|
||||||
Name: {{ input('new_blacklist_name') }}
|
|
||||||
<button onclick="createList('black')">Create</button>
|
|
||||||
</td>
|
|
||||||
<td style="width: 30%;">
|
|
||||||
{% for list in black_lists %}
|
|
||||||
<a onclick="editList('{{ list }}', 'black')" style="cursor: pointer;" title="Edit list {{ list }}">{{ list }}</a>
|
|
||||||
{% endfor %}
|
|
||||||
</td>
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">
|
|
||||||
Name: {{ input('new_whitelist_name') }}
|
|
||||||
<button onclick="createList( 'white')">Create</button>
|
|
||||||
</td>
|
|
||||||
<td style="width: 30%;">
|
|
||||||
{% for list in white_lists %}
|
|
||||||
<a onclick="editList('{{ list }}', 'white')" style="cursor: pointer;" title="Edit list {{ list }}">{{ list }}</a>
|
|
||||||
{% endfor %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ input('group', value=group, type='hidden') }}
|
|
||||||
</table>
|
|
||||||
<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" title="View certificate " style="display: none;">
|
|
||||||
<span><b>Note:</b> Each new address should be specified from a new line</span>
|
|
||||||
<textarea id="edit_lists" style="width: 100%" rows=20></textarea>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -21,6 +21,7 @@
|
||||||
<li><a href="#backup">Backup</a></li>
|
<li><a href="#backup">Backup</a></li>
|
||||||
{% include 'include/login.html' %}
|
{% include 'include/login.html' %}
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul id='browse_histroy'></ul>
|
||||||
<div id="users">
|
<div id="users">
|
||||||
<table class="overview" id="ajax-users">
|
<table class="overview" id="ajax-users">
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
|
|
22
inc/add.js
22
inc/add.js
|
@ -630,6 +630,19 @@ $( function() {
|
||||||
$( "#blacklist-hide-input1" ).prop('required',false);
|
$( "#blacklist-hide-input1" ).prop('required',false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$( ":regex(id, template)" ).click( function(){
|
||||||
|
if ($(':regex(id, template)').is(':checked')) {
|
||||||
|
$( ".prefix" ).show( "fast" );
|
||||||
|
$( ".second-server" ).hide( "fast" );
|
||||||
|
$( ".add-server" ).hide( "fast" );
|
||||||
|
$( ".prefix" ).attr('required',true);
|
||||||
|
} else {
|
||||||
|
$( ".prefix" ).hide( "fast" );
|
||||||
|
$( ".prefix" ).attr('required',false);
|
||||||
|
$( ".second-server" ).show( "fast" );
|
||||||
|
$( ".add-server" ).show( "fast" )
|
||||||
|
}
|
||||||
|
});
|
||||||
var location = window.location.href;
|
var location = window.location.href;
|
||||||
var cur_url = '/app/' + location.split('/').pop();
|
var cur_url = '/app/' + location.split('/').pop();
|
||||||
cur_url = cur_url.split('?');
|
cur_url = cur_url.split('?');
|
||||||
|
@ -699,6 +712,15 @@ $( function() {
|
||||||
});
|
});
|
||||||
$( "#tabs" ).tabs( "option", "active", 7 );
|
$( "#tabs" ).tabs( "option", "active", 7 );
|
||||||
} );
|
} );
|
||||||
|
$( "#add8" ).on( "click", function() {
|
||||||
|
$('.menu li ul li').each(function () {
|
||||||
|
$(this).find('a').css('padding-left', '20px')
|
||||||
|
$(this).find('a').css('border-left', '0px solid #5D9CEB');
|
||||||
|
$(this).children("#add8").css('padding-left', '30px');
|
||||||
|
$(this).children("#add8").css('border-left', '4px solid #5D9CEB');
|
||||||
|
});
|
||||||
|
$( "#tabs" ).tabs( "option", "active", 8 );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
$( "#path-cert-listen" ).autocomplete({
|
$( "#path-cert-listen" ).autocomplete({
|
||||||
|
|
Loading…
Reference in New Issue