mirror of https://github.com/Aidaho12/haproxy-wi
parent
f7de094a4f
commit
ec0718f01f
10
api/api.py
10
api/api.py
|
@ -12,7 +12,6 @@ os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||||
sys.path.append(os.path.join(sys.path[0], '/var/www/haproxy-wi/app/'))
|
sys.path.append(os.path.join(sys.path[0], '/var/www/haproxy-wi/app/'))
|
||||||
|
|
||||||
import modules.db.sql as sql
|
import modules.db.sql as sql
|
||||||
import modules.config.config as config_mod
|
|
||||||
import modules.roxywi.common as roxywi_common
|
import modules.roxywi.common as roxywi_common
|
||||||
|
|
||||||
_error_auth = '403 Auth before'
|
_error_auth = '403 Auth before'
|
||||||
|
@ -186,13 +185,6 @@ def add_acl(haproxy_id):
|
||||||
return api_funct.add_acl(haproxy_id)
|
return api_funct.add_acl(haproxy_id)
|
||||||
|
|
||||||
|
|
||||||
@route('/haproxy/<haproxy_id>/acl', method=['DELETE'])
|
|
||||||
def add_acl(haproxy_id):
|
|
||||||
if not check_login(required_service=1):
|
|
||||||
return dict(error=_error_auth)
|
|
||||||
return api_funct.del_acl(haproxy_id)
|
|
||||||
|
|
||||||
|
|
||||||
@route('/<service>/<server_id>', method=['GET'])
|
@route('/<service>/<server_id>', method=['GET'])
|
||||||
@route('/<service>/<server_id:int>', method=['GET'])
|
@route('/<service>/<server_id:int>', method=['GET'])
|
||||||
def callback(server_id, service):
|
def callback(server_id, service):
|
||||||
|
@ -227,7 +219,7 @@ def service_config_show(server_id, service):
|
||||||
if not check_login(required_service=required_service):
|
if not check_login(required_service=required_service):
|
||||||
return dict(error=_error_auth)
|
return dict(error=_error_auth)
|
||||||
config_path = request.headers.get('config-file')
|
config_path = request.headers.get('config-file')
|
||||||
return api_config_mod.get_config(server_id, service=service, config_path=config_path)
|
return api_funct.get_config(server_id, service=service, config_path=config_path)
|
||||||
|
|
||||||
|
|
||||||
@route('/<service>/<server_id>/config', method=['POST'])
|
@route('/<service>/<server_id>/config', method=['POST'])
|
||||||
|
|
|
@ -6,6 +6,7 @@ from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
import modules.db.sql as sql
|
import modules.db.sql as sql
|
||||||
import modules.common.common as common
|
import modules.common.common as common
|
||||||
|
import modules.config.config as config_mod
|
||||||
import modules.roxy_wi_tools as roxy_wi_tools
|
import modules.roxy_wi_tools as roxy_wi_tools
|
||||||
import modules.roxywi.auth as roxywi_auth
|
import modules.roxywi.auth as roxywi_auth
|
||||||
import modules.roxywi.common as roxywi_common
|
import modules.roxywi.common as roxywi_common
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import distro
|
import distro
|
||||||
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
import modules.db.sql as sql
|
import modules.db.sql as sql
|
||||||
import modules.common.common as common
|
import modules.common.common as common
|
||||||
|
@ -9,9 +10,6 @@ import modules.server.server as server_mod
|
||||||
import modules.roxywi.auth as roxywi_auth
|
import modules.roxywi.auth as roxywi_auth
|
||||||
import modules.roxywi.common as roxywi_common
|
import modules.roxywi.common as roxywi_common
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
import modules.roxywi.common as roxywi_common
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('hapservers.html')
|
template = env.get_template('hapservers.html')
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ def send_cookie(login):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_name = sql.get_user_name_by_uuid(user_uuid)
|
user_name = sql.get_user_name_by_uuid(user_uuid)
|
||||||
roxywi_roxywi_common.logging('Roxy-WI server', f' user: {user_name}, group: {user_group} login', roxywi=1)
|
roxywi_common.logging('Roxy-WI server', f' user: {user_name}, group: {user_group} login', roxywi=1)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
print("Content-type: text/html\n")
|
print("Content-type: text/html\n")
|
||||||
|
@ -103,7 +103,7 @@ def send_cookie(login):
|
||||||
else:
|
else:
|
||||||
sql.insert_user_name(user_name)
|
sql.insert_user_name(user_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
roxywi_roxywi_common.logging('Cannot update subscription: ', str(e), roxywi=1)
|
roxywi_common.logging('Cannot update subscription: ', str(e), roxywi=1)
|
||||||
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
@ -117,9 +117,9 @@ def ban():
|
||||||
c["ban"]["Secure"] = "True"
|
c["ban"]["Secure"] = "True"
|
||||||
c["ban"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
c["ban"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
||||||
try:
|
try:
|
||||||
roxywi_roxywi_common.logging('Roxy-WI server', f'{login} failed log in', roxywi=1, login=1)
|
roxywi_common.logging('Roxy-WI server', f'{login} failed log in', roxywi=1, login=1)
|
||||||
except Exception:
|
except Exception:
|
||||||
roxywi_roxywi_common.logging('Roxy-WI server', ' Failed log in. Wrong username', roxywi=1)
|
roxywi_common.logging('Roxy-WI server', ' Failed log in. Wrong username', roxywi=1)
|
||||||
print(c.output())
|
print(c.output())
|
||||||
print("Content-type: text/html\n")
|
print("Content-type: text/html\n")
|
||||||
print('ban')
|
print('ban')
|
||||||
|
|
|
@ -290,7 +290,7 @@ def keepalived_master_install():
|
||||||
hostname = sql.get_hostname_by_server_ip(master)
|
hostname = sql.get_hostname_by_server_ip(master)
|
||||||
firewall = 1 if server_mod.is_service_active(master, 'firewalld') else 0
|
firewall = 1 if server_mod.is_service_active(master, 'firewalld') else 0
|
||||||
sql.add_server(
|
sql.add_server(
|
||||||
hostname + '-VIP', IP, group_id, '1', '1', '0', cred_id, ssh_settings['port'], f'VRRP IP for {master}',
|
hostname + '-VIP', vrrp_ip, group_id, '1', '1', '0', cred_id, ssh_settings['port'], f'VRRP IP for {master}',
|
||||||
haproxy, nginx, '0', firewall
|
haproxy, nginx, '0', firewall
|
||||||
)
|
)
|
||||||
os.remove(script)
|
os.remove(script)
|
||||||
|
|
Loading…
Reference in New Issue