1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-25 23:21:41 +03:00

Fixed so, if an invalid IP is configured on trusted source, it gets logged and ignored

This commit is contained in:
Adolfo Gómez García 2020-10-29 06:22:52 +01:00
parent 758f409372
commit 8634ce50c6

View File

@ -143,8 +143,11 @@ def trustedSourceRequired(view_func: typing.Callable[..., RT]) -> typing.Callabl
"""
Wrapped function for decorator
"""
if net.ipInNetwork(request.ip, GlobalConfig.TRUSTED_SOURCES.get(True)) is False:
return HttpResponseForbidden()
try:
if net.ipInNetwork(request.ip, GlobalConfig.TRUSTED_SOURCES.get(True)) is False:
return HttpResponseForbidden()
except Exception as e:
logger.warning('Error checking trusted source: "%s" does not seems to be a valid network string. Using Unrestricted access.', GlobalConfig.TRUSTED_SOURCES.get())
return view_func(request, *args, **kwargs)
return _wrapped_view