Arvid Norberg
2016-05-04 23:30:04 UTC
I've been spending some time in master simplifying and generalizing the
piece of code that opens listen sockets. Previously (and in current 1.1
branch) support for IPv6 is hacked in there, with an implied assumption
that you either have an IPv4 address, IPv6 address or both. and if you
specify INADDR_ANY as your listen address, it'll try to bind to both IPv6
and IPv4 address families.
As I'm hoping to improve support for IPv6, I'm re-thinking support for
multi-homed machines in general. For instance, you may have two IPv4 and an
IPv6 address.
Going over the parts of libtorrent that's affected, it seems that
supporting multiple interfaces may involve more than just the list of
listen sockets you have.
There's another gross piece of logic around supporting announcing to
trackers when you have an IPv6 IP, which basically detects whether one of
the listen sockets you have is bound to an IPv6 address. If so _and_ the
tracker resolved to at least on IPv6 address, a second announce is made.
The generalization of this would be that for every tracker announce, each
listen socket interface with a compatible address family should issue an
announce, in parallel (there's no reason to delay or serialize them). I
believe doing this properly requires some form of BIND_TO_DEVICE support,
which I believe is fairly well supported on mainstream OSes these days
(albeit under different name).
Taking this reasoning to it's extreme, it would seem reasonable to also
announce all of ones listen IPs to the DHT. The only reasonable way I can
think of doing that is to have a DHT instance running per listen interface.
You can have multiple listen sockets bound to the same IP, but that would
still just count as a single listen interface. I suppose to announce all
ports, one would have to issue multiple announces in parallel.
thoughts?
piece of code that opens listen sockets. Previously (and in current 1.1
branch) support for IPv6 is hacked in there, with an implied assumption
that you either have an IPv4 address, IPv6 address or both. and if you
specify INADDR_ANY as your listen address, it'll try to bind to both IPv6
and IPv4 address families.
As I'm hoping to improve support for IPv6, I'm re-thinking support for
multi-homed machines in general. For instance, you may have two IPv4 and an
IPv6 address.
Going over the parts of libtorrent that's affected, it seems that
supporting multiple interfaces may involve more than just the list of
listen sockets you have.
There's another gross piece of logic around supporting announcing to
trackers when you have an IPv6 IP, which basically detects whether one of
the listen sockets you have is bound to an IPv6 address. If so _and_ the
tracker resolved to at least on IPv6 address, a second announce is made.
The generalization of this would be that for every tracker announce, each
listen socket interface with a compatible address family should issue an
announce, in parallel (there's no reason to delay or serialize them). I
believe doing this properly requires some form of BIND_TO_DEVICE support,
which I believe is fairly well supported on mainstream OSes these days
(albeit under different name).
Taking this reasoning to it's extreme, it would seem reasonable to also
announce all of ones listen IPs to the DHT. The only reasonable way I can
think of doing that is to have a DHT instance running per listen interface.
You can have multiple listen sockets bound to the same IP, but that would
still just count as a single listen interface. I suppose to announce all
ports, one would have to issue multiple announces in parallel.
thoughts?
--
Arvid Norberg
Arvid Norberg