Connecting via IPv6

66 views
Skip to first unread message

Florian Zeitz

unread,
Oct 22, 2011, 9:36:08 PM10/22/11
to proso...@googlegroups.com
Hello everyone,

this is it. The one you have all been waiting for, an hg export to make
Prosody connect to other servers over IPv6! \o/
</exageration>

Status:
I have tested this code quite a bit now, however not in production. Also
while the concept it is using should be fine, the implementation might
be a bit messy and have quirks.
Therefore both testing and peer review is very appreciated.

Requirements:
For the time being it requires luasocket from
http://code.matthewwild.co.uk/luasocket2-hg/.
In order to get the IP sorting to work properly you'll also have to
include your IP addresses in the config.
There is currently no decent way (I know of) to otherwise determine the
addresses prosody is bound to.
This would look somethig like this:
interface = {"23.42.64.3", "127.0.0.1", "2001::dead:beef:42", "::1"}
Note this *will* work if you bind to 0.0.0.0 and ::, but sorting will
(wrongly) prefer IPv4 addresses in that configuration.

Details:
The export consists of 3 commits.
The first one adds util.ip. It is mainly there to make my life easier
when sorting the addresses. There has been discussion about adding such
a util and I think this one should be extendable enough to do whatever
others had planed for it.
Properties are lazily calculated in order to minimize overhead during
sorting.
Some of the code is certainly hackish. I'm particularly not fond of the
conversion to bits and the prefix matching in various places.

The second one adds util.rfc3484. This is an implementation of
destination address and source address selection as described in RFC
3484. Some of the rules from that RFC are not implemented due to lack of
available information. It still passes most of the examples/test cases
given in that RFC though (I added a test to check this).
From reading through the RFC I'm also under the impression that it is
expected implementers will not necessarily implement all of the rules.
Only a single rule is a MUST and it is among the implemented ones.

The third one adds the actual connection logic. It uses the same
principle as the SRV record selection. I'm not going to go into more
detail here, because honestly it is giving me headaches. This change is
the main reason I'm asking for reviews, especially by people who
understand/wrote the original code (eyes Matthew and/or Waqas).
As previously mentioned this gets the source address candidates from the
config file. That should change eventually, but will (AFAICT) at least
require further changes to luasocket and is probably hard to get right
in a portable way.

--
Florian 'Florob' Zeitz

Florian Zeitz

unread,
Oct 22, 2011, 9:41:22 PM10/22/11
to proso...@googlegroups.com
And yes, I did forget to attach the export...
ipv6connect.exp

Kim Alvefur

unread,
Oct 23, 2011, 9:34:59 PM10/23/11
to proso...@googlegroups.com
On Sun, 2011-10-23 at 03:36 +0200, Florian Zeitz wrote:
> Hello everyone,
>
> this is it. The one you have all been waiting for, an hg export to
> make
> Prosody connect to other servers over IPv6! \o/
> </exageration>

Awesome work!

So, since I can't express how truly awesome this is, I'm going to jump
right ahead to some issues that we found:

* Sessions hitting NXDOMAIN doesn't get cleaned up properly, and will
sit around with session.conn = nil
* SRV records indicating lack of service at that domain (target = .)
causes a complain about a nil connect_host (exact error got lost)

If there were more, then they were either lost in the chat history, or
haven't been found yet.

--
Kim Alvefur <za...@zash.se>

Florian Zeitz

unread,
Oct 30, 2011, 11:42:08 AM10/30/11
to proso...@googlegroups.com

I forgot to update the list on this, sorry.
I'm maintaining an updated export at
<http://babelmonkeys.de/~florob/ipv6connect.exp>.
It already fixes the two issues Zash mentions above. Nothing else has
yet been reported to me.

Reply all
Reply to author
Forward
0 new messages