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

Support running as unix socket #362

Open
ghost opened this issue May 8, 2020 · 0 comments
Open

Support running as unix socket #362

ghost opened this issue May 8, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented May 8, 2020

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants