Skip to content

Support running as unix socket #362

@ghost

Description

Pyramid debugtoolbar should implicitly support running as a unix domain socket like it does for localhost. Development configuration with a domain socket signifies developer intent.

My development environment runs waitress with unix_socket inside a system (LXC/LXD) container without a network interface. The server is accessed with a socat instance running on the container host that forwards to the guest's socket. The system container runs a virtual network simulating public IPv4 address space and this is the simplest setup I've found that's compatible with the unpredictable IP addressing of the host.

When accessing the reverse proxy or directly ncing the unix domain socket, waitress returns a 500 and produces this backtrace:

2020-05-08 21:38:18,476 INFO  [wanmap.schema][MainThread] Initializing Engine
2020-05-08 21:38:18,477 INFO  [wanmap.schema][MainThread] Established Engine(postgresql://@/wanmap)
2020-05-08 21:38:43,930 ERROR [waitress][waitress] Exception while serving /
Traceback (most recent call last):
  File "/opt/wanmap/lib/python3.8/site-packages/waitress/channel.py", line 356, in service
    task.service()
  File "/opt/wanmap/lib/python3.8/site-packages/waitress/task.py", line 172, in service
    self.execute()
  File "/opt/wanmap/lib/python3.8/site-packages/waitress/task.py", line 440, in execute
    app_iter = self.channel.server.application(environ, start_response)
  File "/opt/wanmap/lib/python3.8/site-packages/paste/deploy/config.py", line 291, in __call__
    return self.app(environ, start_response)
  File "/opt/wanmap/lib/python3.8/site-packages/paste/deploy/config.py", line 291, in __call__
    return self.app(environ, start_response)
  File "/opt/wanmap/lib/python3.8/site-packages/pyramid/router.py", line 270, in __call__
    response = self.execution_policy(environ, self)
  File "/opt/wanmap/lib/python3.8/site-packages/pyramid/router.py", line 279, in default_execution_policy
    return request.invoke_exception_view(reraise=True)
  File "/opt/wanmap/lib/python3.8/site-packages/pyramid/view.py", line 778, in invoke_exception_view
    reraise_(*exc_info)
  File "/opt/wanmap/lib/python3.8/site-packages/pyramid/compat.py", line 179, in reraise
    raise value
  File "/opt/wanmap/lib/python3.8/site-packages/pyramid/router.py", line 277, in default_execution_policy
    return router.invoke_request(request)
  File "/opt/wanmap/lib/python3.8/site-packages/pyramid/router.py", line 249, in invoke_request
    response = handle_request(request)
  File "/opt/wanmap/lib/python3.8/site-packages/pyramid_debugtoolbar/toolbar.py", line 220, in toolbar_tween
    or not addr_in(client_addr, hosts)
  File "/opt/wanmap/lib/python3.8/site-packages/pyramid_debugtoolbar/utils.py", line 200, in addr_in
    if ipaddress.ip_address(u'' + addr) in ipaddress.ip_network(u'' + host):
  File "/usr/lib/python3.8/ipaddress.py", line 53, in ip_address
    raise ValueError('%r does not appear to be an IPv4 or IPv6 address' %
ValueError: 'localhost' does not appear to be an IPv4 or IPv6 address

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions