Closed
Description
in debug_toolbar/middleware.py
is following code:
def show_toolbar(request):
"""
Default function to determine whether to show the toolbar on a given page.
"""
internal_ips = list(settings.INTERNAL_IPS)
try:
# This is a hack for docker installations. It attempts to look
# up the IP address of the docker host.
# This is not guaranteed to work.
docker_ip = (
# Convert the last segment of the IP address to be .1
".".join(socket.gethostbyname("host.docker.internal").rsplit(".")[:-1])
+ ".1"
)
internal_ips.append(docker_ip)
except socket.gaierror:
# It's fine if the lookup errored since they may not be using docker
pass
return settings.DEBUG and request.META.get("REMOTE_ADDR") in internal_ips
on every request it tries to resolve host.docker.internal
which might lead to a timeout from the resolver running locally.
I believe at least this behaviour should be described in the documentation and that it might cause problems with certain resolvers.
Also I believe it should be sufficient to do this name resolution only once per server startup and not at every request.
Another way might be to use the documentation to decribe how to add host.docker.internal
to INTERNAL_IPS
if a user is inclined to do so.
What do you think?
Metadata
Metadata
Assignees
Labels
No labels