mirror of
https://github.com/Ysurac/openmptcprouter-vps-admin.git
synced 2025-02-12 18:41:52 +00:00
Add latest Shadowsocks-Go API
This commit is contained in:
parent
b31e764e7b
commit
371ce38ec2
2 changed files with 75 additions and 49 deletions
7
debian/changelog
vendored
7
debian/changelog
vendored
|
@ -1,3 +1,10 @@
|
||||||
|
omr-vps-admin (0.13+20241016) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Add Shadowsocks-go new API support
|
||||||
|
* Add option to disable 6in4
|
||||||
|
|
||||||
|
-- OpenMPTCProuter <contact@openmptcprouter.com> Wed, 16 Oct 2024 15:49:13 +0200
|
||||||
|
|
||||||
omr-vps-admin (0.12+20240920) unstable; urgency=medium
|
omr-vps-admin (0.12+20240920) unstable; urgency=medium
|
||||||
|
|
||||||
* Fix Shadowsocks-go changes
|
* Fix Shadowsocks-go changes
|
||||||
|
|
23
omr-admin.py
23
omr-admin.py
|
@ -159,6 +159,19 @@ def get_bytes_ss(port):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def get_bytes_ss_go(user):
|
def get_bytes_ss_go(user):
|
||||||
|
try:
|
||||||
|
#r = requests.get(url="http://127.0.0.1:65279/v1/servers/ss-2022/stats")
|
||||||
|
r = requests.get(url="http://127.0.0.1:65279/api/ssm/v1/servers/ss-2022/stats")
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
LOG.debug("Shadowsocks go stats timeout")
|
||||||
|
return { 'downlinkBytes': 0, 'uplinkBytes': 0 }
|
||||||
|
except requests.exceptions.RequestException as err:
|
||||||
|
LOG.debug("Shadowsocks go stats error (" + str(err) + ")")
|
||||||
|
return { 'downlinkBytes': 0, 'uplinkBytes': 0 }
|
||||||
|
try:
|
||||||
|
if 'error' in r.json():
|
||||||
|
return { 'downlinkBytes': 0, 'uplinkBytes': 0 }
|
||||||
|
except requests.exceptions.JSONDecodeError:
|
||||||
try:
|
try:
|
||||||
r = requests.get(url="http://127.0.0.1:65279/v1/servers/ss-2022/stats")
|
r = requests.get(url="http://127.0.0.1:65279/v1/servers/ss-2022/stats")
|
||||||
#r = requests.get(url="http://127.0.0.1:65279/api/ssm/v1/servers/ss-2022/stats")
|
#r = requests.get(url="http://127.0.0.1:65279/api/ssm/v1/servers/ss-2022/stats")
|
||||||
|
@ -168,8 +181,12 @@ def get_bytes_ss_go(user):
|
||||||
except requests.exceptions.RequestException as err:
|
except requests.exceptions.RequestException as err:
|
||||||
LOG.debug("Shadowsocks go stats error (" + str(err) + ")")
|
LOG.debug("Shadowsocks go stats error (" + str(err) + ")")
|
||||||
return { 'downlinkBytes': 0, 'uplinkBytes': 0 }
|
return { 'downlinkBytes': 0, 'uplinkBytes': 0 }
|
||||||
|
try:
|
||||||
if 'error' in r.json():
|
if 'error' in r.json():
|
||||||
return { 'downlinkBytes': 0, 'uplinkBytes': 0 }
|
return { 'downlinkBytes': 0, 'uplinkBytes': 0 }
|
||||||
|
except requests.exceptions.JSONDecodeError as err:
|
||||||
|
LOG.debug("Shadowsocks go stats error (" + str(err) + ")")
|
||||||
|
return { 'downlinkBytes': 0, 'uplinkBytes': 0 }
|
||||||
if 'users' in r.json():
|
if 'users' in r.json():
|
||||||
for userdata in r.json()['users']:
|
for userdata in r.json()['users']:
|
||||||
if userdata['username'] == user:
|
if userdata['username'] == user:
|
||||||
|
@ -1924,7 +1941,7 @@ async def config(userid: Optional[int] = Query(None), serial: Optional[str] = Qu
|
||||||
locaip6 = 'fd00::a00:1'
|
locaip6 = 'fd00::a00:1'
|
||||||
remoteip6 = 'fd00::a00:2'
|
remoteip6 = 'fd00::a00:2'
|
||||||
|
|
||||||
vpn = 'glorytun_tcp'
|
vpn = 'openvpn'
|
||||||
if 'vpn' in omr_config_data['users'][0][username]:
|
if 'vpn' in omr_config_data['users'][0][username]:
|
||||||
vpn = omr_config_data['users'][0][username]['vpn']
|
vpn = omr_config_data['users'][0][username]['vpn']
|
||||||
|
|
||||||
|
@ -3076,6 +3093,8 @@ def vpnips(*, vpnconfig: VPNips, current_user: User = Depends(get_current_user))
|
||||||
userid = current_user.userid
|
userid = current_user.userid
|
||||||
if userid is None:
|
if userid is None:
|
||||||
userid = 0
|
userid = 0
|
||||||
|
|
||||||
|
if not '6in4' in omr_config_data or omr_config_data['6in4']:
|
||||||
if os.path.isfile('/etc/openmptcprouter-vps-admin/omr-6in4/user' + str(userid)):
|
if os.path.isfile('/etc/openmptcprouter-vps-admin/omr-6in4/user' + str(userid)):
|
||||||
initial_md5 = hashlib.md5(file_as_bytes(open('/etc/openmptcprouter-vps-admin/omr-6in4/user' + str(userid), 'rb'))).hexdigest()
|
initial_md5 = hashlib.md5(file_as_bytes(open('/etc/openmptcprouter-vps-admin/omr-6in4/user' + str(userid), 'rb'))).hexdigest()
|
||||||
else:
|
else:
|
||||||
|
@ -3123,6 +3142,7 @@ def vpnips(*, vpnconfig: VPNips, current_user: User = Depends(get_current_user))
|
||||||
os.system("systemctl -q reload shorewall")
|
os.system("systemctl -q reload shorewall")
|
||||||
#set_lastchange()
|
#set_lastchange()
|
||||||
|
|
||||||
|
if not '6in4' in omr_config_data or omr_config_data['6in4']:
|
||||||
initial_md5 = hashlib.md5(file_as_bytes(open('/etc/shorewall6/params.vpn', 'rb'))).hexdigest()
|
initial_md5 = hashlib.md5(file_as_bytes(open('/etc/shorewall6/params.vpn', 'rb'))).hexdigest()
|
||||||
fd, tmpfile = mkstemp()
|
fd, tmpfile = mkstemp()
|
||||||
dataexist = False
|
dataexist = False
|
||||||
|
@ -3141,7 +3161,6 @@ def vpnips(*, vpnconfig: VPNips, current_user: User = Depends(get_current_user))
|
||||||
n.write('OMR_ADDR_USER' + str(userid) + '=fd00::a0' + hex(userid)[2:] + ':2/126' + '\n')
|
n.write('OMR_ADDR_USER' + str(userid) + '=fd00::a0' + hex(userid)[2:] + ':2/126' + '\n')
|
||||||
elif userid == 0:
|
elif userid == 0:
|
||||||
n.write('OMR_ADDR=fd00::a0' + hex(userid)[2:] + ':2/126' + '\n')
|
n.write('OMR_ADDR=fd00::a0' + hex(userid)[2:] + ':2/126' + '\n')
|
||||||
|
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
move(tmpfile, '/etc/shorewall6/params.vpn')
|
move(tmpfile, '/etc/shorewall6/params.vpn')
|
||||||
final_md5 = hashlib.md5(file_as_bytes(open('/etc/shorewall6/params.vpn', 'rb'))).hexdigest()
|
final_md5 = hashlib.md5(file_as_bytes(open('/etc/shorewall6/params.vpn', 'rb'))).hexdigest()
|
||||||
|
|
Loading…
Reference in a new issue