Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reverse proxy settings function #179

Open
ohyeah521 opened this issue Sep 27, 2024 · 4 comments
Open

Add reverse proxy settings function #179

ohyeah521 opened this issue Sep 27, 2024 · 4 comments
Labels
request implementation request

Comments

@ohyeah521
Copy link

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

@N4S4
Copy link
Owner

N4S4 commented Sep 28, 2024

If I understood correctly you wish to have the ability to setup the built-in reverse proxy via API, is it right?

@N4S4 N4S4 added the request implementation request label Sep 28, 2024
@ohyeah521
Copy link
Author

Yes, this is a screenshot of the web interface
setting

settings

@ohyeah521
Copy link
Author

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)

@N4S4
Copy link
Owner

N4S4 commented Oct 12, 2024

Thank you i will have a look this afternoon and implement as suggested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request implementation request
Projects
None yet
Development

No branches or pull requests

2 participants