synology-api
synology-api copied to clipboard
Add reverse proxy settings function
Is it possible to add a reverse proxy interface? Because when using a reverse proxy, you need to set up access control rules to automatically block some malicious IP addresses.
http://ip:port/webapi/entry.cgi/SYNO.Core.AppPortal.AccessControl
If I understood correctly you wish to have the ability to setup the built-in reverse proxy via API, is it right?
Yes, this is a screenshot of the web interface
Add the following code to the core_sys_info.py file
def list_accesscontrol(self) -> dict[str, object] | str:
api_name = 'SYNO.Core.AppPortal.AccessControl'
info = self.core_list[api_name]
api_path = info['path']
req_param = {'version': info['maxVersion'], 'method': 'list'}
return self.request_data(api_name, api_path, req_param)
def update_accesscontrol(self, entry: str) -> dict[str, object] | str:
api_name = 'SYNO.Core.AppPortal.AccessControl'
info = self.core_list[api_name]
api_path = info['path'] +"/SYNO.Core.AppPortal.AccessControl"
req_param = {'version': info['maxVersion'], 'method': 'update', 'entry': str(entry)}
return self.request_data(api_name, api_path, req_param)
Usage:
syno = core_sys_info.SysInfo(...)
lac = syno.list_accesscontrol()
print(lac)
# output: {'data': {'entries': [{'UUID': 'xxxx', '_key': 'xxxxxx', 'name': 'block', 'rules': [{'access': True, 'address': '192.164.74.88'}, {'access': False, 'address': '188.125.2.23'}]}]}, 'success': True}
ip={}
ip["address"]="19.64.74.88"
ip["access"]=True
rules.append(ip)
org_entries["rules"]=rules
entry = str(org_entries).replace("True","true").replace("False","false").replace(" ","")
# The execution here fails and returns 502
uac = syno.update_accesscontrol( entry)
Thank you i will have a look this afternoon and implement as suggested