mirror of
https://github.com/Ysurac/openmptcprouter-vps-admin.git
synced 2025-03-09 15:40:05 +00:00
Fix and add log
This commit is contained in:
parent
58171a876c
commit
3885f9896d
1 changed files with 13 additions and 1 deletions
14
omr-admin.py
14
omr-admin.py
|
@ -173,6 +173,8 @@ def check_username_serial(username, serial):
|
||||||
if data:
|
if data:
|
||||||
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as outfile:
|
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as outfile:
|
||||||
json.dump(data, outfile, indent=4)
|
json.dump(data, outfile, indent=4)
|
||||||
|
else:
|
||||||
|
LOG.debug("Empty data for check_username_serial")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def set_global_param(key, value):
|
def set_global_param(key, value):
|
||||||
|
@ -187,14 +189,18 @@ def set_global_param(key, value):
|
||||||
if data:
|
if data:
|
||||||
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as outfile:
|
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as outfile:
|
||||||
json.dump(data, outfile, indent=4)
|
json.dump(data, outfile, indent=4)
|
||||||
|
else:
|
||||||
|
LOG.debug("Empty data for set_global_param")
|
||||||
|
|
||||||
def modif_config_user(user, changes):
|
def modif_config_user(user, changes):
|
||||||
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json') as f:
|
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json') as f:
|
||||||
content = json.load(f)
|
content = json.load(f)
|
||||||
content['users'][0][user].update(changes)
|
content['users'][0][user].update(changes)
|
||||||
if data:
|
if content:
|
||||||
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as f:
|
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as f:
|
||||||
json.dump(content, f, indent=4)
|
json.dump(content, f, indent=4)
|
||||||
|
else:
|
||||||
|
LOG.debug("Empty data for modif_config_user")
|
||||||
|
|
||||||
|
|
||||||
def add_ss_user(port, key, userid=0, ip=''):
|
def add_ss_user(port, key, userid=0, ip=''):
|
||||||
|
@ -756,6 +762,8 @@ def set_lastchange(sync=0):
|
||||||
if data:
|
if data:
|
||||||
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as outfile:
|
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as outfile:
|
||||||
json.dump(data, outfile, indent=4)
|
json.dump(data, outfile, indent=4)
|
||||||
|
else:
|
||||||
|
LOG.debug("Empty data for set_last_change")
|
||||||
|
|
||||||
|
|
||||||
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json') as f:
|
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json') as f:
|
||||||
|
@ -2320,6 +2328,8 @@ def add_user(*, params: NewUser, current_user: User = Depends(get_current_user))
|
||||||
if content:
|
if content:
|
||||||
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as f:
|
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as f:
|
||||||
json.dump(content, f, indent=4)
|
json.dump(content, f, indent=4)
|
||||||
|
else:
|
||||||
|
LOG.debug("Empty data for add_user")
|
||||||
# Create VPNs configuration
|
# Create VPNs configuration
|
||||||
os.system('cd /etc/openvpn/ca && EASYRSA_CERT_EXPIRE=3650 ./easyrsa build-client-full "' + params.username + '" nopass')
|
os.system('cd /etc/openvpn/ca && EASYRSA_CERT_EXPIRE=3650 ./easyrsa build-client-full "' + params.username + '" nopass')
|
||||||
add_glorytun_tcp(userid)
|
add_glorytun_tcp(userid)
|
||||||
|
@ -2345,6 +2355,8 @@ def remove_user(*, params: RemoveUser, current_user: User = Depends(get_current_
|
||||||
if content:
|
if content:
|
||||||
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as f:
|
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json', 'w') as f:
|
||||||
json.dump(content, f, indent=4)
|
json.dump(content, f, indent=4)
|
||||||
|
else:
|
||||||
|
LOG.debug("Empty data for remover_user")
|
||||||
os.system('cd /etc/openvpn/ca && ./easyrsa --batch revoke ' + params.username)
|
os.system('cd /etc/openvpn/ca && ./easyrsa --batch revoke ' + params.username)
|
||||||
os.system('cd /etc/openvpn/ca && ./easyrsa gen-crl')
|
os.system('cd /etc/openvpn/ca && ./easyrsa gen-crl')
|
||||||
os.system("systemctl -q restart openvpn@tun0")
|
os.system("systemctl -q restart openvpn@tun0")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue