Edgewall Software

Opened 17 years ago

Last modified 7 months ago

#5820 new defect

[PATCH] standalone trac does not accept -b "::" — at Version 11

Reported by: sgala@… Owned by: Jonas Borgström
Priority: low Milestone: next-stable-1.6.x
Component: web frontend/tracd Version: 0.11
Severity: normal Keywords: ipv6, patch
Cc: Thijs Triemstra Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Thijs Triemstra)

(error is: socket.gaierror: (-9, "Address family for hostname not supported")

The way sockets are initialized is wrong. trac (or the underlying wsgi code for python 2.4) is assuming socket.AF_INET before even knowing the server address.

Standard code for initializing a ipv6 aware socket, that will work in ipv4-only machines (see U. Drepper tutorial) is:

>>> import socket
>>> gais = socket.getaddrinfo("::",8000, socket.AF_UNSPEC, socket.SOCK_STREAM) # host, port, af, tcp, ... 
>>> for gai in gais:
...   try:
...     sock = socket.socket(*gai[:2])
...     sock.bind(gai[4])
...     break
...   except:
...     continue
... else:
...   sock = None
...   raise "Error, couldn't bind"

or something similar. This code should work on any python having getaddrinfo, which means anything modern enough. In fact this code will try to bind in any different possibilities given.

None means localhost in the most general way (127.0.0.1 or ::1); "::" or "0.0.0.0" means any ipv6/ipv4 or any ipv4 address. For concrete addresses, getaddrinfo will parse and take care of the socket parameters.

Change History (13)

comment:1 by Emmanuel Blot, 17 years ago

Component: generaltracd

comment:2 by anonymous, 16 years ago

someone should change this ticket to "tracd doesn't support IPv6" -b "::" doesn't ring a bell for most people… BTW this ticket is still valid for trac 0.11

comment:3 by Piotr Kuczynski <piotr.kuczynski@…>, 16 years ago

Keywords: ipv6 added
Milestone: 1.0
Priority: normallow
Version: 0.11

by Christian Boos, 15 years ago

As we discussed r7915 on #irc, I came across this ticket and played around…

comment:4 by Christian Boos, 15 years ago

When I start tracd with -b ::1 -p 8000, it seems I can successfully browser my Trac environment using http://[::1]:8000/devel

But then trying to connect http://127.0.0.1:8000/devel fails.

by Christian Boos, 15 years ago

attempts to listen on both ipv4 and ipv6 addresses

comment:5 by Christian Boos, 15 years ago

PythonBug:3213 and http://mail.python.org/pipermail/python-list/2008-May/489377.html were helpful here.

So with the second patch (which has to be applied in addition to the first), and starting tracd with -b :: -p 8000, I was able to connect to both http://[::1]:8000/devel and http://127.0.0.1:8000/devel (on Windows Vista).

As expected the second request shows up as a mapped ipv4 address:

::ffff:127.0.0.1 Trac[...

comment:6 by Christian Boos, 14 years ago

Milestone: 1.0unscheduled

Milestone 1.0 deleted

comment:7 by Christian Boos, 14 years ago

Milestone: triagingnext-major-0.1X
Priority: lowlowest
Severity: normalminor

comment:8 by Thijs Triemstra <lists@…>, 13 years ago

Cc: lists@… added
Keywords: review added
Summary: standalone trac does not accept -b "::"[PATCH] standalone trac does not accept -b "::"

Seems to me this patch needs a review, I'll check it out.

comment:9 by Thijs Triemstra <lists@…>, 13 years ago

#2491 is another ipv6 issue.

comment:10 by Thijs Triemstra, 13 years ago

Cc: Thijs Triemstra added; lists@… removed

comment:11 by Thijs Triemstra, 13 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.